Skip to content

[dotnet-port] Add BuildSequential and BuildConcurrent agent workflow builder helpers - #196

Merged
qmuntal merged 3 commits into
mainfrom
dotnet-port/agent-workflow-builders-74d08e603868111d
May 20, 2026
Merged

[dotnet-port] Add BuildSequential and BuildConcurrent agent workflow builder helpers#196
qmuntal merged 3 commits into
mainfrom
dotnet-port/agent-workflow-builders-74d08e603868111d

Conversation

@qmuntal

@qmuntal qmuntal commented May 18, 2026

Copy link
Copy Markdown
Member

Port .NET's AgentWorkflowBuilder.BuildSequential and AgentWorkflowBuilder.BuildConcurrent convenience functions to Go, including the concurrent aggregation path.

BuildSequential chains agents in order using the default Config (message forwarding and role reassignment enabled), matching .NET's pipeline behavior. It now terminates with an OutputMessages-style executor so the workflow output contains the full turn transcript.

BuildConcurrent fans the input to all agents simultaneously using a lightweight forwarding executor at the start, per-agent turn-message batchers, and a fan-in end executor. BuildConcurrentWithAggregator supports custom, context-aware aggregation and defaults to returning the last message from each non-empty agent batch.

Tests cover single-agent and multi-agent cases for both builders, invalid inputs, custom aggregation, multi-turn concurrent aggregation reset behavior, and the message forwarding executor spec helper.

The agent workflow patterns StartHere sample is synced with the .NET sample's sequential/concurrent builder usage while keeping Azure OpenAI agent construction in the translation agent factory.

Closes the "sequential/concurrent can be composed manually" gap in the feature comparison doc.

Port .NET's AgentWorkflowBuilder.BuildSequential and
AgentWorkflowBuilder.BuildConcurrent convenience functions to Go.

BuildSequential chains agents in order using the default Config (message
forwarding and role reassignment enabled), matching .NET's pipeline
behavior. BuildConcurrent fans the input to all agents simultaneously
using a lightweight forwarding executor at the start, with each agent
configured to not re-forward the shared input.

Tests cover single-agent and multi-agent cases for both builders, plus
error cases for empty input.

Closes the "sequential/concurrent can be composed manually" gap in the
feature comparison doc.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions github-actions Bot 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.

Generated by Go API Consistency Review Agent for issue #196 · ● 3.2M

Comment thread agent/hosting/workflowhosting/builders.go
Comment thread agent/hosting/workflowhosting/builders.go
Comment thread agent/hosting/workflowhosting/builders.go Outdated
@qmuntal
qmuntal marked this pull request as ready for review May 20, 2026 07:52
@qmuntal
qmuntal requested a review from a team as a code owner May 20, 2026 07:52
Copilot AI review requested due to automatic review settings May 20, 2026 07:52
@github-actions

This comment has been minimized.

@github-actions github-actions Bot 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.

Generated by Go API Consistency Review Agent for issue #196 · ● 5.1M

Comment thread agent/hosting/workflowhosting/builders.go

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

This PR ports .NET’s AgentWorkflowBuilder.BuildSequential / BuildConcurrent conveniences into Go by adding workflowhosting builder helpers, plus a small message-forwarding executor spec helper used by the concurrent fan-out path. It also adjusts workflow context handling for observability/tracing and syncs a workflow patterns example + feature comparison docs.

Changes:

  • Add workflowhosting.BuildSequential, BuildConcurrent, and BuildConcurrentWithAggregator helpers (with transcript-style output for sequential and fan-out/fan-in aggregation for concurrent).
  • Introduce messageworkflow.ConfigureForwarding and accompanying tests to forward chat messages / turn tokens (and optionally strings).
  • Update workflow context/telemetry plumbing, refresh tests accordingly, and sync example + feature-comparison documentation.
