Skip to content

fix: retain exec review resources after timeout - #143308

Merged
steipete merged 2 commits into
mainfrom
codex/exec-reviewer-completion-resources
Sep 9, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/exec-reviewer-completion-resources

Conversation

@steipete

@steipete steipete commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #140674

What Problem This Solves

Resolves a problem where exec auto review releases a prepared model before inference and transport cleanup finish. A preparation that completes after the timeout can also escape the caller's lifetime.

Why This Change Was Made

Retain the existing acquired model contract through actual preparation, completion, response callbacks, and cancellation work. Admit the cleanup owner before preparation; separate the caller's result from drainage so late preparation releases without starting inference and existing timeout results stay prompt. This is the exec-reviewer slice of #140674.

The separate preparation and completion budgets, policy checks, prompt construction, parser, and input limits are preserved. Internal test injection follows the acquired contract; no public adapter or compatibility shim is added.

User Impact

Exec review keeps its model and authentication runtime alive until cleanup completes, while preserving existing approval decisions and timeout fallback behavior.

Evidence

Four final native regression cases fail against the original code and pass with the repair: overlap, late preparation, held response callback, and response cancellation. All 293 focused tests passed, including 4,096 seeded malformed responses, concurrency controls, and the fresh completion budget. Changed-file gate coverage, isolated Codex review through P2, and the full build passed. The SDK-removal audit also found and reproduced a stale security-floor test mock. Its acquired-contract migration preserves every assertion; all 26 owning tests, targeted types/lint, and fresh independent review passed.

A plain Node run of the built public exec-review SDK used genuine async provider authentication, actual loopback HTTP, response callbacks, and the configured guarded response body's cancellation. The five-second fallback returned in 5,004 ms for late preparation and 5,008 ms for a held callback. Callback failure returned in 9 ms while cancellation still retained its owner. Strict process cleanup passed in 12.450 seconds; all 12,111 built artifacts remained unchanged. No reviewed command was executed.

These are illustrative local samples, not a speedup benchmark, paid-provider proof, or activation of general registration disposal. Earlier proof-only module-path and ineffective global-fetch instrumentation failures were corrected without weakening production guards; the successful proof delegates through the actual guarded transport.

@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 9, 2026
@steipete
steipete marked this pull request as ready for review September 9, 2026 18:04
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 2:21 PM ET / 18:21 UTC (Revision 2).

ClawSweeper review

What this changes

Keeps exec review’s prepared model resources alive through delayed preparation, inference, and transport cleanup while preserving prompt timeout fallback to human approval.

Merge readiness

✅ Ready for maintainer review

This focused repair remains useful: current main still releases preparation resources before completion finishes. No introduced correctness or security defect was found, and the supplied runtime evidence covers the changed lifecycle.

Priority: P2
Reviewed head: f029c43bbff60944bb88c778bc86a1f993009edc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with relevant production-path observations, meaningful regression coverage, and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured built-SDK observations exercise the changed reviewer owner through real provider authentication and HTTP, showing prompt fallback while preparation, response callbacks, and cancellation remain retained until cleanup settles.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured built-SDK observations exercise the changed reviewer owner through real provider authentication and HTTP, showing prompt fallback while preparation, response callbacks, and cancellation remain retained until cleanup settles.
Evidence reviewed 9 items Introduced lifecycle repair: The pinned merge-base-to-head diff admits a cleanup owner before preparation, tracks completion in its work scope, and releases the acquired model only after drainage. The caller resolves its separate completion signal in finally.
Current main still needs this repair: Fetched main still calls prepareSimpleCompletionModelForAgent and races preparation and completion without this acquired-resource cleanup owner.
Existing acquisition contract: The old preparation wrapper calls release before returning; the existing acquired helper transfers that release obligation to its caller. This PR reuses that contract without adding a public plugin API.
Findings None None.
Security None None.

How this fits together

Exec auto-review evaluates proposed commands using a configured model and returns an approval decision. Its resource owner must outlive pending provider work even when the caller has already received a timeout.

flowchart TD
  A[Proposed command] --> B[Input and policy checks]
  B --> C[Acquire model resources]
  C --> D[Model review]
  C --> E[Timeout or cancellation]
  D --> F[Approval decision]
  E --> F
  C --> G[Drain pending work]
  D --> G
  G --> H[Release resources]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +31, Tests +305, Docs +2. Total +338 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 1 69 38 +31
Tests 4 362 57 +305
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 433 95 +338

Review metrics

Metric Value Why it matters
Lifecycle repair footprint Production net +31 lines; tests net +305 lines Production growth separates prompt caller results from resource drainage; most added coverage exercises the four lifetime boundaries.

Technical review

Best possible solution:

Keep resource release tied to actual provider-work completion while preserving existing approval decisions, cancellation, and independent timeout budgets.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the lifetime mismatch: current main’s preparation wrapper releases before inference, while provider callbacks and cancellation can remain pending. The contributor reports failing-before/passing-after cases; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Reusing the acquired-model contract and existing asynchronous work tracking fixes the owning lifecycle without changing timeout budgets, approval policy, or public plugin APIs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7d31ecce8296.

Labels

Label justifications:

  • P2: This is a bounded exec-review resource-lifetime repair with preserved user-facing approval behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured built-SDK observations exercise the changed reviewer owner through real provider authentication and HTTP, showing prompt fallback while preparation, response callbacks, and cancellation remain retained until cleanup settles.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured built-SDK observations exercise the changed reviewer owner through real provider authentication and HTTP, showing prompt fallback while preparation, response callbacks, and cancellation remain retained until cleanup settles.

Evidence

What I checked:

  • Introduced lifecycle repair: The pinned merge-base-to-head diff admits a cleanup owner before preparation, tracks completion in its work scope, and releases the acquired model only after drainage. The caller resolves its separate completion signal in finally. (src/agents/exec-auto-reviewer.ts:435, f029c43bbff6)
  • Current main still needs this repair: Fetched main still calls prepareSimpleCompletionModelForAgent and races preparation and completion without this acquired-resource cleanup owner. (src/agents/exec-auto-reviewer.ts:399, 7d31ecce8296)
  • Existing acquisition contract: The old preparation wrapper calls release before returning; the existing acquired helper transfers that release obligation to its caller. This PR reuses that contract without adding a public plugin API. (src/agents/simple-completion-runtime.ts:551, f029c43bbff6)
  • Actual transport tails remain observable: Provider lifecycle callbacks and stream cancellation register their pending promises with the transport host; OpenClaw connects that observer to trackAsyncWork. The new reviewer scope therefore includes work that survives the caller-facing result. (packages/ai/src/transports/transport-stream-shared.ts:322, f029c43bbff6)
  • Behavior proof and regression coverage: The captured PR body reports a built public-SDK run with real asynchronous provider authentication and loopback HTTP: late preparation returned fallback in 5,004 ms, a held callback in 5,008 ms, and callback failure in 9 ms while cancellation retained its owner. Cleanup completed in 12.450 seconds. The four added resource cases cover overlap, late preparation, callback tails, and cancellation tails; the body reports original-code failures and repaired passes. These are supplied observations, not reviewer-executed tests. Captured context identity: cd11cb133b70f2e8a65ec2962b5c3e5ca10f3b21c286e5c14738d338a10cb104. (src/agents/exec-auto-reviewer.resources.test.ts:32, f029c43bbff6)
  • Related aggregate delegates this slice: refactor(plugins): release scoped resources after actual work #140674 explicitly remains a draft reference that will not merge and identifies this PR as its separate exec-review replacement. It is not a superseding landing candidate.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • xydt-tanshanshan: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-09T18:13:52.163Z sha f029c43 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit cc81bfa into main Sep 9, 2026
187 checks passed
@steipete
steipete deleted the codex/exec-reviewer-completion-resources branch September 9, 2026 18:35
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 10, 2026
* fix(agents): retain exec reviewer resources through timed-out work

* test: migrate exec security floor to acquired completion
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 16, 2026
* fix(agents): retain exec reviewer resources through timed-out work

* test: migrate exec security floor to acquired completion

(cherry picked from commit cc81bfa)
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 16, 2026
배치 A 체리픽이 이 포크에 없는 중간 리팩터링에 걸린 지점을 포크 코드에 맞춰 정리했다.

- 문자열 이스케이프 복구: attempt-prompt-build.ts, attempt-prompt-context.test.ts
- openclaw#140859: session-accessor.entry-mutation.ts 의 transcript 헤더 import 복원
- openclaw#141247: runs.ts 에서 포크에 없는 projectSessionActive 조건 제거
- openclaw#141471: execute-plugin.test-support.js 가 없어 native-bash 테스트 파일 제거
- openclaw#141960: quickjs-wasi 3.6.0 의 MAX_STACK_SIZE 를 쓸 수 없어 되돌림(포크는 3.5.0 핀)
- openclaw#142130: agents.ts 의 assertCurrent 호출 제거, cleanup-utils 는 선택 인자로 유지
- openclaw#142158: manifest-planner.ts 의 remoteModelIds·manifestModelsById 복원
- openclaw#143308: simple-completion-runtime.ts 에 acquireSimpleCompletionModelForAgent 래퍼 추가
- openclaw#143899: src/infra/file-descriptor.ts 의 fingerprint 비교 헬퍼 이식, backup-shared 의 configCapture 참조 제거

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant