Repository navigation
fix(session): sanitize interrupted tool calls on transport error (#51117) - #52684
Closed
JerryLiu369 wants to merge 1 commit into
Closed
JerryLiu369 wants to merge 1 commit into
JerryLiu369 wants to merge 1 commit into
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
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.
Issue for this PR
Closes #51117
Type of change
What does this PR do?
When a tool call is interrupted mid-stream (e.g. by a provider transport decode error), the partial tool item in history was left un-settled without a paired tool result. On subsequent turns/drains, converting session messages to LLM request format either failed schema validation or produced dangling tool calls without corresponding tool results, permanently bricking the session.
publish-llm-event.ts:failAssistant, immediately publishSessionEvent.Tool.Failedfor any uncalled/unsettled tools so that incomplete tool calls interrupted mid-stream do not linger as pending and poison future session drains.to-llm-message.ts:toolResult, ensure that any incomplete tool calls (pending/running) that never reached durable settlement synthesize a paired error result (ToolResultPart.make) so every tool call is guaranteed to have a corresponding tool result.How did you verify your code works?
bun teston affected test suites:session-runner-message.test.tsandsession-runner.test.tsto reflect proper partial flush and paired tool results on failure.session-transport-poison.test.tsunit tests covering interrupted/transport-error tool sanitization across models.Screenshots / recordings
N/A (session transport and tool call settlement bugfix)
Checklist