Skip to content

fix: retain image provider state through request cleanup - #143403

Merged
steipete merged 1 commit into
mainfrom
codex/image-description-resources
Sep 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/image-description-resources

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Related: #140674.

What Problem This Solves

Resolves a problem where image requests can close plugin databases while timed-out setup, provider calls, or cleanup are still running. Supplied prepared runtimes also need to retain the original provider and any adopted donor registrations through the request.

Why This Change Was Made

Transfer resource ownership immediately after acquisition, before asynchronous model and auth setup. Keep the existing caller deadlines while tracking the actual setup and provider work separately, then release after cooperating cleanup settles. Supplied managed snapshots retain their exact prepared owner, including donors; raw snapshots retain their existing caller ownership.

Closed managed sources refuse new generic and MiniMax calls, including retries and each image in a MiniMax batch. The private early handoff removes competing failed-setup and late-result release paths. No public SDK fields, configuration, schema, dependency, producer-activation or timeout-policy changes.

User Impact

Image requests keep their existing cancellation and timeout behavior while allowing already accepted work to finish using the correct retained resources. Cleanup closes each owned database once after the final user.

Evidence

Sixteen native SQLite cases cover timeout, cancellation, late rejection, supplied and raw owners, adopted donors, setup descendants, cleanup, and closed-source admission. Original code reproduces five ownership failures with two controls. Review found two further defects in the intermediate implementation—failed setup releasing before its descendants and MiniMax missing per-image closure checks—and both have failing-before, passing-after regressions.

Focused Image, timeout, auth-profile and provider/tool suites pass. Complete affected checks, proportional checks after the final narrow fence change, and fresh full-candidate Codex review through P2 pass. The ordinary build passed in 254.76 seconds; its nonfatal UI gzip warning of 20 bytes over the threshold is recorded, with no UI or budget changes.

The actual compiled public SDK and compiled runtime producer passed together in 6.42 seconds. A successful request took 83.88 milliseconds; the unchanged 1-second timeout reported at 1.004 seconds. After replacement, the original provider and donor databases stayed usable through late work. Closed-source admission was refused, all three fixture databases closed exactly once and reopened with their expected values, and the successor received no calls.

All seven source hashes and 11,683 build artifact hashes stayed unchanged; the plain-Node process and descendants exited. The proof uses synthetic SQLite stores and a valid PNG, without application source fallback, external credentials, a real provider or a production Gateway. Timings are individual correctness observations, not a comparative performance claim.

@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: XL maintainer Maintainer-authored PR labels Sep 9, 2026
@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
@steipete
steipete marked this pull request as ready for review September 9, 2026 21:15
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

Image understanding retains provider resources through unfinished setup, requests, and cleanup while preserving timeout and cancellation reporting.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair absent from fetched main and the latest release. No blocking correctness defect was found, and the previous review’s draft-status blocker is resolved.

Priority: P2
Reviewed head: 2562fa69a385146630d7c24dbb1e1d667392e372

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused ownership repair with meaningful native-resource evidence and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body reports compiled SDK-to-runtime execution with native SQLite providers, demonstrating prompt timeout reporting, usable original resources through late work, closed-source rejection, and exactly-once disposal; this directly exercises the changed resource owner without claiming live provider coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports compiled SDK-to-runtime execution with native SQLite providers, demonstrating prompt timeout reporting, usable original resources through late work, closed-source rejection, and exactly-once disposal; this directly exercises the changed resource owner without claiming live provider coverage.
Evidence reviewed 8 items Operation owns cleanup before setup: The request registers its actual work with the surrounding scope, receives the resource release callback before asynchronous setup, reports results separately, and releases only after pending work and cancellation cleanup drain.
Exact supplied owner and admission fences: Supplied managed snapshots retain their original registry owner, including adopted resources; unmanaged snapshots remain caller-owned. Generic requests, reasoning retries, and each MiniMax image check closure before new provider work. The acquisition callback has one internal production caller and adds no public SDK API.
Behavioral regression coverage: The native SQLite fixture exercises 16 cases covering retained donors, late completion or rejection, setup descendants, raw ownership, cancellation context, and closed-source admission. Assertions check usable databases before final cleanup, exactly-once disposal, persisted values after reopening, and suppressed subsequent provider calls. Tests were inspected, not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

Image understanding turns images and prompts into descriptions through configured model providers. Prepared runtimes supply provider registrations and credentials; their resources must remain usable until accepted work and cleanup finish.

flowchart TD
  A[Images and prompt] --> B[Prepare model runtime]
  B --> C[Retain original provider resources]
  C --> D{Source still open?}
  D -->|Yes| E[Run image provider]
  D -->|No| F[Reject new work]
  E --> G[Report result or timeout]
  E --> H[Drain actual work and release resources]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +49, Tests +851, Docs +7. Total +907 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 270 221 +49
Tests 3 871 20 +851
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 1148 241 +907

Review metrics

Metric Value Why it matters
Ownership repair footprint production net +49 lines; tests net +851 lines Production growth establishes explicit operation custody; most added code exercises native resource lifetime and admission boundaries.

Technical review

Best possible solution:

Keep resource ownership tied to actual image-operation completion while separately reporting deadlines and refusing new work from closed managed sources.

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

Yes, from source: hold provider or setup-descendant work past timeout, then release the supplying managed runtime; current main can release resources before that work settles. This review did not execute the scenario.

Is this the best way to solve the issue?

Yes. The private early handoff and existing async-work owner address the lifetime mismatch without adding public APIs, configuration, storage migrations, or changing timeout budgets.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 30ce57e5e3f7.

Labels

Label justifications:

  • P2: This repairs a bounded image-provider lifecycle failure during timeout, cancellation, or cleanup.
  • 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 body reports compiled SDK-to-runtime execution with native SQLite providers, demonstrating prompt timeout reporting, usable original resources through late work, closed-source rejection, and exactly-once disposal; this directly exercises the changed resource owner without claiming live provider coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports compiled SDK-to-runtime execution with native SQLite providers, demonstrating prompt timeout reporting, usable original resources through late work, closed-source rejection, and exactly-once disposal; this directly exercises the changed resource owner without claiming live provider coverage.

Evidence

What I checked:

  • Operation owns cleanup before setup: The request registers its actual work with the surrounding scope, receives the resource release callback before asynchronous setup, reports results separately, and releases only after pending work and cancellation cleanup drain. (src/media-understanding/image.ts:421, 2562fa69a385)
  • Exact supplied owner and admission fences: Supplied managed snapshots retain their original registry owner, including adopted resources; unmanaged snapshots remain caller-owned. Generic requests, reasoning retries, and each MiniMax image check closure before new provider work. The acquisition callback has one internal production caller and adds no public SDK API. (src/agents/prepared-model-runtime.resources.ts:170, 2562fa69a385)
  • Behavioral regression coverage: The native SQLite fixture exercises 16 cases covering retained donors, late completion or rejection, setup descendants, raw ownership, cancellation context, and closed-source admission. Assertions check usable databases before final cleanup, exactly-once disposal, persisted values after reopening, and suppressed subsequent provider calls. Tests were inspected, not executed during this read-only review. (src/media-understanding/image.resources.test.ts:260, 2562fa69a385)
  • Captured compiled-runtime proof: The supplied PR body, captured under sourceRevision 93b8a7bd1044ab98606650b573db6a3c89b1f305ee2034992df928e87e66e5b4, reports the compiled SDK and runtime producer exercising synthetic native SQLite resources: timeout at 1.004 seconds, original provider and donor usable through late work, closed-source rejection, three databases closed once and reopened successfully, and zero successor calls. This is resource-lifecycle evidence, not a live provider/network claim. (2562fa69a385)
  • Still necessary on main: The three changed production files are unchanged between the pinned merge base and fetched main. Main still transfers release ownership only after setup resolves and releases at the caller-facing boundary, without this operation’s descendant-drain ownership. (src/media-understanding/image.ts:431, 30ce57e5e3f7)
  • Latest release retains earlier behavior: The supplied latest release, v2026.9.3, still assigns releaseRuntime from the resolved setup result and invokes it at the earlier request boundary. (src/media-understanding/image.ts:574, 1391f7cd2d40)

Likely related people:

  • Peter Steinberger: Raw commit 73b4086 adds src/agents/prepared-model-runtime.resources.ts:51 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 73b4086ff658; files: src/agents/prepared-model-runtime.resources.ts)

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-09T21:14:01.883Z sha 2562fa6 :: needs changes before merge. :: none

@steipete
steipete merged commit 8103c44 into main Sep 9, 2026
252 checks passed
@steipete
steipete deleted the codex/image-description-resources branch September 9, 2026 21:48
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 9, 2026
Compose current main resource ownership with admitted image selection and caller-projected configuration. Transfer resources before setup, drain actual provider work before release, and retain exact identities and regional MiniMax routing throughout requests.

Related: #130706, #142100, #143403
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 10, 2026
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: XL 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