WEB-4877: forward tool_use_id from claude/codex/cursor hooks (pre + post)#178
Merged
Conversation
…ost) Send the per-invocation tool_use_id in pre-tool-use (pre_tool_use_data) and the post-tool-use completion exchange so the backend can store it in PromptAnalytics.parameters for future pretool<->completion dedup. Store-only. Additive and guarded (omitted when absent) so old hooks are byte-identical. - claude: tool_use_id from PreToolUse + PostToolUse events - codex: tool_use_id (PreToolUse) + call_id (transcript) on completion - cursor: tool_use_id from preToolUse + postToolUse - copilot: unchanged (no native id; backend supports it generically for later) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MohamedAklamaash
approved these changes
Jun 23, 2026
Collaborator
|
✅ Security consensus: no issues found. (reviewers: Cursor, Semgrep, Gitleaks; Claude unavailable) 🤖 consensus review · reviewers: Cursor,Claude,Semgrep,Gitleaks · head |
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
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.
What
Send the per-invocation
tool_use_idin both pre-tool-use (pre_tool_use_data) and the post-tool-use completion exchange, so the backend can store it inPromptAnalytics.parametersfor future pretool↔completion dedup. Store-only — no dedup logic here.tool_use_id(PreToolUse event)tool_use_id(PostToolUse event)tool_use_id(PreToolUse event)call_id(transcript)tool_use_id(preToolUse)tool_use_id(postToolUse)Safety
if _tuid:/ omitted when absent) → oldunbound.pybyte-identical, no new field assumed anywhere.cursorshell/MCP paths (beforeShellExecution/beforeMCPExecution) correctly left alone (those events carry notool_use_id).tool_use_idgenerically, so copilot'sunbound.pyis the only future change.Part of WEB-4877. Pairs with ai-gateway + ai-gateway-data PRs (both →
staging).🤖 Generated with Claude Code
Note
Low Risk
Additive, guarded optional fields with no change to policy or fail-open behavior; Copilot and Cursor shell/MCP pretool paths are intentionally unchanged.
Overview
WEB-4877 threads a per-invocation
tool_use_idthrough Claude Code, Codex, and Cursor hooks so the gateway can persist it for later pretool↔completion correlation (store-only in this PR).On pre-tool policy checks, each hook now adds
pre_tool_use_data.tool_use_idwhen the incoming event includes an id (if _tuid:). Cursor only does this onpreToolUse; shell/MCP pretool paths are unchanged because those events lack a native id.On end-of-turn exchanges, post-tool entries in the assistant
tool_uselist now carrytool_use_id: from PostToolUse /postToolUseevents for Claude and Cursor, and from Codex transcriptcall_idfor function-call pairs. Copilot is untouched (no native per-tool id).Reviewed by Cursor Bugbot for commit e84a6b6. Bugbot is set up for automated code reviews on this repo. Configure here.