Repository navigation
fix(plugins): keep tool metadata and callbacks on the same factory instance - #139828
Conversation
Assemble schemas, display metadata, preparation, and execution from the same current factory instance. Remove the descriptor cache and its retained-runtime path; use existing registry and record lifecycle authority for both cold and warm callbacks. Preserve recordless SDK registrations and never-activated scoped registries. Reject retained callbacks after retirement, record disablement or removal, and reactivation. Production LOC: -710. Validated 105 tool tests, four real cron preparation cases, the changed-file gate, focused final test types, and independent P2 review.
|
🦞👀 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: blocked before merge. Reviewed September 6, 2026, 3:02 AM ET / 07:02 UTC. ClawSweeper reviewWhat this changesPlugin tools now obtain metadata, argument preparation, and execution from one current factory instance, with retained callbacks rejected after their registry or record loses authority. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, independently landable fix: current main and the latest release retain the metadata mismatch. No introduced correctness defect was found. The prior retirement warning describes an intentional, documented behavior change rather than an unresolved finding. Priority: P2 Review scores
Verification
How this fits togetherPlugin tool assembly combines manifest eligibility, runtime context, and plugin factories into tools presented to agents and MCP clients. Those tools expose schemas and descriptions, then invoke plugin callbacks under their owning registry. flowchart TD
A[Plugin manifests and tool policy] --> C[Tool assembly]
B[Current runtime context] --> C
C --> D[Current plugin factory instance]
D --> E[Tool metadata and schemas]
D --> F[Callback authority check]
F --> G[Prepare arguments or execute]
F --> H[Reject inactive owner]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -710, Tests -319, Docs +2, Other -1. Total -1028 across 9 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt the author-documented generation-bound lifetime and single factory path while preserving valid recordless and independently scoped plugin registrations. Do we have a high-confidence way to reproduce the issue? Yes, from source: resolve a factory twice with changed descriptions or progress metadata while retaining the same cache identity; main reuses the old descriptor with current callbacks. No runtime reproduction was executed in this review. Is this the best way to solve the issue? Yes. Removing the competing descriptor path fixes the producer-level mismatch, and reusing existing lifecycle authority avoids a second ownership mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7feeda9b49ce. 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)
|
|
The retained-handle lifetime is intentional and accepted for this plugin lifecycle redesign. A tool callback belongs to the registry generation and plugin record that created it; after retirement, disablement, removal, or generation replacement, the consumer must assemble fresh tools. Letting an old handle silently select a replacement factory would mix generations again. The documented behavior and current consumers were reviewed alongside the existing lifecycle authority owner. The regression and filesystem proof cover cold/warm callbacks, direct/spread copies, recordless SDK registrations, independently scoped registries, disabled/removed records, and reactivation. Calls already admitted are not cancelled by this slice; Gateway reload and full resource ownership remain in #135599. No arbitrary third-party retention compatibility is claimed. |
|
Merged via squash.
|
Assemble schemas, display metadata, preparation, and execution from the same current factory instance. Remove the descriptor cache and its retained-runtime path; use existing registry and record lifecycle authority for both cold and warm callbacks. Preserve recordless SDK registrations and never-activated scoped registries. Reject retained callbacks after retirement, record disablement or removal, and reactivation. Production LOC: -710. Validated 105 tool tests, four real cron preparation cases, the changed-file gate, focused final test types, and independent P2 review.
What Problem This Solves
Fixes an issue where plugin tools could show stale descriptions, schemas, or progress visibility in later turns even though their callbacks came from the current factory. Tools built on the first resolution also lacked the retirement checks applied by the warm path.
Why This Change Was Made
Tool assembly now uses one current factory instance for metadata, argument preparation, and execution. The descriptor cache and its separate retained-runtime path are removed. Callbacks capture the existing registry/record authority once, preserving recordless SDK registrations and independently scoped registries while rejecting retired or invalidated owners. Production code decreases by 710 lines.
User Impact
Factory-created tools reflect their current context consistently. New calls through retained tool callbacks fail after their owner retires, is disabled or removed, or is reactivated as a new generation.
Evidence
Related: #135599. This is an independently landable foundation for that plugin lifecycle work. The existing callback Proxy limitation around fixed properties remains in that ownership consolidation; this PR does not expand that contract.