You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Hooks: include the tool call id in preToolUse, postToolUse and postToolUseFailure input #5261
Describe the feature or problem you'd like to solve
Tool hook input has no tool call id, so a hook can't tell which preToolUse a postToolUse or postToolUseFailure belongs to.
Proposed solution
Add the call's id to the preToolUse, postToolUse and postToolUseFailure input (and permissionRequest, where there is one): toolCallId in the camelCase format and tool_use_id in the VS Code compatible format.
The hooks reference lists sessionId, timestamp, cwd, toolName, toolArgs (plus toolResult or error)
for these events, and nothing that names the call. VS Code's own agent hooks send tool_use_id on PreToolUse and
PostToolUse (VS Code docs, agents/reference/hooks-reference), and the CLI's PascalCase format is described as matching
the VS Code extension's format, so a hook written against VS Code that reads tool_use_id gets nothing from the CLI.
Claude Code's hooks carry the same field.
Without it, two calls of the same tool with the same arguments (the same file viewed twice, a retried command, calls
dispatched in parallel) can't be told apart, and a hook has to pair pre and post events by tool and arguments in
arrival order, which is wrong when they finish in another order.
Example prompts or workflows
An audit hook writes one record per call: the decision at preToolUse, the outcome at postToolUse or postToolUseFailure, joined by id.
A policy hook holds a call for a person's approval in another system, then attaches the result to that approval.
A telemetry hook measures each call's duration while calls run in parallel.
A hook links its record to the same call in the session's event log or an OpenTelemetry span.
Additional context
Context: I maintain Tracekit (https://github.com/Cygnux-Labs/Tracekit), which records and gates agent tool calls; this would let it gate Copilot CLI calls and pair each result with the call it decided by id.
+1. This is the missing join key between hooks and the native OTel export.
A common enterprise pattern is managed preToolUse/postToolUse hooks for policy and audit, with OTel for observability. Joining "hook decision → execute_tool span → outcome" isn't reliable today. Hook input has no call id, so parallel calls to the same tool look identical. The OTel github.copilot.hook.* span events also lack gen_ai.tool.call.id, even though the execute_tool spans have it (checked on 1.0.119).
Putting the same id in both the hook input and the hook span events would let security teams tie a deny or ask decision to the exact tool call, without guessing from timestamps.
Activity
k4otix commentedon Dec 3, 2026
+1. This is the missing join key between hooks and the native OTel export.
A common enterprise pattern is managed
preToolUse/postToolUsehooks for policy and audit, with OTel for observability. Joining "hook decision →execute_toolspan → outcome" isn't reliable today. Hook input has no call id, so parallel calls to the same tool look identical. The OTelgithub.copilot.hook.*span events also lackgen_ai.tool.call.id, even though theexecute_toolspans have it (checked on 1.0.119).Putting the same id in both the hook input and the hook span events would let security teams tie a deny or ask decision to the exact tool call, without guessing from timestamps.