Skip to content

fix(agents): keep accepted image jobs alive through provider cleanup - #142991

Merged
steipete merged 2 commits into
mainfrom
codex/prepared-image-job-resources
Sep 9, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/prepared-image-job-resources

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Related: #140674

What Problem This Solves

Fixes an issue where an accepted image_generate job could lose its plugin resources after returning started, while generation, image persistence, or rollback was still running. Preparing tools and checking remote image references could also outlive the original provider registration.

Why This Change Was Made

Carry the original inspection's resource ownership through prepared facts, preflight, and the actual accepted job. A retired source cannot admit a new task, while an already accepted task retains its captured providers until work and cleanup finish. Shared capability acquisition now exposes the same existing ownership operation for this longer lifetime.

Existing execution and image-geometry helpers move into an execution module to keep the tool readable; their behavior is unchanged. The oversized-file exception is removed. Raw prepared registries retain their host-owned lifetime; this does not enable general prepared-cache disposal.

User Impact

Background image generation keeps working after its originating preparation is released. A source retired during preflight produces a retryable setup failure before task admission. started remains an immediate acceptance result, and completed media remains available after provider cleanup.

Evidence

  • Native before/after regressions cover queued generation, saving, rollback, retirement during a held HTTP preflight, and retirement during actual preparation.
  • Focused resource, runtime, policy, background-task and Cron suites passed. The full changed-file gate and independent Codex review through P2 passed; ordinary build completed in 219 seconds.
  • The built public agent-harness SDK accepted a synthetic SQLite-backed image job in 16.6 ms. After source A retired and B was published, A persisted a real PNG and closed exactly once; B was never invoked. A separate held HTTP preflight rejected admission after retirement. Native SQLite reopening succeeded.
  • The probe used source-produced prepared facts with the built SDK, not a fully packaged CLI. With no delivery runtime attached, the durable task reached its existing blocked-delivery state with media retained; real channel delivery was not tested.
  • Rebased production files are byte-identical to the reviewed and built candidate. Focused composition verification covers the subsequently landed Video and inventory consumers.

@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 labels Sep 9, 2026
@steipete
steipete marked this pull request as ready for review September 9, 2026 09:06
@openclaw-barnacle openclaw-barnacle Bot added size: XL maintainer Maintainer-authored PR labels Sep 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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, 5:37 AM ET / 09:37 UTC.

ClawSweeper review

What this changes

Retains image-provider resources through preparation, reference loading, accepted generation, saving, and rollback, while rejecting new jobs after provider retirement.

Merge readiness

✅ Ready for maintainer review

This remains a useful follow-up to the merged image-runtime ownership fix, which explicitly excluded prepared tools and detached jobs. No blocking correctness defect was found.

Priority: P2
Reviewed head: bda45b23f48aeb20bb7ec12cde185b05e64890ce

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent ownership repair with meaningful native-resource coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts this PR from the external-contributor proof gate. Its reported built-SDK probe exercises the changed prepared-provider and background-job owners through retirement, PNG persistence, and disposal; packaged CLI and live delivery were explicitly outside that probe.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER classification exempts this PR from the external-contributor proof gate. Its reported built-SDK probe exercises the changed prepared-provider and background-job owners through retirement, PNG persistence, and disposal; packaged CLI and live delivery were explicitly outside that probe.
Evidence reviewed 9 items Verified introduced scope: Reviewed the merge-base-to-head changes, including the execution-helper extraction, prepared registry ownership, shared acquisition wrapper, background handoff, tests, and documentation. Base-only changes were excluded. The whitespace check passed.
Admission and ownership transfer: The tool rechecks cancellation and source retirement after awaited preflight, releases on preflight failure or duplicate results, and transfers the acquired resources to the accepted task.
Actual-work cleanup boundary: The background owner releases resources after generation and persistence settle, including failure cleanup; admission or scheduling failures release claims before transfer. Existing callback-shaped capability consumers retain their wrapper and shared work-draining behavior.
Findings None None.
Security None None.

How this fits together

The image-generation tool turns agent requests into foreground or background provider jobs. Prepared plugin resources must remain available until those jobs finish producing and saving their images, after which completion flows into the existing task-delivery system.

