Skip to content

Add a sequential agent-workflow example demonstrating WithChainOnlyAgentResponses#709

Open
PratikDhanave wants to merge 1 commit into
microsoft:mainfrom
PratikDhanave:sequential-chain-only-example
Open

Add a sequential agent-workflow example demonstrating WithChainOnlyAgentResponses#709
PratikDhanave wants to merge 1 commit into
microsoft:mainfrom
PratikDhanave:sequential-chain-only-example

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

What

Adds examples/03-workflows/01-start-here/08_sequential_chain_only_responses, a runnable example that demonstrates SequentialWorkflowBuilder.WithChainOnlyAgentResponses(true).

The example chains three deterministic agents (writer -> translator -> reviewer) via agentworkflow.NewSequentialWorkflowBuilder(...).WithChainOnlyAgentResponses(true).Build(). Each stage prints the messages it received before replying, so the reader can see that the translator and reviewer only ever receive the single message produced by the previous agent — not the seed prompt or the full accumulated conversation.

Sample output:

Seed prompt: Write a one-line greeting.
=== Writer ===
Writer received 1 message(s):
  [user] Write a one-line greeting.
Writer responds: Hello, world!
=== Translator ===
Translator received 1 message(s):
  [user] Hello, world!
Translator responds: Bonjour, le monde!
=== Reviewer ===
Reviewer received 1 message(s):
  [user] Bonjour, le monde!
Reviewer responds: Approved: Bonjour, le monde!
=== Final workflow output ===
  [assistant] Approved: Bonjour, le monde!

The example is registered as a deterministic entry in cmd/verifyexamples/examples.go, mirroring the existing 07_writer_critic_workflow block.

Why

WithChainOnlyAgentResponses had no example coverage — the only usage outside tests was none, and both existing sequential examples rely on the default (false). The flag controls whether each agent forwards only its own response or the accumulated conversation, which is a meaningful behavioral distinction worth showing. This mirrors the .NET/Python SequentialBuilder chain-only option, and giving it a first-class example keeps the Go samples aligned with the other SDKs where the sequential-orchestration samples make the message-forwarding semantics explicit.

How it is tested

  • Deterministic agents (no external provider/credentials), so the example runs offline. go run ./examples/03-workflows/01-start-here/08_sequential_chain_only_responses/ produces the fixed output above.
  • Registered as an IsDeterministic entry with MustContain assertions (including Translator received 1 message(s):), which is the distinguishing signal — with the default the translator would receive the accumulated conversation instead.
  • The underlying behavior is already covered by TestSequentialWorkflowBuilder_ChainOnlyAgentResponses in workflow/agentworkflow/sequential_test.go.
  • go build ./..., go vet, and go test ./cmd/verifyexamples/ ./workflow/agentworkflow/ all pass.

@PratikDhanave
PratikDhanave requested a review from a team as a code owner July 24, 2026 02:39
Copilot AI review requested due to automatic review settings July 24, 2026 02:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new runnable, deterministic workflow example that demonstrates SequentialWorkflowBuilder.WithChainOnlyAgentResponses(true) by chaining three simple in-process agents and showing (via printed received-message counts) that each stage only receives the prior agent’s output.

Changes:

  • Added 08_sequential_chain_only_responses example showing sequential chaining with chain-only message forwarding.
  • Implemented deterministic writer/translator/reviewer stage agents that log the messages they receive to make forwarding semantics observable.
  • Registered the example in cmd/verifyexamples as a deterministic entry with MustContain assertions to validate behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
examples/03-workflows/01-start-here/08_sequential_chain_only_responses/main.go New deterministic sequential workflow example illustrating chain-only forwarding semantics.
cmd/verifyexamples/examples.go Registers the new example as deterministic with output assertions to verify chain-only behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 24, 2026
@github-actions

This comment has been minimized.

Add examples/03-workflows/01-start-here/08_sequential_chain_only_responses
demonstrating SequentialWorkflowBuilder.WithChainOnlyAgentResponses(true),
which forwards only each agent's own response to the next stage instead of
the full accumulated conversation. The example chains writer -> translator
-> reviewer with deterministic agents that print their received input, so the
reader sees the translator receives only the writer's response, not the seed
prompt. Register it as a deterministic entry in cmd/verifyexamples.
@PratikDhanave
PratikDhanave force-pushed the sequential-chain-only-example branch from feb49c8 to 577532d Compare July 24, 2026 03:01
@github-actions

Copy link
Copy Markdown
Contributor

Parity Review: ✅ Approved

This PR adds only a runnable example (examples/03-workflows/01-start-here/08_sequential_chain_only_responses/) and a corresponding deterministic test entry in cmd/verifyexamples/examples.go. No exported Go APIs are added, changed, or removed.

Cross-SDK alignment

  • The demonstrated feature, SequentialWorkflowBuilder.WithChainOnlyAgentResponses(bool), is semantically aligned with the .NET counterpart in SequentialWorkflowBuilder.cs (same name, same boolean semantics, same default of false).
  • The .NET _StartHere sample tree ends at 07_WriterCriticWorkflow — there is no direct upstream sample for chain-only responses — but the feature exists in the .NET public API and its behavior is identically documented. Adding a Go-specific example for it is a reasonable gap-fill rather than a divergence.
  • Python's _start-here samples follow a different progression (step1–3) and do not include a dedicated sequential-chain sample, so there is no Python parity concern here either.

Label outcome

  • No public Go API surface changed → public-api-change label is not warranted.
  • Feature and example semantics match upstream .NET behavior → parity-approved label correctly remains.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent · 38.1 AIC · ⌖ 4 AIC · ⊞ 5.9K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity-approved Go API consistency review found no parity issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants