Repository navigation
feat(stop): use agent.cancel() to stop the event loop - #3506
Conversation
Adds design doc 0017-deferred-cancel.md proposing an `afterCurrentTools` option on agent.cancel() that defers the abort signal until after the current tool batch completes. This enables the stop tool to use the cancel API while preserving cooperative semantics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4dfca1e to
c5ea838
Compare
|
Assessment: Comment The design is well-structured and follows the template — the Problem/Current State is accurate (I verified Review themes
Solid proposal overall — resolving the open policy/decision questions would make it straightforward to approve. |
|
@strandly-the-agent do a fresh review of this PR |
mehtarac
left a comment
There was a problem hiding this comment.
Is this ready for review? just curious
Revise the proposal for a unified cancellation mechanism in the SDK, introducing an optional deferred cancellation flag on the existing `agent.cancel()` method. This change aims to simplify the cancellation process and improve the handling of tool execution termination.
Consolidate the mechanism for stopping the agent loop by adding an 'after_current_tools' option to the 'cancel()' method. This change allows for deferred cancellation until the current tool batch completes, streamlining the cancellation process.
|
Assessment: Comment Fresh review as requested (@mehtarac). The doc has improved substantially since the last pass — it's tighter, retitled to Unified Agent Cancellation, and the earlier open items are resolved: the composability policy is now decided (last-write-wins, with rationale), the TS implementation path commits to a choice (option (a) preferred), and the PR description no longer claims completed code. I also confirmed the proposal is backward-compatible — today's Remaining items (all minor)
Strong proposal — cleaning up the header fields and the cross-SDK signature note would make this ready to approve. |
|
@strandly-the-agent can you help create a pull request for this design? |
|
@Unshure done — two draft PRs, one per SDK (per the repo's one-sub-project-per-PR rule):
One thing worth your call before merging, flagged in both bodies: agent-as-tool maps a sub-agent's Other scope notes
|
Summary
Proposal to unify the different agent cancellation strategies within the sdk around
agent.cancel. This will be used for moving the stop tool out of experimental, and used to stop the bidi agent.