[Bug]: Injected Claude Code hooks (agent-flow/hook.js) have no timeout — up to 60s stall per prompt/tool call on Windows when Orca is not running
What happened
The Orca desktop app injects managed hooks into the global ~/.claude/settings.json, pointing at node C:\Users\<user>\.claude\agent-flow\hook.js for essentially every hook event: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, SubagentStart, SubagentStop, Notification, Stop, SessionEnd, StopFailure, PermissionRequest.
The injected hook entries ship without a timeout field. Claude Code's default hook timeout is 60 seconds. On Windows, when the hook process hangs or is slow to spawn (notably when Orca itself is not running), every single user prompt and every tool call in a plain terminal claude session can stall for up to 60s. In practice this made Claude Code unusable outside of Orca — a message that should answer in seconds took minutes, and the cause was invisible to the user (no error, just dead time before each step).
Diagnosis: a perf audit of ~/.claude/settings.json found the UserPromptSubmit agent-flow hook to be the primary cause of a consistent ~60s delay on the first prompt, with the other 10 injected events adding per-tool-call overhead. Removing the UserPromptSubmit entry and adding "timeout": 2 to the remaining agent-flow hooks fixed it immediately.
Environment
- Windows 11 Pro (10.0.26200)
- Orca desktop (electron-updater
stablyai/orca, current release as of 2026-07-04) - Claude Code CLI, used both inside Orca and standalone in a terminal
Expected behavior
- Injected hooks should declare a small explicit
timeout(1–3s) — they are telemetry/coordination hooks, not workflow gates, so they should never be able to block the user's turn for 60s. hook.jsshould fail fast (exit 0 quickly) when the Orca app/relay is not running, instead of hanging until Claude Code kills it.- Ideally, hook injection would be scoped so standalone terminal sessions aren't affected — e.g. only while an Orca-managed session is active, or at least in
settings.local.jsonas requested in #6879.
Workaround applied locally
Removed the UserPromptSubmit agent-flow hook and set "timeout": 2 on all remaining injected agent-flow hooks in ~/.claude/settings.json. Note the app appears to re-write parts of this file, so manual fixes may not survive updates — which is why an upstream fix matters.
Related: #6879 (inject into settings.local.json instead), #6694 (Windows hooks blocking every prompt for Cursor agent).
Status: NOT REPRODUCED (already fixed on current tree)
The injected Claude hooks now declare an explicit timeout. applyManagedHooks (src/main/claude/hook-settings.ts:95) builds every entry across all 11 CLAUDE_EVENTS via buildManagedCommandHook (src/main/agent-hooks/installer-utils.ts:51), which sets timeout: MANAGED_HOOK_TIMEOUT_SECONDS (= 10, installer-utils.ts:46) — far below the 60s default the report describes. Additionally the curl transport uses --connect-timeout 0.5 --max-time 1.5 (installer-utils.ts:207,230), so a down relay fast-fails in ~1.5s. This landed in commit e03a1cf769 / PR #6148 ("Prevent managed agent hooks from hanging"), after the older agent-flow/hook.js architecture the issue references.
A unit test importing the real injection path confirms all injected hooks carry an explicit numeric timeout:
pnpm exec vitest run --config config/vitest.config.ts src/main/claude/repro-7323-hook-timeout.test.ts
Result: 2 passed. Residual (not the reported symptom): the injected value is 10s vs the issue's requested 1–3s; tightening it toward the 1.5s curl budget would be a hardening follow-up.
Key files: src/main/claude/hook-settings.ts, src/main/agent-hooks/installer-utils.ts.
Automated bug-reproduction pass. Repro artifact committed on branch nwparker/bug-repro-pass2; check it out to run the command above. Writeup: docs/bug-reproductions/7323.md.
Could not reproduce on the current build — fix already shipped
The reported gap — Orca injecting managed Claude Code hooks into the global ~/.claude/settings.json without a timeout field, letting each event stall up to Claude Code's 60s default — is already fixed on the current tree (v1.4.145.0) and confirmed on a live Windows install.
Historical root cause and the fix:
- Managed hooks are generated by
applyManagedHooks(src/main/claude/hook-settings.ts:106-110), which builds each event's entry viabuildManagedCommandHook(src/main/agent-hooks/installer-utils.ts:51-56). - Before PR #6148 (commit
e03a1cf76, 2026-06-23) the emitted object was{ type: 'command', command }— notimeout, exactly as reported. - #6148 added
MANAGED_HOOK_TIMEOUT_SECONDS = 10and now emits{ type: 'command', command, timeout: 10 }for every managed agent.
Two independent bounds now cap a stalled hook:
- Host-level
"timeout": 10on every injected settings entry (caps Claude Code's 60s default). - Transport-level: the managed script posts with curl
--connect-timeout 0.5 --max-time 1.5, so a dead endpoint (Orca not running) returns in ~1.5s.
Live evidence: on this Windows install, all ten injected events in %USERPROFILE%\.claude\settings.json (UserPromptSubmit, Stop, StopFailure, Pre/PostToolUse, PostToolUseFailure, PermissionRequest, SubagentStart, SubagentStop, TeammateIdle) carry "timeout": 10; none missing. The agent-flow/hook.js node path from the report no longer exists in git history — Orca now ships a .cmd/.sh launcher.
Verify: read installer-utils.ts:46,51-56 + hook-settings.ts:103-114; git show e03a1cf76; regression test src/main/agent-hooks/managed-hook-timeout.test.ts.
This looks safe to close as fixed. Notes in docs/bug-reproductions/7323-injected-hooks-no-timeout.md.
🔁 Attempted via automated Windows bug-reproduction pass.
Closing as fixed.
Merged PR that closes this: https://github.com/stablyai/orca/pull/6148 (Prevent managed agent hooks from hanging).
Managed Claude hooks now declare an explicit timeout via buildManagedCommandHook / applyManagedHooks, so they no longer stall up to Claude Code’s default 60s when Orca is not running.