flowchart TD
  A[Agent image request] --> B[Capture provider resources]
  B --> C[Load references and validate]
  C --> D{Source still current?}
  D -->|No| E[Release and report retryable error]
  D -->|Yes| F[Accept image job]
  F --> G[Generate and save or roll back]
  G --> H[Release resources and report completion]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +467, Tests +499, Docs +10, Other -1. Total +975 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 12 1136 669 +467
Tests 5 506 7 +499
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 19 1652 677 +975

Review metrics

Metric Value Why it matters
Ownership implementation growth Production net +467 lines; tests net +499 lines The stated justification is explicit resource custody across preparation and detached completion, with native-resource regressions covering the lifetime boundaries.

Root-cause cluster

Relationship: canonical
Canonical: #142991
Summary: This is the focused prepared-image-job ownership slice; the broader draft is reference context and the merged runtime fix covers a different lifetime boundary.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep provider resource ownership with the actual image job through final cleanup, while preserving the separate admission boundary and existing raw-host lifetime.

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

Yes, from source: release an owned inspection after its image tool returns started while the job remains queued or saving; current main carries provider callbacks without the corresponding resource claim. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. The patch repairs the producer-to-job ownership handoff, reuses existing acquisition and persistence boundaries, and preserves the established independence of accepted jobs from caller cancellation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 96006252820e.

Labels

Label changes:

  • add P2: Repairs a bounded image-generation resource-lifetime failure without changing configuration, provider policy, or persistent schemas.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER classification exempts this PR from the external-contributor proof gate. Its reported built-SDK probe exercises the changed prepared-provider and background-job owners through retirement, PNG persistence, and disposal; packaged CLI and live delivery were explicitly outside that probe.

Label justifications:

  • P2: Repairs a bounded image-generation resource-lifetime failure without changing configuration, provider policy, or persistent schemas.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER classification exempts this PR from the external-contributor proof gate. Its reported built-SDK probe exercises the changed prepared-provider and background-job owners through retirement, PNG persistence, and disposal; packaged CLI and live delivery were explicitly outside that probe.

Evidence

What I checked:

  • Verified introduced scope: Reviewed the merge-base-to-head changes, including the execution-helper extraction, prepared registry ownership, shared acquisition wrapper, background handoff, tests, and documentation. Base-only changes were excluded. The whitespace check passed. (bda45b23f48a)
  • Admission and ownership transfer: The tool rechecks cancellation and source retirement after awaited preflight, releases on preflight failure or duplicate results, and transfers the acquired resources to the accepted task. (src/agents/tools/image-generate-tool.ts:688, bda45b23f48a)
  • Actual-work cleanup boundary: The background owner releases resources after generation and persistence settle, including failure cleanup; admission or scheduling failures release claims before transfer. Existing callback-shaped capability consumers retain their wrapper and shared work-draining behavior. (src/agents/tools/media-generate-background.ts:51, bda45b23f48a)
  • Native resource regressions: Inspected tests exercise real SQLite-backed plugin registrations and media files while holding preflight, queued execution, saving, and rollback. Assertions verify no retired-source admission, no successor-provider invocation, retained resources during work, and exactly-once disposal. Tests were not executed during this read-only review. (src/agents/tools/image-generate-tool.resources.test.ts:174, bda45b23f48a)
  • Earlier merged fix leaves this work distinct: GitHub confirms fix(image): close registration resources after generation #142843 merged as 1ab71b8. Its body explicitly limits that fix to default runtime acquisition and leaves prepared provider arrays and detached background jobs as separate work. (1ab71b84dc29)
  • Current main and release comparison: Inspected current main at 9600625 and the supplied latest release, v2026.9.3. Both still use the prepared-provider array and task invocation without this resource transfer; the central fix is not already present. (src/agents/tools/image-generate-tool.ts:901, 1391f7cd2d40)

Likely related people:

  • Peter Steinberger: Raw commit 6f2bce0 adds src/plugins/capability-provider-acquisition.ts:2 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6f2bce0aa92b; files: src/plugins/capability-provider-acquisition.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.

@steipete
steipete merged commit b07d30a into main Sep 9, 2026
301 of 303 checks passed
@steipete
steipete deleted the codex/prepared-image-job-resources branch September 9, 2026 10:31
@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
…penclaw#142991)

* fix(agents): retain prepared image resources through job completion

* test(agents): assert prepared loader inputs independently of callbacks
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. 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