Repository navigation
Fixes #397: Abort sandbox exec on turn cancellation - #407
rohanmalhotracodes wants to merge 9 commits into
Conversation
🦋 Changeset detectedLatest commit: 1d5b7b9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for your contribution. Can you attach a video that showcases
Please add a before-and-after video by changing the branch in between. |
|
Please also confirm that you have covered all Acceptance Criteria present on #397 Feel free to copy them into this PR description. |
Before Screen.Recording.2026-08-24.at.5.33.37.PM.movAfter Screen.Recording.2026-08-24.at.5.45.34.PM.mov |
There was a problem hiding this comment.
The video you uploaded is not very satisfactory.
For instance - From the video it is not very clear that next turn can be created after the cancellation or not(using the same sandbox, or code mode works etc)
You should test the acceptance criteria mention in the Issue
|
Added coverage for the
I also reran |
|
Just a note: #409 also adds signal to download method |
|
Before Screen.Recording.2026-08-25.at.1.03.35.PM.movAfter Screen.Recording.2026-08-25.at.1.07.47.PM.movScreen.Recording.2026-08-25.at.1.08.14.PM.mov |
|
Thanks for the heads-up. I kept this PR scoped to #397 and only pass the turn abort signal through the sandbox |
|
sorry to bother here can I get more issues assigned please I cannot see help wanted issues as the newer issues have not yet been approved @govindavashishtha @debajyoti-truefoundry, I have got the chat deletion issue merged so I do have time to work on more |
|
Checkout these. For such communication you can join discord - https://github.com/truefoundry/trueforge#talk-to-us |
|
This looks good. |
|
@chiragjn PTAL |
|
I independently reviewed I also ran two isolated local tests using the real provider and UDS transport. They confirmed child-process termination and stopped output after cancellation, a subsequent operation against the same sandbox identity, and a corrupt MCP tools cache triggering a real refetch and repair. Review tests and reproduction notes No issues found within the reviewed scope. These additional checks are at the provider/transport layer, not a complete session/turn lifecycle. I did not run live Daytona/TFY providers. The broader local smoke suite was blocked earlier by an unrelated pip-policy assertion, so I am not claiming that whole suite passed. First-turn initialization cancellation remains the separate question in #433. |
Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Fixes #397
Fixes sandbox turn cancellation so an in-flight sandbox
execcan stop promptly when the turn is cancelled, instead of waiting for the command timeout.sanity check added a video
Screen.Recording.2026-08-22.at.8.07.24.PM.mov
Changes
AbortSignalintoSandboxOptionsandSandboxExecParams.execpath, not init, skills, mkdir, uploads, downloads, or general tool execution.sandbox.stop(timeout, true)and avoid recovery/retry of the cancelled command./execfetch when the turn signal aborts.killExecTreepath without deleting the sandbox root.@truefoundry/trueforge-coreand@truefoundry/trueforge.How was this tested?
git diff --checkpnpm --filter @truefoundry/trueforge-core test -- sandboxBridgeTimeout tfyLayoutpnpm --filter @truefoundry/trueforge-core typecheckpnpm --filter @truefoundry/trueforge typecheckpnpm --filter @truefoundry/trueforge testChecklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedAcceptance Critera
Client cancel during a long sandbox exec ends the turn without a wait for the full exec timeout. This applies to Daytona and Local.
After a Daytona cancel, executeWithSandboxRecovery must not start the sandbox and run the same cancelled command again on DaytonaError.
After a Daytona / Local stop, the next turn can reuse existingSandboxId. The sandbox starts. The filesystem is available. Any commands run successfully.
After a Daytona / Local stop, Code Mode works in the next turn.
After a Daytona / Local stop during Code Mode MCP use, the next turn recovers on-disk state without a hard failure.
If the mcp_client tools cache {server}.tools.json is corrupt or truncated, the client deletes it and refetches over NATS.
freezeTurn with reason cancelled-for-next-turn does not change.
Note
Medium Risk
Changes cancellation and teardown paths across Daytona, TFY, and local sandbox exec; incorrect abort handling could stop sandboxes early or skip legitimate recovery, but scope is limited to turn-cancel on user exec.
Overview
Fixes turn cancellation waiting on long sandbox exec timeouts by threading the turn
AbortSignalfrom the turns API intoSandboxandSandboxExecParams, and stopping work when that signal aborts.The signal is passed only for agent
exectool calls—not sandbox init, skill setup, uploads, or other internalprovider.execpaths. Providers returnSANDBOX_EXEC_ABORTEDinstead of hanging or mis-reporting failures.Daytona registers abort to
sandbox.stop(..., true), skipsexecuteWithSandboxRecoveryretry when the turn was cancelled, and evicts stale SDK cache entries without destroying the remote sandbox id. TFY ties turn abort to the/execfetch (distinct from client timeoutAbortError). Local kills the supervised process tree viakillExecTreeand surfaces abort without removing the sandbox root.onSignalAbortnow returns a cleanup disposer;isSignalAbortedis exported from core. Tests cover signal propagation, TFY fetch abort, Daytona no-retry-on-abort, and local smoke abort behavior.Reviewed by Cursor Bugbot for commit 1d5b7b9. Bugbot is set up for automated code reviews on this repo. Configure here.