Skip to content

Conversation

@SergeyMenshykh
Copy link
Member

Motivation and Context

The reliability of the StructuredOutputAgent in producing structured output through an additional LLM call may not be sufficient for all scenarios. As a result, it's not going to be included in the public AF API surface. However, it would be beneficial to provide a sample to demonstrate how structured output can be achieved for agents without native support. This would give users a reference implementation they can adapt to their own requirements.

Description

The StructuredOutputAgent class and related classes have been moved to the samples.

Copilot AI review requested due to automatic review settings February 10, 2026 19:45
@SergeyMenshykh SergeyMenshykh changed the title .NET: Move so agent to samples .NET: Move SO agent to samples Feb 10, 2026
@SergeyMenshykh SergeyMenshykh self-assigned this Feb 10, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Progress in Agent Framework Feb 10, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Moves the non-public StructuredOutputAgent implementation out of the .NET library/test surface and into a Getting Started sample, aligning with the decision to not include it in the public Agent Framework API while still providing a reference implementation.

Changes:

  • Removed unit tests that covered StructuredOutputAgent, StructuredOutputAgentResponse, and related builder extensions from Microsoft.Agents.AI.UnitTests.
  • Updated the Step05 Structured Output sample to host the structured-output wrapper types under the sample namespace (SampleApp) and remove dependencies on shared diagnostics helpers.
  • Adjusted sample types’ accessibility to keep the implementation sample-scoped (e.g., internal classes).

Reviewed changes

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

Show a summary per file
File Description
dotnet/tests/Microsoft.Agents.AI.UnitTests/StructuredOutput/StructuredOutputAgentTests.cs Removed tests for StructuredOutputAgent after moving implementation to samples.
dotnet/tests/Microsoft.Agents.AI.UnitTests/StructuredOutput/StructuredOutputAgentResponseTests.cs Removed tests for StructuredOutputAgentResponse after moving implementation to samples.
dotnet/tests/Microsoft.Agents.AI.UnitTests/StructuredOutput/AIAgentBuilderExtensionsTests.cs Removed tests for builder extensions after moving implementation to samples.
dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/StructuredOutputAgentResponse.cs Scoped the response wrapper to the sample namespace and adjusted accessibility.
dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/StructuredOutputAgentOptions.cs Scoped options to the sample namespace and adjusted analyzers/accessibility.
dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/StructuredOutputAgent.cs Scoped the agent wrapper to the sample namespace and replaced diagnostics null-check helper.
dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/AIAgentBuilderExtensions.cs Scoped extensions to the sample namespace and replaced diagnostics null-check helper.
Comments suppressed due to low confidence (2)

dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/StructuredOutputAgentResponse.cs:20

  • StructuredOutputAgentResponse is internal, but its constructor is public. Since the type can’t be constructed from outside the assembly anyway, making the constructor internal improves encapsulation and avoids suggesting this is intended as a public API surface.
    dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/AIAgentBuilderExtensions.cs:46
  • In UseStructuredOutput, the chatClient ??= assignment mutates the captured parameter inside the builder lambda. If the same AIAgentBuilder instance is built multiple times (potentially with different IServiceProviders), the first resolved IChatClient will be cached and reused on subsequent builds, which can be surprising and incorrect. Prefer resolving into a local variable without mutating the captured chatClient parameter (or always re-resolve from services when no explicit client was provided).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/AIAgentBuilderExtensions.cs:46

  • chatClient ??= inside the builder.Use(...) lambda mutates the captured chatClient parameter. If the same builder is built more than once (especially with different service providers), the first resolved IChatClient instance will be cached and reused for later builds, which can produce incorrect behavior. Resolve into a local variable inside the lambda (without writing back to the captured parameter) and pass that local to StructuredOutputAgent.

@SergeyMenshykh SergeyMenshykh merged commit 6dda25c into microsoft:feature-so Feb 11, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Agent Framework Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants