Add an example demonstrating imperative in-executor human-in-the-loop via Context.PostRequest - #750
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new runnable Go workflow example demonstrating the imperative human-in-the-loop (HITL) pattern where an executor raises an external request via Context.PostRequest and handles the matching *workflow.ExternalResponse directly (as a lower-level counterpart to the existing request-port binding example). The example is registered with cmd/verifyexamples to ensure it stays runnable and output-stable.
Changes:
- Added
examples/03-workflows/human-in-the-loop/imperative_request, showcasing in-executor imperative HITL usingContext.PostRequest. - Implemented a deterministic driver flow that waits for
workflow.RequestInfoEvent, resumes the run with a fixed response, and prints the resulting output. - Registered the example in
cmd/verifyexamples/examples.gowithMustContainoutput assertions.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| examples/03-workflows/human-in-the-loop/imperative_request/main.go | New runnable example demonstrating imperative Context.PostRequest + *workflow.ExternalResponse handling inside a custom *workflow.Executor. |
| cmd/verifyexamples/examples.go | Registers the new example with deterministic output checks for CI 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.
Adds examples/03-workflows/human-in-the-loop/imperative_request showing a custom executor that raises an ExternalRequest imperatively with Context.PostRequest and consumes the matching ExternalResponse itself, the low-level counterpart to the request-port binding in human_in_the_loop_basic. Registers it in verifyexamples.
c0802dd to
d863db3
Compare
Parity Review: ✅ AlignedThis PR adds Cross-repo parity check:
The example closes a documented gap in No parity issues found. The 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.
|
There was a problem hiding this comment.
Looks like you checked this binary in by accident
What
Adds
examples/03-workflows/human-in-the-loop/imperative_request, a runnable sample where a custom*workflow.Executorraises a human-in-the-loop request imperatively from inside a handler viaContext.PostRequestand consumes the matching*workflow.ExternalResponseitself. It is registered incmd/verifyexamples/examples.go.Why
Context.PostRequestis documented inworkflow/workflow.goas a first-class user primitive and is exercised byTestPostRequestFromExecutor, but no committed example showed it — the only HITL sample (human_in_the_loop_basic) uses the higher-levelworkflow.RequestPortbinding. This sample fills that gap and is framed explicitly as the low-level counterpart to the request-port binding, mirroring the .NET/Python guidance where the request-port abstraction and the imperative post-request path are presented as two ways to reach the same external-request/response protocol. Surfacing both keeps the Go examples aligned with the other SDKs.How it works
The executor registers two raw handlers via
RouteBuilder: on the initialstringinput it buildsworkflow.NewExternalRequestand callswctx.PostRequest; on*workflow.ExternalResponseit readsresp.Data.As(port.Response)and yields the greeting. The driver runs withinproc.Default.Run, drains events to catchworkflow.RequestInfoEvent, answers with a fixed value viarun.Resume, and drains the resultingOutputEvent. The shape followsTestPostRequestFromExecutor.Testing
go build ./...go veton the new example andcmd/verifyexamplesHello, Ada!MustContainassertion