Unify agent workflow responses as output events - #124
Conversation
API Consistency ReviewSummary: This PR ports the spirit of What upstream .NET PR #3441 did
Consumers can still do What this Go PR does
Go consumers now need two nested type assertions to reach a response payload, which is more verbose than the upstream API intends and could make cross-language documentation and samples harder to keep aligned. Suggested alignment options
See inline comment on
|
There was a problem hiding this comment.
Generated by Go API Consistency Review Agent for issue #124 · ● 619K
There was a problem hiding this comment.
Pull request overview
This PR unifies workflow-hosted agent responses under workflow.OutputEvent instead of the dedicated ResponseUpdateEvent / ResponseEvent types, and updates the provider, examples, and tests to consume the new event shape. It affects core workflow event semantics, hosted-agent behavior, and the workflow-backed agent provider.
Changes:
- Remove dedicated workflow response event types and route hosted-agent updates/responses through
OutputEvent. - Update
workflowproviderto translate hosted-agentOutputEventpayloads into agent response updates. - Refresh examples and tests to look for
OutputEventpayload types instead of the removed event types.
Show a summary per file
| File | Description |
|---|---|
workflow/inproc/context.go |
Removes special handling that previously converted yielded agent responses into dedicated workflow events. |
workflow/event.go |
Deletes the exported ResponseUpdateEvent and ResponseEvent types from the public workflow API. |
examples/03-workflows/_start-here/03_agent_workflow_patterns/main.go |
Updates the sample to read hosted-agent streaming updates from OutputEvent. |
examples/03-workflows/_start-here/02_agents_in_workflows/main.go |
Updates the sample to read hosted-agent streaming updates from OutputEvent. |
agent/provider/workflowprovider/workflow.go |
Reworks workflow-event-to-agent-update translation around OutputEvent payloads. |
agent/provider/workflowprovider/workflow_test.go |
Adjusts provider tests for the new output-event-based response flow. |
agent/hosting/workflowhosting/workflow.go |
Changes hosted agents to emit streaming updates and aggregated responses as OutputEvents. |
agent/hosting/workflowhosting/workflow_test.go |
Updates hosted-agent tests to collect typed payloads from OutputEvent. |
agent/hosting/workflowhosting/inprocess_execution_test.go |
Updates in-process execution tests and adds coverage for hosted-agent outputs without WithOutputFrom. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (2)
workflow/inproc/context.go:496
- Removing the
*agent.ResponseUpdate/*agent.Responsespecial-casing here meansctx.YieldOutput(...)from a non-output executor is now dropped silently unless the binding is also registered withWithOutputFrom. That is a behavior regression for existing plain executors that relied on agent-style outputs being surfaced without declaring workflow outputs.
YieldOutput: func(output any) error {
// Check if this executor can output
if _, ok := proc.wf.OutputExecutors[executorID]; ok {
return proc.AddEvent(ctx, workflow.OutputEvent{
ExecutorID: executorID,
Output: output,
})
agent/hosting/workflowhosting/workflow.go:461
- This has the same compatibility problem as the streaming path above: a hosted agent that is not in
WithOutputFromwill now still surface aworkflow.OutputEventhere, so consumers listening for declared workflow outputs start receiving an extra aggregated*agent.Responsefrom every hosted agent in the graph.
if h.cfg.EmitResponseEvents {
if err := wctx.AddEvent(workflow.OutputEvent{ExecutorID: h.id, Output: &resp}); err != nil {
- Files reviewed: 9/9 changed files
- Comments generated: 3
|
Agent response events are a bit more difficult to consume with this change, as they need one additional type cast. On the other hand, there is now no possible confusion about which event will be emitted when there is an agent response. It is not possible to achieve 100% parity with .NET due to the lack of inheritance, so I've picked the side of consistency and clarity over verbosity. |
Summary
AgentResponse[Update]events asWorkflowOutputEvents agent-framework#3441Tests