Skip to content

WEB-4877: forward tool_use_id from claude/codex/cursor hooks (pre + post)#178

Merged
pugazhendhi-m merged 1 commit into
mainfrom
WEB-4877
Jun 23, 2026
Merged

WEB-4877: forward tool_use_id from claude/codex/cursor hooks (pre + post)#178
pugazhendhi-m merged 1 commit into
mainfrom
WEB-4877

Conversation

@pugazhendhi-m

@pugazhendhi-m pugazhendhi-m commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Send the per-invocation tool_use_id in both 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 — no dedup logic here.

Tool PRE POST
claude tool_use_id (PreToolUse event) tool_use_id (PostToolUse event)
codex tool_use_id (PreToolUse event) call_id (transcript)
cursor tool_use_id (preToolUse) tool_use_id (postToolUse)
copilot — (no native id) — (no native id)

Safety

  • Additive + guarded (if _tuid: / omitted when absent) → old unbound.py byte-identical, no new field assumed anywhere.
  • Fail-open untouched. cursor shell/MCP paths (beforeShellExecution/beforeMCPExecution) correctly left alone (those events carry no tool_use_id).
  • copilot unchanged on purpose: it has no native per-tool id; the backend handles tool_use_id generically, so copilot's unbound.py is 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_id through 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_id when the incoming event includes an id (if _tuid:). Cursor only does this on preToolUse; 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_use list now carry tool_use_id: from PostToolUse / postToolUse events for Claude and Cursor, and from Codex transcript call_id for 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.

…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>
@pugazhendhi-m pugazhendhi-m requested a review from a team June 23, 2026 14:14
@vigneshsubbiah16

Copy link
Copy Markdown
Collaborator

✅ Security consensus: no issues found. (reviewers: Cursor, Semgrep, Gitleaks; Claude unavailable)


🤖 consensus review · reviewers: Cursor,Claude,Semgrep,Gitleaks · head e84a6b6d · 2026-06-23T14:28Z

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown

Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance.

@pugazhendhi-m pugazhendhi-m merged commit 072724a into main Jun 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants