Add a runnable example for the public messageworkflow chat-protocol primitives - #752
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a first runnable Go example demonstrating the public message/messageworkflow turn-token / message-accumulation protocol, and wires it into the repository’s example verification harness to keep it deterministic and continuously checked.
Changes:
- Introduces
examples/03-workflows/message-workflow, a runnable workflow showingConfigureForwarding(relay) +Configure(chat) +DisableAutoSendTurnTokenbehavior across two scenarios. - Registers the new example in
cmd/verifyexamples/examples.gowith deterministic expected output substrings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| examples/03-workflows/message-workflow/main.go | New runnable sample exercising messageworkflow primitives (message accumulation + turn token semantics + forwarding). |
| cmd/verifyexamples/examples.go | Adds the new example to the verification list with deterministic output expectations. |
💡 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/message-workflow demonstrating the public messageworkflow package: Configure accumulates messages and invokes TakeTurnHandler once per TurnToken, ConfigureForwarding relays messages and turn tokens downstream, and DisableAutoSendTurnToken controls whether the token is forwarded after a turn. Register it in verifyexamples as a deterministic example.
5d8d1f2 to
1335976
Compare
Parity Review — PR #752Scope: Exported API surface changed: None. This PR exercises the pre-existing public API — Cross-repo parity: The PR claims to mirror upstream .NET and Python "MessageWorkflow" samples. Checking Behavior parity: The two demo scenarios ( Verdict: ✅ No parity issues. The change is example-only, stays within the existing public API, and is conceptually aligned with the upstream framework. 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/message-workflow, the first runnable example that exercises the publicmessage/messageworkflowpackage. Until now the turn-token / message-accumulation protocol had no example —grep messageworkflow examples/returned zero matches, and the only in-repo consumers were the internalagentworkflowbuilders.The example wires
driver -> relay -> chat -> collector:messageworkflow.Configurebuilds thechatexecutor: it accumulates every*message.Message/[]*message.Messageit receives and invokes itsTakeTurnHandlerexactly once when aTurnTokenarrives, building a single reply from the accumulated turn.messageworkflow.ConfigureForwardingbuilds therelayexecutor that relays messages and turn tokens downstream (withStringMessageRoleset so bare strings are forwarded as user messages).DisableAutoSendTurnToken: with auto-send (the default) the collector observes the forwardedTurnToken(forwarded turn tokens: 1); with it disabled the token stops at the chat executor (forwarded turn tokens: 0). Both runs showTakeTurnHandler invocations: 1, confirming aTurnTokentriggers exactly one turn regardless of how many messages accumulated.Registered in
cmd/verifyexamples/examples.goas a deterministic example (no model credentials required).Why
This mirrors the .NET / Python
MessageWorkflowsamples, where the chat-message protocol (buffer messages, take a turn on a token, forward the token to the next participant) is documented with a runnable sample. The Go port already exposes the same primitives (Configure,ConfigureForwarding,Options.DisableAutoSendTurnToken) but had no example, leaving the turn-token path undocumented for users. PR #691 added godoc only; this adds the missing executable walkthrough, keeping cross-SDK parity.Testing
go build ./...go vet ./examples/03-workflows/message-workflow/... ./cmd/verifyexamples/...go test ./cmd/verifyexamples/...go run ./examples/03-workflows/message-workflow/— output contains the accumulated messages in order (You said: hello | how are you?),forwarded turn tokens: 1then0, andTakeTurnHandler invocations: 1for both scenarios.