-
Notifications
You must be signed in to change notification settings - Fork 601
.NET: Add support for background responses #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: Add support for background responses #1501
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds background (long‑running) response support with continuation tokens across agent and chat client layers.
- Introduces AllowBackgroundResponses and ContinuationToken plumbing in AgentRunOptions, AgentRunResponse, AgentRunResponseUpdate, and ChatClientAgent merge logic.
- Adds comprehensive unit tests plus a new sample (Step17) and ADR documenting long‑running operations.
- Extends serialization to include ContinuationToken and updates solution / docs.
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| ChatClientAgentTests.cs | Adds tests validating propagation and precedence of background response options and continuation tokens. |
| AgentRunResponseUpdateTests.cs | Adds tests for new ContinuationToken property and JSON round‑trip. |
| AgentRunResponseTests.cs | Adds ContinuationToken handling tests and serialization updates. |
| AgentRunOptionsTests.cs | Tests cloning and JSON serialization including new properties. |
| ChatClientAgent.cs | Merges chat options now applying background response properties, introduces helper. |
| AgentRunResponseUpdate.cs | Adds ContinuationToken property with documentation remark. |
| AgentRunResponseExtensions.cs | Propagates ContinuationToken when converting chat responses to agent responses. |
| AgentRunResponse.cs | Adds ContinuationToken property and remarks. |
| AgentRunOptions.cs | Adds AllowBackgroundResponses and ContinuationToken with extensive remarks. |
| Agents README / Sample Step17 | New sample demonstrating polling and streaming resumption using continuation tokens. |
| Solution (.slnx) | Registers new sample and ADR document. |
| ADR 0009 | Design record for long‑running operations (background responses). |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponseUpdate.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponseUpdate.cs
Outdated
Show resolved
Hide resolved
…date.cs Co-authored-by: Copilot <[email protected]>
dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunResponse.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: westey <[email protected]>
Co-authored-by: westey <[email protected]>
Co-authored-by: westey <[email protected]>
dotnet/samples/GettingStarted/Agents/Agent_Step17_BackgroundResponses/Program.cs
Outdated
Show resolved
Hide resolved
…sponses/Program.cs Co-authored-by: westey <[email protected]>
This PR updates AF model to use model for background responses (long-running operations) from MEAI and updates
ChatClientAgentto support it.Background responses use a continuation token returned by the
RunAsyncandRunStreamingAsyncmethods in theAgentRunResponseandAgentRunResponseUpdateclasses, respectively, when background responses are enabled and supported by the AI agent.The continuation token contains all necessary details to enable polling for a background response using the non-streaming
RunAsyncmethod. It also allows resuming a streamed background response with theRunStreamingAsyncmethod if the stream is interrupted. In both cases, the continuation token obtained from the initial agent response or the streamed update received before the interruption should be supplied as input for follow-up calls.When a background response has completed, failed, or cannot proceed further (for example, when user input is required), the continuation token returned by either method will be null, signaling to consumers that processing is complete and there is nothing to poll or resume. The result returned by either method can then be used for further processing.
Non-streaming API:
Streaming API: