← Back to PRs

#8270: fix: support snake_case 'tool_use' in transcript repair (#8264)

by heliosarchitect open 2026-02-03 20:43 View on GitHub →
app: web-ui gateway commands agents stale
Fixes #8264 ## Problem The session transcript repair mechanism checks for tool call blocks with type `toolUse` (camelCase) but Anthropic uses `tool_use` (snake_case). This caused the repair to miss valid tool_use blocks when extracting tool calls from assistant messages. When a tool result was missing and the repair mechanism inserted a synthetic error, it would reference a tool_use_id that appeared missing to Anthropic (because we didn't extract it properly), leading to permanent session corruption. ## Solution Now checks for both format variants: - `toolUse` (camelCase, used by some providers) - `tool_use` (snake_case, Anthropic's format) ← **NEW** - `toolCall` (alternative format) - `functionCall` (OpenAI format) This ensures the repair mechanism correctly identifies all tool call blocks regardless of which provider format is used, preventing the "unexpected tool_use_id" errors that permanently broke sessions. ## Testing - Verified code change matches Anthropic's documented format - Checked that both camelCase and snake_case variants are now supported - Minimal change with no risk of breaking existing functionality Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes transcript repair compatibility with Anthropic by treating assistant tool call blocks with `type: "tool_use"` the same as existing `toolUse`/`toolCall`/`functionCall` variants during tool call extraction, preventing spurious synthetic “missing tool result” insertions. In addition, it includes a set of extensions (cortex, conversation-summarizer, self-reflection) and several related core changes: - `message` tool and outbound send path now propagate the requester `sessionKey` and add a guard to avoid corrupting the original session’s delivery context when outbound routing resolves back to the requester session. - Agent invocation paths accept a per-run `model` override to avoid session patch race conditions. - Image tool resolves `maxTokens` from configured extra params instead of a hardcoded 512. Overall, the key functional fix is small and targeted (support snake_case `tool_use`), while the rest of the PR introduces new plugins and some session/model-routing safeguards. <h3>Confidence Score: 3/5</h3> - This PR is likely safe to merge, but it includes broad additional changes beyond the stated transcript-repair fix that deserve extra scrutiny. - The transcript repair change itself is straightforward and low risk. However, the PR also adds multiple new extensions and modifies outbound session handling and agent model override behavior; these are higher surface-area changes where small edge cases (e.g., assumptions about required fields) could cause runtime issues. - src/agents/session-transcript-repair.ts, src/infra/outbound/outbound-session.ts, src/commands/agent.ts, and the new extensions under extensions/ <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs