Repository navigation
fix(harness): keep a Claude task running while its background tasks wake Claude - #3149
Draft
thomasbarrett wants to merge 1 commit into
Draft
thomasbarrett wants to merge 1 commit into
thomasbarrett wants to merge 1 commit into
Conversation
…ake Claude When a background task or Monitor wakes Claude after its first result, Claude Code emits another result per wake-up and exits only once nothing is left running. The driver treated the first result as terminal, so the next reply failed the task with "claude emitted activity after its terminal result" and the process group, background job included, was killed. The turn now ends when Claude exits, with the last result as its outcome. Replies after a result start a new paragraph, and approval requests after a result take the normal input-required path. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Thomas Barrett <thomas@fluidstack.io>
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.
When Claude starts a Monitor or a background shell and ends its turn, Claude Code emits a result, then another result each time the background task wakes it, and exits only once nothing is left running. The driver took the first result as terminal, so Claude's next reply failed the task with
claude emitted activity after its terminal result, and the process group, background job included, was killed.With this change a Claude harness task lives exactly as long as
claude -pdoes: it ends when Claude exits, and the last result is its outcome.origin.kind: task-notificationare no longer dropped by the parser; each one replaces the outcome so far.The task stays working while background tasks run, so its Actor isn't suspended under them; cancellation still kills the process group. Claude Code bounds how long that can be: in unattended runs a background command is stopped after 30 minutes unless Claude asks for longer, at most 2 hours, and a Monitor watch lasts at most 30 minutes (tools reference). Claude can restart either.
testdata/stream-background.jsonlis modelled on Claude Code 2.1.296's output for a Monitor (each wake-up is a freshinit, assistant reply andtask-notificationresult); 2.1.296 behaves the same for arun_in_backgroundshell.Not in this PR: reporting
background_tasks_changedas a status update, so a task waiting on a job isn't silent, and an overall bound on how long a task can run.Tested with
go test ./harness/claude/... ./harness/runtime/...andmake -C go lint. The new process test fails on main with the error above. Not run in a cluster.🤖 Generated with Claude Code