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
The Session prompt says ending the turn kills background tasks, but Claude Code -p waits for them #1517
Every Session prompt that runs commands contains this sentence (src/prompt.rs:40):
Never end your turn while a background task you depend on is still running: ending the turn kills it.
For Claude Code -p (2.1.312), the second half is false. The sentence that follows it in the prompt already assumes the opposite: "a task still running when your turn ends is taken as work you were waiting on."
Evidence (2026-10-27, Jacob-MacBook-Pro)
The implement session of #1482 (Pickup run pickup-20261027T195741-0400, PR #1505):
20:24:01: it started cargo test -- --test-threads=3 in the background (task bb2cn7cp9).
20:24:16: it said "Waiting for the local run on the merged head to finish." and ended its turn (result, stop_reason: end_turn).
The session broke the rule and nothing went wrong, apart from a false Silent (#1499). Agents can see the rule doesn't hold, and a prompt rule that doesn't hold makes the rest of the prompt less trustworthy.
Decision for the Day shift
Either:
Keep the rule and correct the reason. Say why ending the turn is unwanted for each Harness: for example, the Run reads as Silent, and for Codex the task may really be killed (unverified). Or:
Check Codex's behaviour before choosing. The prompt is shared by both Harnesses. After changing src/prompt.rs, regenerate prompts/ and the site fragment with UPDATE_PROMPTS=1 cargo test prompts_page.
Investigation of #1517 against main at 9712feb confirms the shared prompt makes an unsupported universal claim. The remaining question is which wait policy the Day shift wants.
Evidence:
src/prompt.rs:28-43 says ending a turn ends the Session and kills background tasks. Both the opening sentence and the stated reason need correction for Claude's reported behavior.
src/harness/interpretation/stream.rs:3-6 explicitly distinguishes a turn result from Session completion. Its tests include background_sub_agents_that_resumed_the_session_are_not_killed_background_work. This corroborates the lifecycle described in the supplied issue; the reported Mac session was not independently replayed.
docs/research/codex-headless-harness.md:174-183 explains Codex exec shutdown. Its recorded live check at line 273 reports that Codex 0.160.0 killed an ordinary background sleep when exec ended, while setsid nohup escaped and survived. Thus the issue's Codex question already has version-specific evidence in the repository.
src/harness/codex/stream.rs:197-215 classifies unfinished items at turn.completed as killed work; passing adapter tests verify that interpretation, rather than independently proving current CLI behavior.
src/process/tests.rs:509 verifies that normal supervision completion can leave background work without inherited I/O alive. Task termination is not a universal guarantee provided by thirdshift.
Recommendation: retain the shared requirement to collect all required results before finishing, but explain that background-task lifetime differs by Harness and execution mode. Preserve task-specific waiting and stopping guidance. Avoid claiming that every task dies or that every turn result ends a Session. Permitting Claude to finish a turn while waiting remains an alternative policy for the Day shift to choose.
After that decision, update HEADLESS and its explanatory comment in src/prompt.rs, regenerate prompts/ and the generated site fragment with UPDATE_PROMPTS=1 cargo test prompts_page, and verify with cargo test prompts_page. Leave the actual-killed-work Resume path intact unless separate evidence requires changing it. Keep health behavior under #1499.
Validation: cargo test --bin thirdshift background -- --test-threads=3 passed 16 tests; cargo test --bin thirdshift prompts_page -- --test-threads=3 passed 14 tests. scripts/affected-tests main reported no changed files. No source or Git-history changes were made.
Questionnaire
For the Day shift deciding #1517: the shared prompt claims every turn ending kills background tasks, while the Claude adapter supports background notifications resuming a Session. Repository-recorded Codex 0.160.0 testing found ordinary background commands killed at exec shutdown, with detached commands able to survive.
Activity
JacobStephens2 commentedon Nov 10, 2026
Investigation of #1517 against main at 9712feb confirms the shared prompt makes an unsupported universal claim. The remaining question is which wait policy the Day shift wants.
Evidence:
Recommendation: retain the shared requirement to collect all required results before finishing, but explain that background-task lifetime differs by Harness and execution mode. Preserve task-specific waiting and stopping guidance. Avoid claiming that every task dies or that every turn result ends a Session. Permitting Claude to finish a turn while waiting remains an alternative policy for the Day shift to choose.
After that decision, update HEADLESS and its explanatory comment in src/prompt.rs, regenerate prompts/ and the generated site fragment with UPDATE_PROMPTS=1 cargo test prompts_page, and verify with cargo test prompts_page. Leave the actual-killed-work Resume path intact unless separate evidence requires changing it. Keep health behavior under #1499.
Validation: cargo test --bin thirdshift background -- --test-threads=3 passed 16 tests; cargo test --bin thirdshift prompts_page -- --test-threads=3 passed 14 tests. scripts/affected-tests main reported no changed files. No source or Git-history changes were made.
Questionnaire
For the Day shift deciding #1517: the shared prompt claims every turn ending kills background tasks, while the Claude adapter supports background notifications resuming a Session. Repository-recorded Codex 0.160.0 testing found ordinary background commands killed at exec shutdown, with detached commands able to survive.