Repository navigation
bash: a cancelled bash_job wait parks the job again instead of killing it - #269
Merged
Merged
Conversation
…g it An abort while the model waited on a job with bash_job (or a mid-run compact/switch_session/new_session/fork, which self-aborts the run) killed the job: the wait takes the job out of the table, and the cancelled attach dropped it. The model had been told a background job "keeps running after your turn ends"; it died silently, with no bash_jobs_stopped frame, and the next bash_job said "no job 1". A cancelled attach now parks a job that already has a number back in the table and says "Wait cancelled; job N is still running." Only a call's own fresh command dies with the call. Test: bash_jobs_serve_abort.rs aborts a bash_job wait on a background job, then checks the process is alive, nothing was reported stopped, and a peek on the next prompt still finds job 1 (fails on main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes serve audit defect #8 (wrong output, from #254/#258).
Problem
Aborting a
bash_jobwait killed the job being waited on. The same happened when a busycompact,switch_session,new_sessionorforkself-aborted the run.resume_jobtakes the job out of the table to wait on it, and the cancelledattachthen dropped it. Dropping aJobkills it. So a server the model had started withrun_in_background, and been told "keeps running after your turn ends", died silently:bash_jobs_stoppedframe was sent;bash_jobsaid "no job 1: it was already reported, was stopped, or never existed".Fix
When
attachis cancelled while holding a job that already has a number, it parks the job back in the table and returns "Wait cancelled; job N is still running." Only a call's own fresh command dies with the call, which keepscmd &grandchildren of an aborted command from leaking. A re-parked yielded job is still stopped byend_turnas usual. ARCHITECTURE.md and theattachdoc are updated.Tests
New
crates/agent/tests/bash_jobs_serve_abort.rs: start a background job, wait on it withbash_job, thenabort. The test checks:bash_jobs_stoppedframe was sent;timeout_ms: 0peek on the next prompt still finds job 1 running.It fails on main with
Command cancelled.cargo fmt,clippy --all-targets -D warningsanddprint checkare clean. The agent + agent-core nextest suites passed in full, 3908/3908, on the stacked serve-jobs fixes.🤖 Generated with Claude Code
https://claude.ai/code/session_01JimHGjsfk2Ktm5GxyZJKKk