fix: Propagate turn abort to in-flight tool calls and sandbox exec - #835
bhaveshpatel640 wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 3aa6e42 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dd68970. Configure here.
| cancelled = true; | ||
| killExecTree(child); | ||
| }; | ||
| signal?.addEventListener('abort', onAbort, { once: true }); |
There was a problem hiding this comment.
Abort can miss spawned sandbox process
Medium Severity
Local sandbox cancel can miss the child. The abort listener is attached only after wrapWithSandboxArgv, spawn, and optional stdin writes, and an already-aborted signal does not invoke a new abort listener. Cancel during that window leaves the process running until the exec timeout.
Reviewed by Cursor Bugbot for commit dd68970. Configure here.
| if (signal?.aborted) { | ||
| return 'exit'; | ||
| } | ||
|
|
There was a problem hiding this comment.
Cancel drops completed sub-agent tools
Medium Severity
When the turn signal is aborted after executeToolCalls, stepToolResponse persists regular tool results and then returns exit before yielding createThreadEvents. A completed create-sub-agent call in that batch never creates the child thread and never gets a matching tool result, so the stored turn context can contain an unmatched tool_call.
Reviewed by Cursor Bugbot for commit dd68970. Configure here.


Summary
fix: Propagate turn abort to in-flight tool calls and sandbox exec
Closes AGE-2252
Changes
How was this tested?
Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,python/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 changedNote
Medium Risk
Changes agent turn lifecycle and sandbox/process teardown on cancel; behavior is scoped to cancellation but touches core tool execution and both sandbox providers.
Overview
When a user cancels a turn, in-flight work now stops instead of running until timeout. An optional
AbortSignalis threaded fromAgentThread.executethroughexecuteToolCallsandIToolSet.callTool(including local tools andToolSetwrappers).Sandbox
execforwards the same signal into providerexeccalls (init, git credentials, and the agent command). TFY merges the turn signal with the client timeout viaAbortSignal.anyand surfacesCancelled; the local SRT supervisor kills the sandbox process tree on abort and reportsCancelled.After tools finish under abort, the thread skips tool-response processors, still records tool results where applicable, and exits the turn without continuing the agent loop. Unit tests cover
executeToolCallssignal passthrough and TFY exec cancellation.Reviewed by Cursor Bugbot for commit 3aa6e42. Bugbot is set up for automated code reviews on this repo. Configure here.