fix(agent): sanitize unanswered tool_calls on interrupt to prevent transcript corruption - #11354
Closed
nicoechaniz wants to merge 1 commit into
Closed
nicoechaniz wants to merge 1 commit into
nicoechaniz wants to merge 1 commit into
Conversation
nicoechaniz
force-pushed
the
fix/interrupt-history-sanitization
branch
2 times, most recently
from
April 20, 2026 05:28
91aea29 to
fd704ea
Compare
Contributor
Author
|
Hi @teknium1 — this fixes transcript corruption when interrupts leave unanswered tool_calls in flight. Rebased on latest main and ready for review. Thanks! |
nicoechaniz
force-pushed
the
fix/interrupt-history-sanitization
branch
from
April 22, 2026 02:24
fd704ea to
114522c
Compare
…anscript corruption Adds _sanitize_unanswered_tool_calls() to backfill synthetic role=tool results for any assistant tool_calls that weren't answered before an interrupt or error exits the loop. This prevents the next API call from failing with a missing tool response error. Also removes the duplicated inline logic from the outer-loop error handler and calls the helper from _persist_session() so every exit path guarantees an API-valid transcript.
nicoechaniz
force-pushed
the
fix/interrupt-history-sanitization
branch
from
April 22, 2026 07:21
114522c to
ed382e4
Compare
Collaborator
|
Thanks for the careful writeup and the rebase work, @nicoechaniz! This hermes-sweeper automated review found that current The bug is already fixed on main by two existing mechanisms:
The proposed |
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.
Summary
Fixes a bug where interrupting the agent during pending tool calls leaves the conversation transcript in an invalid state, causing the next API call to fail with a "missing tool response" error.
Closes #11351
Changes
_sanitize_unanswered_tool_calls()helper toAIAgentinrun_agent.py._persist_session()so every exit path guarantees an API-valid transcript.Testing
origin/mainBackwards compatibility
No behavior change for users — this only prevents a crash condition.