Repository navigation
fix(server): t3_thread_wait can wait out a thread's background tasks - #256
Merged
Merged
Conversation
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
…d tasks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jayleaton
force-pushed
the
fix/thread-wait-background-tasks-20261116
branch
from
November 16, 2026 04:13
24eed72 to
72190f0
Compare
jayleaton
marked this pull request as ready for review
November 16, 2026 04:20
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.
A thread can end its run with background tasks still running, such as a
make box-ciit backgrounded.t3_thread_waiton that idle thread returned at once, even withuntilDelegatedWorkSettled: true, so a Captain listener used up its rounds in seconds.Summary
untilDelegatedWorkSettledwaits only for delegated tasks and awaited background tasks. A task is awaited only if the agent marked it witht3_background_wait, which only Claude can do. Plain commands and monitors were left out on purpose, because a dev server must not hold a delegated result open. The reported thread is an OpenCode thread: its twobox-ciruns werekind: "command"with noawaited, so the wait reportedresult_availableimmediately.untilBackgroundWorkEnds, instead of wideninguntilDelegatedWorkSettled. Remote delegation (RemoteDelegation.ts) andt3 thread(threadIsIdle) useuntilDelegatedWorkSettledto mean "the result is ready". If it counted every background command, a child that left a dev server running would never deliver its result.pendingBackgroundTaskslist thatt3_thread_readreturns. A wait that times out keeps today's shape: the run status shows the run ended,timedOut: trueshows the thread isn't done, andpendingBackgroundTaskCountsays why.PeerForwardingpasses the flag through to linked environments.captain-event-loop, as rewritten in chore(agents): Captain preset follows approvals, continuations and post-merge cleanup #254) passesuntilBackgroundWorkEnds: truein step A, so an idle child with running background work no longer ends the listener. Step D stays: the wait returns when a background task's completion starts a new run, and D'sactiveRunIdcheck follows that run.Evidence
The reported thread on the live install (main build), idle with two unawaited
box-cicommands. This is before:This branch's dev server, on a completed thread from a seeded copy with one unawaited
commandtask added (sandbox data only). This is after:New case in
ThreadManagementService.test.ts: waitForThread can wait past an ended run for its background tasks. On main it fails withtimedOut: false(expectedtruewithpendingBackgroundTaskCount: 1). On this branch it passes, including the wake: the command ends, a new run starts, and the wait returns.vp run check:changedpasses.The tool-list budget (
agentContextBudget.json) grows by 178 bytes for the new field; theagent-context-increaselabel accepts that. I didn't run a paid eval because this checkout has no eval API key. The change adds a parameter and doesn't rewrite existing guidance.Thread status,
t3_thread_readand the Agents view list the same tasks, but on purpose they treat only awaited tasks as "Working" (backgroundWorkHoldsCompletion). I left that unchanged.Merge Danger
Door: two-way. The flag is opt-in, and a missing flag behaves exactly as before.
Blast Radius: narrow. Only callers that pass
untilBackgroundWorkEndschange: the Captain listener template and any agent that opts in.Opus 5.5 via Claude Code in Ada.
🤖 Generated with Claude Code