Summary
Wire the dispatch-side envelope unwrap and *triggers.Context injection into the Go SDK's reasoner request handler, so a webhook delivery from the control plane lands on a typed handler with a populated context.
Part of the epic #508. Depends on the trigger types from the sibling issue.
Scope
Modified Files
| File |
Change |
sdk/go/agent/agent.go (handler dispatch) |
Recognise the dispatcher's envelope shape {event, _meta}. Peel event (running the binding's Transform if registered). Build a *triggers.Context from _meta. Call the handler with the (transformed) payload and the context. Direct calls (no _meta) call the handler with the raw input unchanged |
Behaviour
Generic handler signature, supported via Go 1.21+ generics:
func handlePayment(ctx context.Context, in Payment, tc *triggers.Context) (any, error) {
if tc != nil {
// dispatched via a trigger
}
return ..., nil
}
tc == nil for direct calls; non-nil when the request body is the dispatcher envelope.
Acceptance
References
Summary
Wire the dispatch-side envelope unwrap and
*triggers.Contextinjection into the Go SDK's reasoner request handler, so a webhook delivery from the control plane lands on a typed handler with a populated context.Part of the epic #508. Depends on the trigger types from the sibling issue.
Scope
Modified Files
sdk/go/agent/agent.go(handler dispatch){event, _meta}. Peelevent(running the binding'sTransformif registered). Build a*triggers.Contextfrom_meta. Call the handler with the (transformed) payload and the context. Direct calls (no_meta) call the handler with the raw input unchangedBehaviour
Generic handler signature, supported via Go 1.21+ generics:
tc == nilfor direct calls; non-nil when the request body is the dispatcher envelope.Acceptance
POST /reasoners/<name>with a flat input still works —tcis nilPOSTwith{event, _meta}envelope shape calls the handler with the transformed payload and a non-nil*triggers.ContextTransformruns before the handler when an envelope is detected, is skipped on direct callsReferences
sdk/python/agentfield/agent.py— theis_trigger_envelopepath