You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Agent state: an approved long-running tool is served as needs-input until the tool completes #1851
Found during #1595 Phase 8 real-session verification. After the operator approves a permission prompt for a long-running tool, the served agent state stays needs-input until the tool completes, because Claude Code fires no hook on approval; the next lifecycle event is PostToolUse when the tool ends. Measured: approved at 07:57:22, a 5.5-minute tool, needs-input served until 08:02:55.
This matches #1595's SC3 as written ("within 5 s of the approved tool completing") and is documented behaviour in that lane. It is still a false "needs input" for the whole run, visible on every attention surface, for any session that raises permission prompts (default permission mode; sessions launched with the skip-permissions flag never prompt, so most codev builders and architects do not hit it).
Candidate design (not decided)
The spike behind #1595 established that the TUI repaints its elapsed-time counter every second during a running foreground tool, while the screen is static at a permission prompt. So served needs-input plus PTY output fresher than about 3 s is evidence the prompt was answered and the tool is running. The sdk classifier could downgrade needs-input to working only while that freshness holds; a one-off output blip (a resize, a delivered message) would clear it for a few seconds and then needs-input returns.
This fuses a PTY signal back into a harness-reported state, which #1595 deliberately avoided, so it needs a conscious decision rather than a late patch:
it changes SC3's semantics and the needs-input row's meaning;
flicker on output blips must be bounded and verified in a real session;
the question tool is unaffected (answering completes the tool, so PostToolUse fires at once).
Alternative: leave as documented behaviour and revisit if the harness gains an approval hook.
Acceptance (if taken)
Approve a long tool: the row leaves needs-input within a few seconds of approval and shows working until completion.
A permission prompt left unanswered stays needs-input indefinitely (no false clear).
Status from the #1595 lane (PR #1854): this stays open. #1854 ships it as a documented limitation (review doc Known Limitations, arch.md Agent State). Below: why the hook set can't close it, and the options worth exploring.
Why hooks alone can't fix it
Measured hook timeline around a permission prompt (Claude Code 2.1.289 and 2.1.306):
Moment
Hook
Tool about to run
PreToolUse
Prompt drawn
PermissionRequest (~10 ms later), Notification(permission_prompt) ~6 s later
Operator approves
none
Tool completes
PostToolUse
Turn ends
Stop
No event fires between approval and completion, so the served state cannot move then.
PermissionRequest fires before the decision. Our reporter hooks are async and fire-and-forget, so they never see the outcome.
PTY-freshness downgrade (the candidate in the body). Cheapest. The risk is asymmetric: a false working hides a real prompt, which is worse than today's false needs-input. Any version needs:
a minimum continuous-output window (not a single blip);
a test that an unanswered prompt survives resizes and delivered messages;
real-session measurement of how often the prompt pane itself repaints.
Upstream approval signal. Re-spike each Claude Code release for a hook that fires on a permission decision or on tool start after approval. If one appears, it maps to tool-activity in the reporter with no Tower, contract or sdk change, and supersedes options 1 and 2. Worth raising as a harness feature request.
Presentation-only mitigation. Keep needs-input but show elapsed time since the prompt, plus "may be running" when output is fresh. The served state stays honest and the operator can judge. Cheap fallback if 1 to 3 don't pan out.
Out of scope regardless
The question tool is unaffected: answering completes the tool, so PostToolUse fires at once. Sessions launched with the skip-permissions flag never prompt, so this affects default-mode sessions only.
Activity
amrmelsayed commentedon Oct 21, 2026
Status from the #1595 lane (PR #1854): this stays open. #1854 ships it as a documented limitation (review doc Known Limitations,
arch.mdAgent State). Below: why the hook set can't close it, and the options worth exploring.Why hooks alone can't fix it
Measured hook timeline around a permission prompt (Claude Code 2.1.289 and 2.1.306):
PreToolUsePermissionRequest(~10 ms later),Notification(permission_prompt)~6 s laterPostToolUseStopPermissionRequestfires before the decision. Our reporter hooks areasyncand fire-and-forget, so they never see the outcome.PermissionRequesthook would put codev in the permission path. Agent attention states (working / needs-input / idle / dead) from harness lifecycle hooks instead of PTY-silence inference #1595 rules that out: the reporter never makes, delays or influences a permission decision (SC15).Options to explore
workinghides a real prompt, which is worse than today's falseneeds-input. Any version needs:tool-activityin the reporter with no Tower, contract or sdk change, and supersedes options 1 and 2. Worth raising as a harness feature request.tool_result? Unverified. If it records nothing until completion, drop this option.needs-inputbut show elapsed time since the prompt, plus "may be running" when output is fresh. The served state stays honest and the operator can judge. Cheap fallback if 1 to 3 don't pan out.Out of scope regardless
The question tool is unaffected: answering completes the tool, so
PostToolUsefires at once. Sessions launched with the skip-permissions flag never prompt, so this affects default-mode sessions only.