Skip to content

Align examples with .NET samples - #430

Merged
Quim Muntal (qmuntal) merged 4 commits into
mainfrom
align-examples-with-dotnet
Jul 6, 2026
Merged

Quim Muntal (qmuntal) merged 4 commits into
mainfrom
align-examples-with-dotnet

Conversation

@qmuntal

Copy link
Copy Markdown
Member

Summary

  • Update several Go examples so their scenarios and flow better align with the corresponding .NET examples.
  • Refresh the memory, image input, Foundry MCP tools, group chat tool approval, conditional multi-selection, and human-in-the-loop workflow examples.
  • Add the image asset used by the updated image input example.

Validation

  • go test -count=1 ./examples/01-get-started/04_memory ./examples/02-agents/agents/step11_using_images ./examples/02-agents/providers/foundry/step09_mcp_client_as_tools ./examples/03-workflows/agents/group_chat_tool_approval ./examples/03-workflows/conditional-edges/03_multi_selection ./examples/03-workflows/human-in-the-loop/human_in_the_loop_basic

Copilot AI review requested due to automatic review settings July 6, 2026 14:33
@qmuntal
Quim Muntal (qmuntal) requested a review from a team as a code owner July 6, 2026 14:33

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 refreshes several Go examples so their scenarios and flow align more closely with corresponding .NET samples, including updates to memory usage, image inputs, MCP tooling instructions, and workflow-based examples.

Changes:

  • Updates the memory example to persist richer user state (name + age) and demonstrate session serialization/deserialization.
  • Refactors multiple workflow examples (human-in-the-loop guessing game, conditional multi-selection routing, group chat tool approval) to match updated scenarios and outputs.
  • Updates the image example to embed a local image asset and send it as in-memory base64 data instead of a remote URI.
Show a summary per file
File Description
examples/03-workflows/human-in-the-loop/human_in_the_loop_basic/main.go Replaces the approval pause flow with a request-port-driven number guessing game.
examples/03-workflows/conditional-edges/03_multi_selection/main.go Extends analysis routing to compute and propagate an email summary through the workflow.
examples/03-workflows/agents/group_chat_tool_approval/main.go Improves agent metadata, termination logic, and console output formatting for the group chat workflow.
examples/02-agents/providers/foundry/step09_mcp_client_as_tools/main.go Updates agent instructions to encourage explicit use of the Microsoft Learn MCP tool.
examples/02-agents/agents/step11_using_images/main.go Switches the image input from remote URI to embedded base64 data content.
examples/01-get-started/04_memory/main.go Expands the memory provider to store/restore user name + age and demonstrates session persistence.

Review details

Tip

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

  • Files reviewed: 6/7 changed files
  • Comments generated: 4
  • Review effort level: Low

Comment thread examples/01-get-started/04_memory/main.go Outdated
Comment thread examples/03-workflows/agents/group_chat_tool_approval/main.go
Comment thread examples/03-workflows/agents/group_chat_tool_approval/main.go Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@qmuntal

Copy link
Copy Markdown
Member Author

Copilot fix ci

Co-authored-by: qmuntal <3747816+qmuntal@users.noreply.github.com>

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Copilot fix ci

Addressed in 73edcee.

Local validation now passes:

  • go test ./...
  • golangci-lint run --verbose ./cmd/verifyexamples/...

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Cross-repo parity review — aligns well with .NET

This PR explicitly targets alignment with microsoft/agent-framework (dotnet) and largely succeeds. I reviewed all changed example files and the new cmd/verifyexamples tool against their .NET counterparts.

✅ Changes that are well-aligned

human_in_the_loop_basic — The rewrite exactly mirrors dotnet/samples/03-workflows/HumanInTheLoop/HumanInTheLoopBasic: same NumberSignal enum (Init/Above/Below), same GuessNumber request port ID, same Judge executor name with target 42, same prompt strings for each signal, and same event-handling structure. The Go version appropriately uses ctx.ReadOrInitState/ctx.QueueStateUpdate for tries state (Go's durable-state pattern) rather than .NET's instance field — that's a framework-level idiom difference, not a divergence.

group_chat_tool_approval — Agent descriptions ("QA engineer who runs tests", "DevOps engineer who handles deployments"), instruction strings, completion messages, and separator lines now match dotnet/.../GroupChatToolApproval/Program.cs verbatim. The manual selectedTurns counter is the Go-idiomatic replacement for .NET's built-in this.IterationCount on GroupChatManager. Adding an explicit Reset callback to zero selectedTurns is correct: Go struct-based managers don't inherit base-class state reset.

step11_using_images — Switching from message.URIContent (external Wikipedia URL) to message.DataContent with a locally embedded walkway.jpg matches the .NET sample (DataContent.LoadFromAsync("Assets/walkway.jpg")). Both approaches send inline base64 image data to the model — semantically identical.

03_multi_selection — EmailSummaryExecutor now returns AnalysisResult (populating EmailSummary) and DatabaseAccessExecutor now receives AnalysisResult, matching the .NET types Executor<AnalysisResult, AnalysisResult> and Executor<AnalysisResult> respectively. The edge ordering fix (AddEdge(summary, log) moved after the conditional direct edge) also matches .NET's builder call sequence.

cmd/verifyexamples — This is a faithful Go port of dotnet/eng/verify-samples/. The ExampleDefinition struct mirrors SampleDefinition field-for-field (Name, ProjectPath, RequiredEnvironmentVariables, OptionalEnvironmentVariables, SkipReason, MustContain, MustNotContain, IsDeterministic, ExpectedOutputDescription, Inputs). InputDelay time.Duration corresponds to InputDelayMs int — same concept, idiomatic Go type. The module split (orchestrator, runner, verifier, reporter, writers) mirrors the .NET class split.

i️ Minor observation (no action required)

04_memory extraction mechanism — The .NET sample creates a dedicated IChatClient and calls GetResponseAsync<UserInfo>(...) with a JSON schema to AI-extract the user's name and age from messages. The Go sample uses simple string-matching helpers (extractName, extractAge). The high-level pattern demonstrated — custom ContextProvider, StoreAIContext/ProvideAIContext callbacks, session serialization, deserialization, and cross-session memory transfer — is fully aligned. The simpler extraction is an intentional Go sample choice (avoids a second AI call for illustration purposes) and does not affect any public framework API. The section headers and MEMORY - User Name: / MEMORY - User Age: output format are identical to .NET.


No cross-repo consistency issues found. The PR preserves semantic parity with the .NET implementations for all changed examples and adds a Go-equivalent of the .NET verify-samples tooling.

Generated by Go API Consistency Review Agent for #430 · 476.5 AIC · ⌖ 13.1 AIC · ⊞ 27.1K · ◷

@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Jul 6, 2026
Merged via the queue into main with commit b10fbe3 Jul 6, 2026
19 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the align-examples-with-dotnet branch July 6, 2026 16:25
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.

4 participants