Skip to content

.NET: Sample fix#6773

Merged
alliscode merged 4 commits into
microsoft:mainfrom
alliscode:sample-fix
Jun 26, 2026
Merged

.NET: Sample fix#6773
alliscode merged 4 commits into
microsoft:mainfrom
alliscode:sample-fix

Conversation

@alliscode

Copy link
Copy Markdown
Member

This pull request introduces a mix of improvements across sample code, agent instructions, workflow event handling, and workflow execution robustness. The changes enhance clarity in agent and workflow behavior, improve testability and reliability (especially around user input and stdin handling), and add minor but important refinements to sample logic and documentation.

Agent and Sample Improvements:

  • Updated required environment variables and sample input/output expectations for agent and workflow samples to better reflect actual usage and clarify configuration. [1] [2] [3]
  • Improved agent instructions and tool usage in several samples to ensure correct and more descriptive behavior, such as requiring explicit tool use for price lookup and providing more detailed QA/DevOps responses. [1] [2] [3]
  • Refined sample prompts and outputs for clarity and brevity, e.g., changing a "very long novel" prompt to a "short story" in astronaut sample.

Workflow and Event Handling Enhancements:

  • Added a custom ClassificationEvent type and logic to emit classification results in workflow outputs, improving observability and debugging for classification steps. [1] [2] [3]

Robustness and Testability:

  • Improved stdin handling in workflow runners and application input, ensuring workflows exit gracefully when stdin closes (e.g., during automated testing), and preventing hangs or crashes. [1] [2] [3] [4] [5]

Agent Construction and Memory Extraction:

  • Refactored the memory extraction logic in the "get started" sample to use a dedicated IChatClient for structured extraction, ensuring agent conversation history is not polluted by extraction calls and avoiding initialization issues. [1] [2]

OpenAPI Tooling:

  • Enhanced the OpenAPI tool definition in the agent sample to support a new fields query parameter, and updated agent instructions to always use this parameter for more focused API responses. [1] [2]

Copilot AI review requested due to automatic review settings June 26, 2026 16:44
@moonbox3 moonbox3 added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Jun 26, 2026
@github-actions github-actions Bot changed the title Sample fix .NET: Sample fix Jun 26, 2026

@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.

Automated Code Review

Reviewers: 5 | Confidence: 91% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by alliscode's agents

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 updates several .NET samples and shared workflow helpers to improve sample correctness and robustness, especially around interactive input and observability of workflow decisions.

Changes:

  • Improve EOF/stdin-closed handling in shared workflow sample utilities to avoid hangs during automated sample verification.
  • Enhance workflow sample output/debuggability by emitting a dedicated ClassificationEvent and printing it in the multi-selection workflow sample.
  • Refactor and clarify several agent/workflow samples (memory extraction client separation, OpenAPI tool parameter support, sample verification inputs/env vars, and prompt/instruction refinements).
Show a summary per file
File Description
dotnet/src/Shared/Workflows/Settings/Application.cs Return gracefully when initial console input hits EOF.
dotnet/src/Shared/Workflows/Execution/WorkflowRunner.cs Track stdin EOF during interactive workflow runs and break the loop cleanly.
dotnet/samples/03-workflows/ConditionalEdges/03_MultiSelection/Program.cs Add a custom ClassificationEvent and emit/print classification decisions.
dotnet/samples/03-workflows/Agents/GroupChatToolApproval/Program.cs Refine QA/DevOps agent instructions for clearer output expectations.
dotnet/samples/02-agents/Agents/Agent_Step18_CompactionPipeline/Program.cs Require tool usage for price lookups in the sample instructions.
dotnet/samples/02-agents/Agents/Agent_Step14_BackgroundResponses/Program.cs Only persist resumable updates that include a continuation token.
dotnet/samples/02-agents/Agents/Agent_Step10_BackgroundResponsesWithToolsAndPersistence/Program.cs Shorten the initial story prompt to be more practical for a sample.
dotnet/samples/02-agents/AgentProviders/foundry/Agent_Step17_OpenAPITools/Program.cs Add fields query parameter support and instruct the agent to use it.
dotnet/samples/01-get-started/04_memory/Program.cs Use a dedicated IChatClient for structured memory extraction and set model ID from metadata.
dotnet/eng/verify-samples/WorkflowSamples.cs Update sample inputs/delays to better match interactive workflow behavior.
dotnet/eng/verify-samples/AgentsSamples.cs Update required env vars for the Foundry computer-use sample.

Review details

  • Files reviewed: 11/11 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread dotnet/src/Shared/Workflows/Execution/WorkflowRunner.cs
Comment thread dotnet/samples/01-get-started/04_memory/Program.cs Outdated
…lId, format

- WorkflowRunner: reset _stdinEof=false at start of ExecuteAsync so reused
  instances don't exit immediately on the next external request
- 04_memory: throw clear InvalidOperationException when DefaultModelId is null
  rather than silently sending null to the Foundry Responses API
- dotnet format: no code changes, formatting only

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread dotnet/samples/01-get-started/04_memory/Program.cs Outdated
@alliscode alliscode added this pull request to the merge queue Jun 26, 2026
Merged via the queue into microsoft:main with commit 7749823 Jun 26, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants