Add a workflow-as-agent human-in-the-loop example resuming tool approval across the NewAgent boundary - #744
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Go example demonstrating a human-in-the-loop tool approval flow when a workflow is wrapped as an agent (resuming approval responses across the agentworkflow.NewAgent boundary), and registers it with the example verifier so it can be exercised alongside other workflow samples.
Changes:
- Adds
examples/03-workflows/agents/workflow_as_an_agent_human_in_the_loopshowing tool approval request detection and resume viarequest.CreateResponse(...)on the same session. - Registers the new example in
cmd/verifyexamplesunder the workflows/agents set.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| examples/03-workflows/agents/workflow_as_an_agent_human_in_the_loop/main.go | New runnable sample: sequential workflow wrapped as an agent, with tool approval handled via surfaced request content and resumed on the same session. |
| cmd/verifyexamples/examples.go | Adds the new example to the workflowExamples registry for automated verification. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
Add examples/03-workflows/agents/workflow_as_an_agent_human_in_the_loop demonstrating tool approval resumed across the agentworkflow.NewAgent boundary. A sequential workflow hosts an agent whose function tool is wrapped with tool.ApprovalRequiredFunc; wrapping the workflow as an agent surfaces the pending approval request as a ToolApprovalRequestContent on the run response, and resuming the same session with the matching ToolApprovalResponseContent routes it back into the workflow as an external response to complete the turn. Register the example in cmd/verifyexamples.
2fb6754 to
3611998
Compare
Parity Review: PR #744Summary: This PR adds a new example Scope: Example-only addition — no public API surface changes. Upstream parity check:
The Go example specifically demonstrates the combination of workflow-as-agent with Verdict: ✅ No parity issues found. The example scenario has clear upstream equivalents. The existing Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
What
Adds
examples/03-workflows/agents/workflow_as_an_agent_human_in_the_loopand registers it incmd/verifyexamples.The example builds a sequential workflow that hosts a single agent whose function tool is wrapped with
tool.ApprovalRequiredFunc, then wraps the whole workflow as an agent viaagentworkflow.NewAgent. It:agent.Session.*message.ToolApprovalRequestContent.demo.UserInputRequesthelper, mirroring the approval-detail printing used bygroup_chat_tool_approval).request.CreateResponse(approved, "")soagentworkflowmatches it against the pending request and routes it back into the workflow as aworkflow.ExternalResponseto complete the turn.Why
The
agentworkflowpackage doc already documents that pending workflowRequestInfoEvents are surfaced as agentResponseUpdates carrying request content, resumable by includingmessage.ToolApprovalResponseContentin the next agent run. This path is exercised byTestNew_ApprovalRoundtrip_ResponseIsProcessed, but no runnable example demonstrated it: the existingworkflow_as_an_agentsample wraps a concurrent bilingual workflow with no approval, andgroup_chat_tool_approvalhandles approval at the RAW workflow level (inproc.RunStreaming+run.SendResponse), NOT across theNewAgentagent boundary.This closes the parity gap with the Python SDK's
workflow_as_agent_human_in_the_loop.py, which demonstrates the same resume-across-the-agent-boundary flow. It keeps the Go samples aligned with the cross-SDK "workflow as an agent" HITL story.Testing
go build ./...go vet ./cmd/verifyexamples/... ./examples/03-workflows/agents/...go test ./cmd/verifyexamples/...(registration compiles and validates)The underlying resume behavior is already covered by
TestNew_ApprovalRoundtrip_ResponseIsProcessedinworkflow/agentworkflow/workflow_test.go; this change is example-only and touches no production code.