Skip to content

Restart inherited sandbox sessions when metadata changes#43

Merged
t-kalinowski merged 1 commit intomainfrom
stack/inherit-sandbox-restart
Apr 22, 2026
Merged

Restart inherited sandbox sessions when metadata changes#43
t-kalinowski merged 1 commit intomainfrom
stack/inherit-sandbox-restart

Conversation

@t-kalinowski
Copy link
Copy Markdown
Member

@t-kalinowski t-kalinowski commented Apr 20, 2026

Summary

  • treat inherited sandbox changes as worker-session boundaries and restart before the next non-poll, non-bare-interrupt worker interaction
  • preserve local-only behavior for empty polls, bare interrupts, and pager-local commands while applying current metadata before real worker interactions
  • add restart notices, timeout-bundle handling, and regression coverage for the restart-on-change contract

Why

After the per-call metadata migration, inherited sandbox state still needed one clearer runtime rule: sandbox changes should take effect at the next real worker interaction. That avoids preserving an old worker session when the current tool-call metadata describes a different inherited sandbox.

Public-facing changes

  • when inherited sandbox metadata changes, the next non-empty worker interaction restarts into the new sandbox and reports that restart
  • empty polls keep draining existing output without forcing a restart
  • bare Ctrl-C remains local recovery behavior even if inherited sandbox metadata changed
  • pager-local commands, including active or pending pager navigation, stay local and ignore sandbox metadata until a later call interacts with the worker
  • control-prefixed tails such as Ctrl-C<code> and Ctrl-D<code> run in the restarted session when the sandbox changed

Internal-only changes

  • rework worker respawn sequencing so timeout bundles, detached output, and restart notices survive sandbox-driven restarts cleanly
  • retire stale disclosed timeout bundles when a sandbox change resets the worker session
  • keep session-ended pager commands local until the next worker interaction
  • keep missing-metadata recovery local for empty drains and bare interrupts that can be answered without spawning a worker
  • cover restart edge cases for guardrail retries, active-pager bare restarts, explicit restart prefix cleanup, Windows test compilation, and unit-test process isolation
  • document the restart-on-change contract and expand sandbox-state regression coverage

Diff composition

Measured against origin/main, this PR is 2,737 insertions and 603 deletions across 11 files. Most of that is regression coverage and inline unit tests around worker/session transitions:

  • runtime code in src/: +725/-299 (30.7% of churn)
  • inline tests inside src/: +450/-53 (15.1% of churn)
  • tests in tests/: +1,460/-237 (50.8% of churn)
  • docs: +100/-12 (3.4% of churn)
  • snapshots: +2/-2 (0.1% of churn)

The largest contributors are tests/sandbox_state_updates.rs, src/worker_process.rs, and the inline tests in src/worker_process.rs.

@t-kalinowski t-kalinowski force-pushed the stack/inherit-sandbox-meta branch 5 times, most recently from 25f35f9 to 2acdf61 Compare April 20, 2026 22:37
@t-kalinowski t-kalinowski force-pushed the stack/inherit-sandbox-restart branch from f6b35c0 to 302322f Compare April 21, 2026 18:35
@t-kalinowski t-kalinowski force-pushed the stack/inherit-sandbox-meta branch from 32f077c to 33eaaac Compare April 22, 2026 15:37
Base automatically changed from stack/inherit-sandbox-meta to main April 22, 2026 16:03
@t-kalinowski t-kalinowski force-pushed the stack/inherit-sandbox-restart branch from 302322f to 1602999 Compare April 22, 2026 16:05
@t-kalinowski t-kalinowski marked this pull request as ready for review April 22, 2026 16:53
@t-kalinowski t-kalinowski marked this pull request as draft April 22, 2026 17:39
Treat inherited sandbox metadata changes as worker-session boundaries, while keeping empty polls, bare interrupts, and pager-local commands local until a real worker interaction needs current metadata.

Document the restart contract and add regression coverage for timeout bundles, session-ended pager commands, missing metadata recovery, explicit restarts, and guardrail recovery.
@t-kalinowski t-kalinowski force-pushed the stack/inherit-sandbox-restart branch from 182a9f0 to 44f3f30 Compare April 22, 2026 19:28
@t-kalinowski t-kalinowski marked this pull request as ready for review April 22, 2026 20:39
@t-kalinowski t-kalinowski merged commit 8aa67cf into main Apr 22, 2026
5 checks passed
@t-kalinowski t-kalinowski deleted the stack/inherit-sandbox-restart branch April 22, 2026 20:39
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