mason: prune dangling tool calls when replaying OpenAI session history - #551
Open
elainewang-db wants to merge 1 commit into
Open
mason: prune dangling tool calls when replaying OpenAI session history#551elainewang-db wants to merge 1 commit into
elainewang-db wants to merge 1 commit into
Conversation
When a run interrupts for human approval, the Agents SDK persists the `function_call` item immediately but writes its matching `function_call_output` only on resume. If that resume never lands cleanly — the user declines, or the paused in-process RunState is lost to a restart or another replica so the next prompt starts a fresh turn — the transcript keeps a `function_call` with no output. Replaying it makes the Responses API reject the whole request with BAD_REQUEST for the dangling `call_id`. Wrap every session (durable and in-memory) so `get_items` drops unpaired tool calls/outputs on replay; writes and rollback pass through unchanged. (A plain tool exception does NOT trigger this — the SDK stores an error output as a matched pair; verified via an end-to-end HITL-interrupt test.) Co-authored-by: Isaac <no-reply@databricks.com>
elainemwang
force-pushed
the
fix-dangling-tool-call
branch
from
September 4, 2026 22:57
2cbbf26 to
38b95f5
Compare
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.
A run that dies during or right after a tool call persists the
function_callitem without its matchingfunction_call_output, so the next turn replays a danglingcall_idand the Responses API rejects the whole request with BAD_REQUEST. Wrap every session (durable and in-memory) soget_itemsdrops unpaired tool calls/outputs on replay; writes and rollback pass through unchanged.