fix(session): drop tool calls from aborted turns#7546
Closed
hclsys wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(session): drop tool calls from aborted turns#7546hclsys wants to merge 1 commit intoopenclaw:mainfrom
hclsys wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Comment on lines
+8
to
+14
| function isToolCallBlock(block: unknown): boolean { | ||
| if (!block || typeof block !== "object") { | ||
| return false; | ||
| } | ||
| const rec = block as { type?: unknown }; | ||
| return rec.type === "toolCall" || rec.type === "toolUse" || rec.type === "functionCall"; | ||
| } |
Contributor
There was a problem hiding this comment.
[P2] Duplicate tool-call-type logic increases drift risk
isToolCallBlock duplicates the exact set of block types checked in extractAssistantToolCalls (toolCall/toolUse/functionCall). If this list ever changes, it’s easy to update one and forget the other, reintroducing the aborted-turn bug or missing a new tool-call variant. Consider defining a single helper (e.g., isToolCallBlock) and using it in both places, or centralizing the allowed type set.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/session-tool-result-guard.ts
Line: 8:14
Comment:
[P2] Duplicate tool-call-type logic increases drift risk
`isToolCallBlock` duplicates the exact set of block types checked in `extractAssistantToolCalls` (`toolCall`/`toolUse`/`functionCall`). If this list ever changes, it’s easy to update one and forget the other, reintroducing the aborted-turn bug or missing a new tool-call variant. Consider defining a single helper (e.g., `isToolCallBlock`) and using it in both places, or centralizing the allowed `type` set.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
This was referenced Feb 8, 2026
Member
|
Closing as duplicate of #3223. If this is incorrect, comment and we can reopen. |
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.
Fixes #6157\n\n- strip toolCall/toolUse blocks from aborted assistant messages before persisting\n- avoid inserting synthetic tool_result for aborted tool calls\n- add regression test for aborted turns\n\n## Test plan\n- pnpm vitest src/agents/session-tool-result-guard.test.ts\n- pnpm format\n
Greptile Overview
Greptile Summary
This PR updates
installSessionToolResultGuardto treat aborted assistant turns specially: tool call/tool use blocks are stripped from aborted assistant messages before persisting, and any pending tool results for those aborted calls are not synthesized. A regression test was added to ensure an aborted assistant message containing a tool call is persisted without tool-call blocks and does not leave pending tool-call IDs behind.Overall, the change fits into the session transcript consistency layer: the guard tracks pending tool calls and synthesizes missing tool results when needed for strict providers, while also ensuring the transcript stays well-formed. The new behavior prevents “orphaned” synthetic tool results caused by persisting tool calls from turns that never actually executed.
Confidence Score: 4/5
Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)