fix(agents): clear pending tool call state on interruption regardless of provider#32120
Merged
steipete merged 2 commits intoopenclaw:mainfrom Mar 2, 2026
Merged
Conversation
Contributor
Greptile SummaryRemoves unnecessary guard around pending tool call cleanup logic, fixing session-breaking bug for OpenAI/OpenRouter providers. The fix correctly addresses the root cause: Key insight from
Behavior after fix:
The added comment clearly documents the rationale for future maintainers. Confidence Score: 5/5
Last reviewed commit: 17cfb91 |
… of provider When `allowSyntheticToolResults` is false (OpenAI, OpenRouter, and most third-party providers), the guard never cleared its pending tool call map when a user message arrived during in-flight tool execution. This left orphaned tool_use blocks in the transcript with no matching tool_result, causing the provider API to reject all subsequent requests with 400 errors and permanently breaking the session. The fix removes the `allowSyntheticToolResults` gate around the flush calls. `flushPendingToolResults()` already handles both cases correctly: it only inserts synthetic results when allowed, and always clears the pending map. The gate was preventing the map from being cleared at all for providers that disable synthetic results. Fixes openclaw#32098 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17cfb91 to
2372b57
Compare
Contributor
|
Landed via temp rebase onto main.
Thanks @jnMetaCode! |
dawi369
pushed a commit
to dawi369/davis
that referenced
this pull request
Mar 3, 2026
OWALabuy
pushed a commit
to kcinzgg/openclaw
that referenced
this pull request
Mar 4, 2026
zooqueen
pushed a commit
to hanzoai/bot
that referenced
this pull request
Mar 6, 2026
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 #32098 — orphaned
tool_useblock when user message interrupts in-flight tool call permanently breaks the session.Root cause: In
session-tool-result-guard.ts, the flush logic that clears pending tool call state was gated behindif (allowSyntheticToolResults). For providers where this isfalse(OpenAI, OpenRouter, and most third-party providers), the pending map was never cleared when a user message arrived during in-flight tool execution. This left orphanedtool_useblocks in the transcript with no matchingtool_result, causing the provider API to reject all subsequent requests.Fix: Remove the
allowSyntheticToolResultsguard around the flush calls.flushPendingToolResults()already handles both cases correctly internally — it only inserts synthetic results whenallowSyntheticToolResultsistrue, and always callspending.clear(). The outer guard was simply preventing the cleanup from ever running for affected providers.Two call sites fixed:
Test plan
oxfmt --checkpasses🤖 Generated with Claude Code