claude-code - 💡(How to fix) Fix [DOCS] Hook input references omit `duration_ms` for `PostToolUse` and `PostToolUseFailure` [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52607Fetched 2026-04-24 06:02:36
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

error: string; PostToolUseFailureHookInput documents tool_name, tool_input, tool_use_id, error, is_interrupt, agent_id, and agent_type. PostToolUseFailure hooks receive the same tool_name and tool_input fields as PostToolUse, along with error information as top-level fields.

RAW_BUFFERClick to expand / collapse

Documentation Type

Incorrect/outdated documentation

Documentation Location

https://code.claude.com/docs/en/agent-sdk/typescript

Section/Topic

PostToolUseHookInput and PostToolUseFailureHookInput in the Agent SDK hook input reference, plus the corresponding hook input documentation for PostToolUse / PostToolUseFailure

Current Documentation

The docs currently show these TypeScript hook input definitions:

PostToolUseHookInput

type PostToolUseHookInput = BaseHookInput & { hook_event_name: "PostToolUse"; tool_name: string; tool_input: unknown; tool_response: unknown; tool_use_id: string; };

PostToolUseFailureHookInput

type PostToolUseFailureHookInput = BaseHookInput & { hook_event_name: "PostToolUseFailure"; tool_name: string; tool_input: unknown; tool_use_id: string; error: string; is_interrupt?: boolean; };

The Python reference shows the same omission:

PostToolUseHookInput documents tool_name, tool_input, tool_response, tool_use_id, agent_id, and agent_type.

PostToolUseFailureHookInput documents tool_name, tool_input, tool_use_id, error, is_interrupt, agent_id, and agent_type.

The hooks reference also currently says:

PostToolUse hooks fire after a tool has already executed successfully. The input includes both tool_input, the arguments sent to the tool, and tool_response, the result it returned.

PostToolUseFailure hooks receive the same tool_name and tool_input fields as PostToolUse, along with error information as top-level fields.

What's Wrong or Missing?

Changelog v2.1.119 says PostToolUse and PostToolUseFailure hook inputs now include duration_ms (tool execution time, excluding permission prompts and PreToolUse hooks), but the current hook input documentation still omits that field.

As a result, hook authors reading the TypeScript/Python SDK references or the hooks reference cannot discover that duration_ms is available, what it means, or that they can safely consume it in logging, metrics, and automation hooks.

Suggested Improvement

Update the hook input documentation to add duration_ms everywhere PostToolUseHookInput and PostToolUseFailureHookInput are defined or summarized.

Suggested minimum fix:

  1. Add duration_ms to the TypeScript PostToolUseHookInput and PostToolUseFailureHookInput type definitions.
  2. Add duration_ms to the Python class definitions and field tables for those same hook inputs.
  3. Update the hooks reference PostToolUse input / PostToolUseFailure input sections to mention the field and define it as tool execution time in milliseconds, excluding permission prompts and PreToolUse hooks.
  4. Update the example JSON payloads to include duration_ms so the new field is discoverable in the main hooks documentation.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageLine(s)Context
https://code.claude.com/docs/en/agent-sdk/typescript1012-1034PostToolUseHookInput / PostToolUseFailureHookInput type definitions omit duration_ms
https://code.claude.com/docs/en/agent-sdk/python1877-1927Python class definitions and field tables omit duration_ms
https://code.claude.com/docs/en/hooks1145-1222PostToolUse / PostToolUseFailure input docs describe fields but do not mention duration_ms
https://platform.claude.com/docs/en/agent-sdk/typescript1002-1024Agent SDK cross-reference has the same omission
https://platform.claude.com/docs/en/agent-sdk/python1854-1903Agent SDK cross-reference has the same omission

Total scope: 5 pages affected

Source: Changelog v2.1.119

Changelog entry under review: Hooks: PostToolUse and PostToolUseFailure hook inputs now include duration_ms (tool execution time, excluding permission prompts and PreToolUse hooks)

extent analysis

TL;DR

Update the documentation for PostToolUseHookInput and PostToolUseFailureHookInput to include the duration_ms field in the TypeScript and Python SDK references, as well as the hooks reference.

Guidance

  • Review the changelog entry for v2.1.119 to understand the addition of duration_ms to the hook inputs.
  • Update the TypeScript type definitions for PostToolUseHookInput and PostToolUseFailureHookInput to include duration_ms.
  • Update the Python class definitions and field tables for the same hook inputs to include duration_ms.
  • Modify the hooks reference to mention duration_ms as part of the input for PostToolUse and PostToolUseFailure hooks.

Example

type PostToolUseHookInput = BaseHookInput & {
  hook_event_name: "PostToolUse";
  tool_name: string;
  tool_input: unknown;
  tool_response: unknown;
  tool_use_id: string;
  duration_ms: number; // Add this line
};

type PostToolUseFailureHookInput = BaseHookInput & {
  hook_event_name: "PostToolUseFailure";
  tool_name: string;
  tool_input: unknown;
  tool_use_id: string;
  error: string;
  is_interrupt?: boolean;
  duration_ms: number; // Add this line
};

Notes

The updates should be applied to the specified pages in the documentation to ensure consistency and accuracy.

Recommendation

Apply the workaround by updating the documentation as suggested to include the duration_ms field, allowing hook authors to discover and utilize this information correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING