Skip to content

Hooks: include tool_use_id in PreToolUse and PostToolUse input #85

Open

Description

@LoopGlitch26

The hooks reference documents PreToolUse and PostToolUse input as session_id, transcript_path, cwd,
permission_mode, hook_event_name, tool_name, tool_input (and tool_response), with nothing that names the
tool call (docs/reference/hooks-reference.mdx:279-338).

A hook that handles both events can't tell which PreToolUse a PostToolUse closes. Two identical calls in flight (the
same Read, a retried Execute) look the same. Droid also runs PostToolUse only after a tool succeeds and has no
PostToolUseFailure, so a call that fails, is declined in the permission prompt, or is blocked by another hook leaves a
PreToolUse with nothing after it. A hook that pairs by tool and arguments then hands the next identical call's result
to the wrong call.

Proposed: a tool_use_id field (the model's tool call id, which the transcript also records) on PreToolUse and
PostToolUse input. Droid already uses Claude Code's event names and field names, and Claude Code's PreToolUse and
PostToolUse carry tool_use_id, so hooks written for Claude Code would work unchanged. A PostToolUseFailure event
would close the remaining gap; I can file that separately.

Context: I maintain Tracekit (https://github.com/Cygnux-Labs/Tracekit), which records and gates agent tool calls; this would let it pair each Droid call with its result by id instead of by tool and arguments.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions