Skip to content

Support cancellation during first-turn sandbox initialization #433

Description

@rohanmalhotracodes

Description

When a user cancels the first turn while the sandbox is still initializing, the turn does not cancel promptly because the cancellation signal is not propagated to the sandbox initialization methods.

This is separate from sandbox exec cancellation addressed in #407.

Steps to reproduce

  1. Start a new conversation that requires a sandbox.
  2. Cancel the first turn while the sandbox is still initializing.
  3. Observe that cancellation takes time to complete.

Expected behavior

The cancellation signal should be propagated through the sandbox initialization flow so that cancelling the first turn stops initialization promptly.

Actual behavior

Sandbox initialization does not currently receive the cancellation signal, causing cancellation to be delayed.

Acceptance criteria

  • Pass the cancellation signal to the relevant sandbox initialization methods.
  • Cancelling during first-turn initialization completes promptly.
  • Normal sandbox initialization remains unaffected when no cancellation is requested.
  • Add test coverage for cancellation during initialization.

Activity

  1. rohanmalhotracodes commented on Aug 25, 2026

    @rohanmalhotracodes
    ContributorAuthor

    @thesujai Please take a look at the issue wording and modify as per requirement

  2. mstevens843 commented on Sep 16, 2026

    @mstevens843

    I reproduced this on 7dc87574 and prepared a candidate patch that forwards the turn's AbortSignal into Sandbox and stops the turn from waiting when sandbox creation or initialization is cancelled.

    Candidate branch

    The patch includes 15 sandbox-level regression tests and two route-level tests, including a real loopback HTTP request to the session cancellation endpoint. Coverage includes cancellation during creation and post-create initialization, normal completion, provider errors, listener cleanup, and late completion after cancellation.

    One boundary needs a maintainer decision: this stops the cancelled turn from waiting; it does not stop an already-running provider operation. A late create can leave a provider-side sandbox, and late initialization can still issue commands against an identity subsequently reused by another turn. The shared-identity test observes those calls; it does not establish that their filesystem or credential effects are harmless.

    Would you approve opening a PR with this bounded scope, or should provider cancellation/shared-identity coordination be included before submission? I have not opened a PR, in accordance with the contribution guide. This is separate from #407's exec-cancellation work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions