Repository navigation
fix(cli): retain local model resources through completion cleanup - #143302
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, 1:57 PM ET / 17:57 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR keeps local CLI model resources alive through response processing and callback or cancellation cleanup, with regression coverage for overlapping commands. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still releases preparation resources before completion. No blocking correctness defect was found, and the related aggregate is a draft reference rather than a replacement landing path. Priority: P2 Review scores
Verification
How this fits togetherLocal model commands resolve an agent’s configured model and credentials, then send a one-shot provider request. Prepared runtime resources must remain available until both the response and its asynchronous cleanup finish. flowchart TD
A[Local model command] --> B[Acquire prepared model resources]
B --> C[Send provider request]
C --> D[Return output or error]
C --> E[Drain callbacks and cancellation]
E --> F[Release model resources]
G[CLI invocation cleanup] --> E
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +23, Tests +298. Total +321 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep lease ownership at the local command boundary and let the existing invocation owner join cleanup without delaying the command’s result. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the premature release: main’s preparation helper releases its acquired lease before the local command sends its request. The supplied regressions exercise the resulting lifetime gaps; this review did not run them. Is this the best way to solve the issue? Yes. Reusing the existing acquired-model contract and asynchronous work owner repairs the caller’s lifetime boundary without changing public APIs, configuration, or provider selection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4fce9c9e6e33. 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
Local model commands release their prepared model generation before sending the request. Overlapping commands can rebuild the same catalog, and callback or response-cancellation work can outlive the command result without retaining that generation.
Why This Change Was Made
The local command uses the existing acquired model contract and admits its cleanup owner before preparation. It retains the lease through completion interpretation and actual callback/cancellation drainage. The existing command runtime owns that drainage independently of when the result becomes available.
User Impact
Local model commands reuse their active prepared generation and finish cleanup before its final release. Existing output, errors, model/profile selection, unsupported-runtime handling and Gateway behavior remain unchanged.
Evidence