Resume only the task that owns the event
You let input-required and terminal events resume only their identity-scoped owning continuation. Recorded envelopes make that boundary testable without a live server.
Worked example
See the idea in context
target := ax.AxEventTarget{
ID: "reindex-flow", RetrySafety: "idempotent",
WaitFor: []map[string]ax.Value{{
"kind": "mcp.task", "value": "taskKey",
"metadata": map[string]ax.Value{"taskId": taskID},
}},
MapInput: func(event ax.AxEventEnvelope, continuation *ax.AxEventContinuation) (ax.Value, error) {
if continuation != nil {
return map[string]ax.Value{"taskId": continuation.Metadata["taskId"]}, nil
}
return map[string]ax.Value{"taskId": event.Data.(map[string]ax.Value)["taskId"]}, nil
},
Invoke: invokeFlow,
}
routes := []ax.AxEventRoute{
{ID: "task-start", Action: "wake", TargetID: "reindex-flow", Match: map[string]ax.Value{"types": ax.Array("app.task.started")}},
{ID: "task-resume", Action: "resume", TargetID: "reindex-flow", Match: map[string]ax.Value{"types": ax.Array("mcp.task.status")}},
}Run itIn your own project
go get github.com/ax-llm/ax/packages/go
import axllm "github.com/ax-llm/ax/packages/go"
client := axllm.NewAI("openai", map[string]axllm.Value{"apiKey": os.Getenv("OPENAI_API_KEY")})
classify := axllm.NewAx("review:string -> sentiment:class \"positive, negative, neutral\"", nil)Set OPENAI_APIKEY in your environment before running provider-backed code.
From a clone of the ax repo:
npm run example -- go src/examples/go/mcp/resource_wake_agent.goActive practice
Answer 2 in a row to learn this · attempt 1