Show a summary per file
File Description
workflow/workflow.go Removes GetContext() and changes telemetry lookup to use the workflow context directly.
workflow/executor.go Passes *workflow.Context into telemetry span creation (instead of GetContext()).
workflow/executor_test.go Updates tests to populate workflow.Context.Context so executor execution has a real context.
message/messageworkflow/messageworkflow_test.go Sets workflow.Context.Context in tests to avoid nil embedded contexts.
message/messageworkflow/messageforwarding.go Adds ConfigureForwarding helper for forwarding messages/turn tokens (optional string support).
message/messageworkflow/messageforwarding_test.go Adds coverage for forwarding behavior and protocol description.
agent/hosting/workflowhosting/builders.go Adds sequential/concurrent workflow builder helpers + internal executors (start forwarder, per-agent batchers, end aggregator, transcript sink).
agent/hosting/workflowhosting/builders_test.go Adds comprehensive tests for sequential/concurrent builders, custom aggregation, and multi-turn reset behavior.
examples/03-workflows/_start-here/03_agent_workflow_patterns/main.go Updates sample to use new builders and newer OpenAI agent provider package.
docs/dotnet-go-sdk-feature-comparison.md Updates feature comparison to reflect new sequential/concurrent builders.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (1)

workflow/executor.go:285

  • telemetry.StartExecutorProcess is now invoked with ctx (a *workflow.Context) as the context.Context argument. This will panic if ctx.Context (the embedded context) is nil because ctx.Value will dispatch to a nil embedded interface. Either ensure *workflow.Context safely implements context.Context with a non-nil fallback (e.g., background) or pass a guaranteed-non-nil context here.
	telemetry := ctx.telemetry()
	messageType := NewTypeID(reflect.TypeOf(message))
	spanCtx, span := telemetry.StartExecutorProcess(
		ctx,
		e.ID,
		observability.TypeName(e.ExecutorType),
		messageType.TypeName,
		message,
		ctx.traceContextStrings(),
	)
  • Files reviewed: 10/10 changed files
  • Comments generated: 5

Comment thread workflow/workflow.go
Comment thread agent/hosting/workflowhosting/builders.go Outdated
Comment on lines +16 to +21
const (
aggregateTurnMessagesStateKey = "AggregateTurnMessagesExecutor.State"
concurrentEndExecutorID = "ConcurrentEnd"
outputMessagesExecutorID = "OutputMessages"
outputMessagesStateKey = "OutputMessagesExecutor.State"
)
Comment thread agent/hosting/workflowhosting/builders.go
Comment thread message/messageworkflow/messageforwarding.go Outdated
@qmuntal
qmuntal enabled auto-merge (squash) May 20, 2026 08:14
@github-actions

Copy link
Copy Markdown
Contributor

Cross-repo parity review ✅

This PR is a faithful port of .NET's AgentWorkflowBuilder.BuildSequential and BuildConcurrent to Go.

Verified alignment with .NET upstream:

  • BuildSequential: chains agents with ForwardIncomingMessages = true and ReassignOtherAgentsAsUsers = true (matching AIAgentHostOptions defaults), terminates with an OutputMessagesExecutor — identical semantics to .NET.
  • BuildConcurrent: fan-out via a forwarding executor, per-agent AggregateTurnMessages batchers, fan-in barrier, then a ConcurrentEndExecutor — identical graph topology to .NET.
  • Default aggregator (last message per non-empty batch) matches the .NET fallback.
  • The split into BuildConcurrentWithAggregator is an idiomatic Go adaptation of .NET's optional aggregator parameter (Go has no default args).
  • The context.Context added to MessageAggregator is an idiomatic Go enhancement with no semantic regression.

Python: No equivalent build_sequential/build_concurrent helpers exist in the Python package yet; this is an explicit .NET → Go port, so no Python parity gap is introduced by this PR.

No cross-repo consistency issues found.

Generated by Go API Consistency Review Agent for issue #196 · ● 12.9M ·

@qmuntal
qmuntal merged commit c82bd62 into main May 20, 2026
16 checks passed
@qmuntal
qmuntal deleted the dotnet-port/agent-workflow-builders-74d08e603868111d branch May 20, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port] Add BuildSequential and BuildConcurrent agent workflow builder helpers

3 participants