Skip to content

Conversation

@SergeyMenshykh
Copy link
Member

Context:

Description:
This PR adds the ChatClientAgentContinuationToken token type for ChatClientAgent. This token type retains the agent's input messages provided during the initial call of the RunStreamingAsync method, as well as the streamed updates received through all subsequent stream-resumption calls of the method. ChatClientAgent wraps all continuation tokens received from the chat client into the new token type, and it adds both input messages and streamed updates to the token before returning it as part of the response update to the caller. Upon receiving the token back from the caller via run options, the agent retrieves the input messages and updates from the token and provides them to the configured message store and AI context provider.

…e able to use them in the last successful stream resumption call.
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

This PR introduces the ChatClientAgentContinuationToken type to prevent loss of input messages and streamed updates when resuming streaming operations in ChatClientAgent. The new token wraps the underlying chat client's continuation token and stores input messages from the initial call and all streamed updates received during stream-resumption calls.

Key Changes

  • New ChatClientAgentContinuationToken class that extends ResponseContinuationToken to preserve input messages and response updates across streaming resumptions
  • Updated ChatClientAgent to wrap continuation tokens and restore input messages/updates when resuming streams
  • Refactored validation logic to distinguish between streaming resumption and polling scenarios

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
ChatClientAgentContinuationToken.cs Implements new continuation token type with serialization support for input messages and response updates
ChatClientAgent.cs Updates streaming logic to wrap/unwrap continuation tokens and restore messages/updates when resuming
ChatClientAgentStructuredOutput.cs Wraps continuation tokens in structured output responses
AgentRunResponse.cs Removes automatic propagation of continuation tokens from ChatResponse constructor
AgentRunResponseUpdate.cs Removes automatic propagation of continuation tokens from ChatResponseUpdate constructor
ChatClientAgent_BackgroundResponsesTests.cs Updates tests to use new token type and adds comprehensive tests for streaming resumption scenarios
ChatClientAgentContinuationTokenTests.cs New test file with serialization and roundtrip tests for the new token type
AgentRunResponseUpdateTests.cs Removes test assertions for automatic continuation token propagation
AgentRunResponseTests.cs Removes test assertions for automatic continuation token propagation
AgentJsonUtilities.cs Adds JSON serialization support for ChatMessage and ChatResponseUpdate collections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

1 participant