PostToolUse hook not sending tool_use_id field as documented

Resolved 💬 5 comments Opened Dec 6, 2025 by orr-levinger Closed Feb 27, 2026

Problem

The PostToolUse hook is not sending the tool_use_id field in the hook data, despite being documented in the official hooks documentation.

Documentation vs. Reality

According to the documentation (PostToolUse Input):

The hook should receive:

{
  "tool_name": "Read",
  "tool_input": {...},
  "tool_response": {...},
  "tool_use_id": "toolu_01XX...",
  "session_id": "...",
  "transcript_path": "...",
  ...
}

In reality:
The tool_use_id field is always null or missing from the hook data.

Impact

Without tool_use_id, we cannot:

  1. Correlate tool executions with Claude's internal transcript
  2. Match PreToolUse and PostToolUse events for the same tool call
  3. Handle parallel tool execution correctly (multiple tools running simultaneously)
  4. Build accurate trace hierarchies for LangSmith-style visualization

Current Workaround

We're forced to parse the transcript JSONL file to extract tool_use_id by searching for the most recent tool_use block that matches the tool name:

# Workaround: Parse transcript to find tool_use_id
def _extract_tool_use_id_from_transcript(transcript_path: str, tool_name: str):
    # Read last 100 lines of transcript
    # Parse JSONL entries
    # Find most recent {"type": "tool_use", "name": tool_name, "id": "toolu_..."}
    # Return the id

This is fragile because:

  • It's slow (reads 100+ lines per tool call)
  • Can mismatch tools with the same name
  • Fails with parallel tool execution
  • Adds unnecessary complexity

Expected Behavior

Claude Code should send tool_use_id in both PreToolUse and PostToolUse hook data, exactly as documented.

Environment

  • Claude Code version: Latest (as of 2024-12-06)
  • Hook: PostToolUse
  • Platform: macOS (but affects all platforms)

Request

Please add the tool_use_id field to the hook data as documented, so we can correlate tool executions without parsing transcript files.

Thank you!

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