Repository navigation
fix(plugins): preserve tool identity during managed cancellation - #143305
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 2:03 PM ET / 18:03 UTC (Revision 2). ClawSweeper reviewWhat this changesPreserves plugin identity and abort reasons during managed tool cancellation, shares cancellation handling with MCP requests, and adds lifecycle regression coverage and documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still forwards cancellation without preserving the executing tool’s context. No actionable introduced defect was found, and the merged MCP parent explicitly leaves this behavior for a follow-up. Priority: P2 Review scores
Verification
How this fits togetherPlugin tools execute requests from agents and MCP clients under a plugin-specific runtime context. Managed work scopes retain their background work through cancellation and cleanup while allowing results to return early. flowchart TD
A[Agent or MCP request] --> B[Check live plugin registration]
B --> C[Execute in plugin context]
C --> D[Return tool result]
C --> E[Track background work]
F[Request cancellation or owner shutdown] --> G[Restore captured cancellation context]
G --> E
E --> H[Finish cleanup and remove listeners]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +26, Tests +150, Docs +9. Total +185 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one cancellation owner that restores the executing plugin’s context, preserves early results, and retains cleanup without renewing execution authority. Do we have a high-confidence way to reproduce the issue? Yes, from source: execute a managed plugin tool, retain a cancellation listener after its early result, then abort from another plugin’s context. Current main forwards the original signal without restoring the executing context; this review did not run the reproduction. Is this the best way to solve the issue? Yes. Moving the existing MCP cancellation owner into a shared helper and invoking it inside the checked plugin scope fixes the producer boundary without adding a public API or configuration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fa914c52f128. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Related: #140674
What Problem This Solves
A plugin tool's cancellation callback can run under the context that dispatched cancellation instead of the plugin that started the work. This can misidentify the caller of nested runtime operations, including when MCP relays cancellation while accepted work is still draining.
Why This Change Was Made
The existing MCP cancellation owner moves into a small shared work helper. Signal-bearing managed plugin calls capture their context after the existing registration-authority check. The direct result remains independent of actual descendant cleanup, and the original abort reason is preserved.
User Impact
Managed tool cancellation retains the executing plugin's identity through its existing work owner. Retired authority still refuses new invocation; raw and no-signal callers preserve their existing context behavior. No public API or registry resource manager is added.
Evidence