PostToolUse hook adds ~1.7s to every tool call on Windows
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with scripts/on-post-tool-use.sh and scripts/on-permission-request.sh, then read the README's PostToolUse behavior and the hook payload handling. Compare the existing process chain with the suggested gating or consolidation approaches, using session durationMs measurements as the baseline. Done means preserving required Warp notifications and status behavior while reducing Windows hook latency, validated with before-and-after measurements.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
scripts/on-post-tool-use.sh is registered on PostToolUse with no matcher, so it runs after every tool call. Under Git Bash on Windows each run blocks for about 1.7 seconds. Measured across my sessions that is roughly 11% of the typical gap between consecutive tool calls and 6.5% of total turn wall time.
Environment
- Claude Code 2.1.220, native install
- Windows 11 Pro 26200, hooks running under Git Bash (MSYS2)
- Warp
v0.2026.07.15.08.55.stable_01,WARP_CLI_AGENT_PROTOCOL_VERSION=1 - Plugin
warp@claude-code-warp2.2.0 - Past
LAST_BROKEN_STABLE, soshould_use_structuredreturns 0 and the full structured path runs on every fire
Measurements
Claude Code records a durationMs per hook run in its session transcripts. Attributed per script:
| script | runs | median | p90 | worst |
|---|---|---|---|---|
on-post-tool-use.sh |
5,643 | 1,699 ms | 4,060 ms | 9,814 ms |
on-stop.sh |
410 | 3,856 ms | 6,612 ms | 14,211 ms |
on-session-start.sh |
42 | 2,813 ms | 6,056 ms | 8,746 ms |
Cost in context, over 521 turns totalling 47.1 hours of turn wall time:
on-post-tool-use.shaccounts for 3.1 hours of that, or 6.5%- median gap between consecutive tool calls is 15.0 s, of which the hook is 1.7 s
- it fires 12x more often than the plugin's other two hooks combined
Where the time goes
Benchmarked against a bare bash -c ':' spawn, arms interleaved, 15 iterations each: shipped hook 5,816 ms/run, bare spawn 540 ms/run. Both arms ran loaded, which is why they sit above the telemetry median. The ratio is the point, and it puts one fire at about eleven bash process spawns.
The chain explains that. One fire spawns two bash processes and eleven helper binaries, five of them separate jq calls, plus roughly a dozen $(...) subshells. MSYS2 emulates fork(), so process creation is expensive and the fixed startup cost dwarfs the work being done. Untested on macOS and Linux.
The asymmetry
on-permission-request.sh sets the session to Blocked and fires rarely. Only on-post-tool-use.sh clears it mid-turn, and that fires after every tool call regardless. Hooks are stateless, so it cannot know whether the session is currently Blocked and notifies unconditionally: thousands of notifications to clear a state set on the order of tens of times.
Suggestions
- Sentinel gate.
on-permission-request.shwrites a marker keyed onsession_id, already in the payload;on-post-tool-use.shnotifies and clears it only when present, making the common path onetest -fand an exit. Caveat: the README saysPostToolUsealso drives Warp's inline status indicators, so this breaks anything needing a continuoustool_completestream rather than edge transitions. - One process, one
jq. A singlejqover stdin can pullsession_id,cwd, andtool_name, deriveproject, and emit the{terminalSequence: ...}wrapper in one pass. Inliningwarp-notify.shdrops the second bash process, the duplicatesource, and thegrep/headversion parse. - Drop
jqhere. Thetool_completepayload is fixed-shape with two fields needing escaping; building it in bash spawns no helper binary at all.
Happy to run a patched build and send back before-and-after durationMs.
- Lingua principale
- Shell
- Stelle
- 232
- Fork
- 56
- Merge medio
- 4g 15h
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di warpdotdev/claude-code-warp
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
warpdotdev/claude-code-warp#63 · 2 commenti ·
Tutte le issue di warpdotdev/claude-code-warp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
gnosis/gnosis_vpn#540 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue needs-triage priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
melodic-software/claude-code-plugins#6631 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Lid close does not lock the session on Apple Silicon (lid-close bind skips omarchy-system-lid-close)Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 90/100
omacom/omarchy-mac#701 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
A 20.x release after 21.0.0 would move `latest` back to 20.x, and `next` stays on the release candidateForse già presa @armando-navarro l’ha presa oggi. Apertacomp: build/pipeline type: bug version: current (v17+)
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
angular/angularfire#3790 ·
I maintainer di solito rispondono entro 3 giorni