Commit 3fc9ead
authored
fix(daemon): close stdin on AskUserQuestion tool_use so runs don't hang (#4277)
* fix(daemon): close stdin on AskUserQuestion tool_use so runs don't hang (#4273)
Remove the dead AskUserQuestion detection branch from
applyClaudeStreamJsonRunBookkeeping. The branch (left over from PR #4114
cleanup) added the tool_use id to pendingHostAnswers and returned early
when the CLI emitted an AskUserQuestion tool_use event. This blocked the
subsequent non-tool_use turn_end from closing stdin, leaving the run
stdinOpen indefinitely — the cleanTerminalTurn condition could never be
satisfied because pendingHostAnswers.size was always > 0. The run stayed
`running` forever and the web Continue button stayed disabled.
The AskUserQuestion tool wiring and POST /api/runs/:id/tool-result
endpoint were intentionally removed in PR #4114; per AGENTS.md the
stream-json stdin skeleton is retained only as generic infrastructure.
The detection branch had no live counterpart to answer it and was
therefore permanently blocking.
Fix: remove the branch, the pendingHostAnswers type field, and the
pendingHostAnswers guard in the cleanTerminalTurn condition. A
non-tool_use turn_end now correctly closes stdin regardless of what
tool_use events preceded it.
* docs(spec): reconcile stale AskUserQuestion/tool-result references
Address @PerishCode review on #4277: the 'Why OD diverged' section and the
'Interactive intact' acceptance test still described the removed host-answer
contract (stream-json tool_result / POST /api/runs/:id/tool-result) as live.
Rewrite both to the current <question-form> -> POST /api/chat path, citing the
PR #4114 removal already stated earlier in the spec, so future maintainers
cannot reintroduce the dead path.
* docs(spec): correct stdin lifecycle direction in stream-json note
Address @PerishCode second review on #4277: prior cleanup wrote that stdin
closes on a tool_use stop reason, inverting the invariant the daemon code and
regression test rely on. Per applyClaudeStreamJsonRunBookkeeping, stdin stays
open across tool_use pauses and closes only on a terminal non-tool_use
turn_end/usage. Reword the clause to match.1 parent 4b3bf91 commit 3fc9ead
3 files changed
Lines changed: 56 additions & 28 deletions
File tree
- apps/daemon
- src
- tests
- specs/change/20260529-claude-session-resume
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4574 | 4574 | | |
4575 | 4575 | | |
4576 | 4576 | | |
4577 | | - | |
4578 | 4577 | | |
4579 | 4578 | | |
4580 | 4579 | | |
| |||
4601 | 4600 | | |
4602 | 4601 | | |
4603 | 4602 | | |
4604 | | - | |
4605 | | - | |
4606 | | - | |
4607 | | - | |
4608 | | - | |
4609 | | - | |
4610 | | - | |
4611 | | - | |
4612 | | - | |
4613 | | - | |
4614 | | - | |
4615 | 4603 | | |
4616 | | - | |
| 4604 | + | |
4617 | 4605 | | |
4618 | | - | |
4619 | | - | |
| 4606 | + | |
| 4607 | + | |
4620 | 4608 | | |
4621 | | - | |
4622 | | - | |
| 4609 | + | |
4623 | 4610 | | |
4624 | 4611 | | |
4625 | | - | |
4626 | | - | |
4627 | | - | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
4628 | 4615 | | |
4629 | 4616 | | |
4630 | 4617 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
554 | | - | |
555 | 554 | | |
556 | 555 | | |
557 | 556 | | |
| |||
571 | 570 | | |
572 | 571 | | |
573 | 572 | | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
574 | 604 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| |||
334 | 341 | | |
335 | 342 | | |
336 | 343 | | |
337 | | - | |
338 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
339 | 350 | | |
340 | 351 | | |
341 | 352 | | |
| |||
0 commit comments