Skip to content

fix(sandbox): background work an agent waits on keeps its sandbox on - #71

Merged
t3-code-sandboxes[bot] merged 1 commit into
feat/sandbox-environmentsfrom
fix/sandbox-keepalive-background
Nov 15, 2026
Merged

t3-code-sandboxes[bot] merged 1 commit into
feat/sandbox-environmentsfrom
fix/sandbox-keepalive-background

Conversation

@t3-code-sandboxes

Copy link
Copy Markdown

Stacked on #70.

Problem. A Boat sandbox stops after about 35 minutes "without work". The keep-alive only counted threads with a queued, preparing, starting or running status, or a thread changed since its last check. An agent waiting on background subagents, background commands or monitors looked idle: its thread was waiting or completed, and native subagent children list as idle. So Boat stopped the sandbox mid-wait, killing Claude Code and its tasks, and the agent never woke. On a user's own machine that work is never killed for being idle.

Fix (keep-alive script only).

  • The keep-alive lists every thread over MCP, paging through nextCursor, and judges each check in this order:
    • busy: a thread is queued, preparing, starting or running, or has a pending subagent or background_task, or an awaited command or monitor. These are the same rules as backgroundWorkHoldsCompletion.
    • active: a thread changed since the last check (unchanged).
    • background: only unawaited commands or monitors, such as a dev server, are pending. These extend only within the existing 480-minute running limit, so a forgotten server doesn't bill forever.
    • idle: nothing above.
  • It reads the existing pendingBackgroundTasks on list items, so no server or contract changes. On an older T3 without that field, it behaves as before.
  • Each log line records the pending-work count (e.g. busy pending=2 extend 200), so a stop can be explained afterwards.
  • The Boat keep-alive section of docs/user/remote-access.md now covers this.

Test plan

  • sandboxSetup.test.ts "counts background work an agent will wake for, and a dev server to the limit": the work sits on page 2 of the list (awaited command, waiting parent with a subagent, idle child) and gives one extend. The CLI fallback carrying a subagent also extends, and a lone dev server extends at 59 min but not at 60. Gives 0 extends on the base.
  • The sandboxKeepAliveScript tests (5/5) and the server typecheck pass on the stack tip

Claude Opus 5.5 via Claude Code.

🤖 Generated with Claude Code

The keep-alive saw only thread statuses and updates, so a sandbox stopped while an agent waited
on subagents, background commands or monitors, killing the agent before it woke. It now reads
every thread's pending background work: work that holds a thread counts as busy, and work no
agent waits on, such as a dev server, keeps the sandbox on up to the running limit. Each check
logs how many threads had background work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from fix/sandbox-model-parity to feat/sandbox-environments November 15, 2026 21:16
@t3-code-sandboxes
t3-code-sandboxes Bot merged commit b4eb08f into feat/sandbox-environments Nov 15, 2026
@t3-code-sandboxes
t3-code-sandboxes Bot deleted the fix/sandbox-keepalive-background branch November 15, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant