Repository navigation
.Net: Keep completed tool turns out of streamed agent history - #14801
Open
Jiayi Yang (ridlog) wants to merge 1 commit into
Open
Jiayi Yang (ridlog) wants to merge 1 commit into
Jiayi Yang (ridlog) wants to merge 1 commit into
Conversation
The streaming agent copies completed assistant and tool messages from the chat service into its thread, but it also kept their text in the buffer used for the final message. Reset that buffer at each completed turn before appending the next update, so the next turn keeps its first token. Constraint: Preserve streamed updates and intermediate message callbacks Confidence: high Scope-risk: narrow Tested: Baseline regression 2 failed/2 passed; fixed Agent project 508 passed/1 skipped; dotnet format verification Not-tested: Credentialed live provider integration tests and the full repository platform matrix Related: microsoft#12485
Jiayi Yang (ridlog)
deployed
to
github-app-auth
November 16, 2026 15:17 — with
GitHub Actions
Active
Author
|
@microsoft-github-policy-service agree |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #12485.
After a tool call,
ChatCompletionAgent.InvokeStreamingAsynccopies the completed assistant and tool messages into the thread. It also retains the completed turn's text in its final-message buffer. A turn that streamsPlanning 0., calls a tool, then streamsFinal answer.therefore storesPlanning 0.Final answer.as the final assistant message.Description
Clear the buffer when the chat service supplies completed tool-turn messages. Append the current update after that step so the final turn keeps its first token. The streamed updates and
OnIntermediateMessagecallbacks remain intact.The regression uses the real agent and thread with a mocked external chat service. It covers zero, one, and two tool turns, plus tool termination. On unchanged base
ff22ec32, two cases fail and two pass. With this fix, the full Agent unit-test project passes: 508 passed, 1 existing test skipped. The changed files also passdotnet format --verify-no-changes.Commands:
Checked with .NET SDK 10.0.303 on Windows. Credentialed live-provider integration tests and the repository platform matrix were not run locally.
This contribution was generated and reviewed with OpenAI Codex at the account owner's request. It comes from a search for reproducible Agent issues. No separate human review is claimed.
Contribution Checklist