Description
Claude Code v2.1.119 (April 23, 2026) added a duration_ms field to PostToolUse and PostToolUseFailure hook payloads, reporting tool execution wall time (excluding permission prompts and PreToolUse hook time).
Zeph's hook system (zeph-config/src/hooks.rs, zeph-core hook firing) passes env vars to hook scripts but does not include timing information. This prevents hooks from implementing performance-aware behaviors (alerting on slow tools, logging latency per tool type, triggering escalation on timeout).
Relevance to Zeph
HookContext / env vars set at fire_hooks time should include ZEPH_TOOL_DURATION_MS
PreToolUse time should be excluded (only measure actual tool executor wall time)
- Applies to both
post_tool_use and post_tool_use_failure event types
Implementation Sketch
- Record
Instant::now() before calling the tool executor
- After execution, compute
duration_ms = elapsed.as_millis()
- Add
ZEPH_TOOL_DURATION_MS=<N> to the env vars passed to post_tool_use / post_tool_use_failure hooks
- Document in
zeph-config hook env var reference
Estimated Complexity
Very low (~1h). Timer is already available; only env var injection is new.
Source: Claude Code changelog v2.1.119 — https://code.claude.com/docs/en/changelog
Description
Claude Code v2.1.119 (April 23, 2026) added a
duration_msfield toPostToolUseandPostToolUseFailurehook payloads, reporting tool execution wall time (excluding permission prompts and PreToolUse hook time).Zeph's hook system (
zeph-config/src/hooks.rs,zeph-corehook firing) passes env vars to hook scripts but does not include timing information. This prevents hooks from implementing performance-aware behaviors (alerting on slow tools, logging latency per tool type, triggering escalation on timeout).Relevance to Zeph
HookContext/ env vars set atfire_hookstime should includeZEPH_TOOL_DURATION_MSPreToolUsetime should be excluded (only measure actual tool executor wall time)post_tool_useandpost_tool_use_failureevent typesImplementation Sketch
Instant::now()before calling the tool executorduration_ms = elapsed.as_millis()ZEPH_TOOL_DURATION_MS=<N>to the env vars passed topost_tool_use/post_tool_use_failurehookszeph-confighook env var referenceEstimated Complexity
Very low (~1h). Timer is already available; only env var injection is new.
Source: Claude Code changelog v2.1.119 — https://code.claude.com/docs/en/changelog