Repository navigation
Resume a session once when its background work was killed - #59
Merged
Merged
Conversation
Sessions run with claude -p, which exits when the agent ends its turn and kills any background task still running. Every prompt now tells the agent to run long commands in the foreground. When a session still ends with background tasks killed after its last result, the Run resumes it once with --resume, logged as <kind>-resume, and fails with the killed task's description if it happens again, instead of an unexplained 'no PR found'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sessions bundles where a Run's sessions run and does the single Resume itself, so run.rs only names the session kind. A session whose last result was an error is not resumed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Summary
A session that ends its turn while waiting on a background Bash task is killed along with that task. The Run then used to fail with an unexplained
no PR found. Now thirdshift prevents it where it can, gives the session one Resume when it happens anyway, and says why if it happens again.Progressrecords thesession_idfrominit, each task's description fromtask_started, and tasks killed after the lastresult(task_updatedwithpatch.status: "killed", ortask_notificationwithstatus: "stopped"). A laterresultclears the list, so background sub-agents that resumed the session don't count. A Resume is not a Repair and doesn't count towardMAX_REPAIRS. CONTEXT.md and the README describe the Resume.Seams under test:
Progress(stream lines in, killed background work and session id out), and the Run binary driven by the fakeclaude/gh(prompts, the resume-once and fail-with-reason cases, the Failed run push). The fakeclaudenow putssession_id: fake-session-<n>in itsinitline, and can emit lines after its closingresult.Evidence
./mvnw testin the background and ends its turn. The task is killed and the Run ends withthirdshift: no PR found.After:
tests/background_work.rs:progress.rscover: killed after the last result;stoppednotifications, deduplicated; no kills; sub-agents that resumed; a kill before a later result; kills after an error ormax_turnsresult;initwithout a session id.cargo test --no-fail-fast: everything passes exceptci::waits_for_github_to_work_out_whether_the_pr_is_mergeable. That test is timing-sensitive (300 ms grace) and also fails 3 of 4 times onmainat this machine's current load, so this change didn't cause it.Merge Danger
Door: two-way
Blast Radius: sessions
Every prompt gets one more paragraph. A session that ends with killed background work now costs one extra
claude --resumesession before the Run goes on or fails.Unaddressed findings
Standards
Progressnow tracks task state as well as progress lines (Divergent Change): skipped. The issue names "Progress, or whatever condenses the stream" as the place for this, and both jobs read the same events in one pass.&str/Stringlists (Primitive Obsession): partly addressed. Removing theEndedstruct got rid of the re-allocation. A dedicated type wasn't worth it for twojoin("; ")calls.HEADLESSwording is repeated in four test files: skipped. Those tests assert each whole prompt as a literal on purpose, so the expected values don't come from the code under test.freshhas no blank line before the headless paragraph: skipped. That matchesfresh's existing style, which has no blank lines between paragraphs.Spec
session_idpath and "Resume opens no PR" have no Run-level tests: skipped. The first needs a fakeclaudethat leaves out its session id, and no real stream does that. The second is the existingno PR foundpath, which is already tested.initwithout a session id is covered by a unit test.Closes #58
🤖 Generated with Claude Code