Stabilize ResponseContinuationToken / background-response APIs#7512
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR stabilizes the background-response continuation token surface area in Microsoft.Extensions.AI.Abstractions by removing the experimental gating and updating tests/metadata to reflect the now-stable API.
Changes:
- Removes
Experimentalannotations (and the associated diagnostic ID) fromResponseContinuationTokenand background-response related properties. - Promotes
ContinuationToken/AllowBackgroundResponsesproperties to be the directly-serialized public properties (removing the prior*Coreindirection pattern). - Updates stabilization and unit tests to validate JSON roundtripping using
AIJsonUtilities.DefaultOptions, and marks API stages asStablein the API metadata JSON.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.AI.Stabilization.Tests/Microsoft.Extensions.AI.Stabilization.Tests.csproj | Adds the continuation-token test to the stabilization test suite. |
| test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ResponseContinuationTokenTests.cs | Updates JSON roundtrip test to use AIJsonUtilities.DefaultOptions for serialization/deserialization. |
| src/Shared/DiagnosticIds/DiagnosticIds.cs | Removes the unused experiment ID entry for response continuations. |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/ResponsesClientContinuationToken.cs | Removes experimental annotation/imports in line with stabilization. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/ResponseContinuationToken.cs | Removes experimental annotation/imports to make the token type stable. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.json | Marks ResponseContinuationToken and related background-response members as Stable. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseUpdate.cs | Makes ContinuationToken the public JSON-included property (removes prior wrapper + core split). |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponse.cs | Same stabilization pattern for ChatResponse.ContinuationToken. |
| src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatOptions.cs | Same stabilization pattern for ChatOptions.AllowBackgroundResponses and ChatOptions.ContinuationToken. |
|
The canonical way to drive a background response is still: var chatOptions = new ChatOptions { AllowBackgroundResponses = true };
// Get initial response with continuation token
var response = await ChatClient.GetResponseAsync("What's the biggest animal?", chatOptions);
// Continue to poll until we get the final response
while (response.ContinuationToken is not null)
{
chatOptions.ContinuationToken = response.ContinuationToken;
response = await ChatClient.GetResponseAsync([], chatOptions);
await Task.Delay(1000);
}Anything other than public static Task<ChatResponse> ContinueResponseAsync(
this IChatClient client, ChatOptions options, CancellationToken cancellationToken = default);
public static IAsyncEnumerable<ChatResponseUpdate> ContinueStreamingResponseAsync(
this IChatClient client, ChatOptions options, CancellationToken cancellationToken = default);As of today, only OpenAI Responses honors continuation, so it's a small surface bloat for a single-provider feature. |
|
@SergeyMenshykh thanks, I agree with adding them at a later stage if necessary. |
…son attribute and augment tests.
Agent-Logs-Url: https://github.com/dotnet/extensions/sessions/9ce4ad36-d6d2-4c9a-8020-7ec92eae60f2 Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
Microsoft Reviewers: Open in CodeFlow