Skip to content

fix(media): inspect generated images with workspace-only tools - #197812

Merged
roboclaw-bot merged 4 commits into
openclaw:mainfrom
Alexi5000:fix/197767-workspaceonly-load-own-generated-images
Nov 14, 2026
Merged

roboclaw-bot merged 4 commits into
openclaw:mainfrom
Alexi5000:fix/197767-workspaceonly-load-own-generated-images

Conversation

@Alexi5000

@Alexi5000 Alexi5000 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #197767

What Problem This Solves

Fixes: an agent can generate an image but receive no image input to inspect its result when the generation completes.

User Impact

Successful image-generation completions provide their exact generated images to the follow-up agent turn, including with tools.fs.workspaceOnly enabled. Input admission stays separate from existing output-delivery bookkeeping, so inspection does not resend the generated files. Arbitrary prompt paths to unrelated media-store files remain outside workspace-only native discovery. No permission or configuration migration.

Why This Change Was Made

The original proposal widened native prompt discovery to the entire Gateway media directory. This revision preserves that boundary: the generation owner binds the completion to its requester and admits only its successful output descriptor list through existing Gateway input-attachment admission. Unavailable image input produces explicit guidance not to claim inspection.

Original report and proposed fix by @Alexi5000. Scoped takeover and repair requested by @vincentkoc. Original contributor commit a7c83e8a09637dd343c1916ad0022ceeecd9d33e remains in the branch ancestry; its global-root exception is not retained.

Work sessions

Linked for team reference; these sessions aren’t public.

Evidence

  • Actual GitHub PR comparison repaired in place: before the update GitHub reported 1,839 files, +82,952/−22,900, base 7b75336…, head 9a56b52…. After the normal merge/push, the PR metadata and complete PR files endpoint both report six files, +141/−1, base 6b8bdec8314fee0db128b9be15f021f116ea1584, head 448a1dfd014f82ee0f973fb801397217f29dc936. This was verified against the actual PR view/API, not inferred from a local three-dot diff.
  • Merge parents are 9a56b52fea3a52e2f607eeac346ac8b4e688e4f2 and verified main 6b8bdec…. This integration was specifically to repair the broken PR comparison, not merely for main freshness. No force-push, rebase, closure, or replacement PR. The merge carries Vincent’s required coauthor credit and preserves original contributor ancestry.
  • Production repair is unchanged: the three producer/dispatch repair modules are byte-identical to the previously reviewed/tested 9a56b52…. The conflict-free auto-merge keeps main’s removal of the retired findDuplicate test-fixture property. Native image-discovery code remains unchanged; no second media-admission owner was introduced.
  • Fresh post-merge validation: all 123 affected tests pass, 78.33 seconds total wrapper wall time. Targeted source/test types, scoped five-file lint, six-file formatting, and staged/working-tree whitespace checks pass. Earlier unchanged proof was reused rather than replaying unrelated suites.
  • Fresh resolution review: complete six-file AutoReview against pinned main 6b8bdec…, P0–P2, completed scoped-clean with no actionable findings. It confirmed the scoped attachment repair and separate outbound bookkeeping; it did not independently certify remote PR comparison statistics. Those were separately read back from GitHub after push.
  • Qualified real-product producer-input proof: the parent verified an isolated real Gateway and actual model receiving the exact private PNG input in combined integration candidate 943a6da6f110c46d17fb6d5f60bf7c24a742b87c. This is qualified producer-input integration evidence, not a newly executed live run on 448a1df…, and does not itself claim full combined delivery success. The separate review-release/delivery work is tracked in feat: let agents review generated images before delivery #198227.
  • Current-head CI and security: run 43566913255, attempt 2 completed successfully for 448a1dfd014f82ee0f973fb801397217f29dc936, including security-fast and openclaw/ci-gate. The current security-sensitive guard is cleared and the combined commit status reports success; the revised six-file comparison has no sensitive-product-change approval requirement.
  • Retained prior evidence: the stored-image regression was red on base 91046f7… and green with the repair while an unrelated image in the same generation directory remained rejected. Producer tests exclude paths from completion text/arbitrary media URLs. The earlier 169-test run and successful CI 43396504892 belong to prior head 9a56b52…, not the new merge head.

The coordinator released this independent producer-input repair after its integration proof and current-head gates qualified. Native maintainer landing retains exact-head, review, contributor-ancestry and current GitHub enforcement checks. No native filesystem-discovery permission is widened.

Focused post-merge command:

node scripts/run-vitest.mjs src/agents/tools/media-generate-background.test.ts src/agents/subagents/announce/subagent-announce-delivery.test.ts --maxWorkers=1

…ages

With tools.fs.workspaceOnly, native image loading restricted localRoots to
[workspaceDir], so images written to <stateDir>/media/tool-image-generation/
were rejected. Add getMediaDir() to the host allowlist, consistent with the
outbound media rule.

Fixes openclaw#197767
@clawsweeper

clawsweeper Bot commented Nov 12, 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 agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR lets non-sandboxed workspaceOnly agents automatically load images anywhere in the Gateway media directory.

Example: An agent with workspace /srv/openclaw/workspace receives a generated-image path /srv/openclaw/media/tool-image-generation/poster.png.

  • Before: Native prompt loading rejects the generated image because it is outside the workspace.
  • After: Native prompt loading accepts it, along with other images anywhere under /srv/openclaw/media.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch targets a real workflow failure, but broadens an intentional access boundary and has no supplied runtime proof or added regression.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: An agent can generate and deliver an image but miss the image input needed to inspect its result.
Reason: Reliable generated-image inspection has clear value, but this implementation changes the documented native-loading permission contract rather than limiting access to the completion’s admitted images.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this PR addresses a source-confirmed problem, but its global media-root exception also admits unrelated images through a deliberately restricted native-loading path.

Priority: P2
Reviewed head: a7c83e8a09637dd343c1916ad0022ceeecd9d33e
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should native prompt discovery gain Gateway-wide media access, or should generated completion images use the existing admitted-attachment contract?
  • Recommendation: Preserve discovery containment: Have the contributor repair the generated-completion attachment handoff using the existing admission path.
  • Why: The requested inspection workflow is useful, but documentation and prior merged work deliberately distinguish native discovery from explicit media-tool access, and no maintainer has approved changing that boundary here.

Before merge

  • Add real behavior proof - The complete PR body and comments contain no after-fix runtime output or linked artifact exercising generated-image inspection through a Gateway and model; the linked issue supplies a before-fix report only. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Keep unrelated media outside native prompt discovery (P1) - This fallback also handles arbitrary paths discovered in prompt text, with attachment=false. For example, a non-sandboxed workspaceOnly agent whose explicit image tools are denied can receive Inspect /srv/openclaw/media/tool-image-generation/other-session.png; the new root lets the loader read that unrelated existing PNG and send its bytes to the model. Previously the workspace-only root rejected it. Neither the generated-image directory nor this branch checks that the image belongs to the current completion. Preserve the discovered-path boundary and carry the intended generated images through the existing admitted-attachment path instead.
  • Resolve security concern: Implicit reads bypass explicit media-tool policy - The principal is a chat sender able to supply an existing media path; prompt preparation performs the read before model execution, so denying view_image does not prevent the newly admitted read.

Findings

  • [P1] Keep unrelated media outside native prompt discovery — src/agents/embedded-agent-runner/run/images.ts:233
  • [medium] Implicit reads bypass explicit media-tool policy — src/agents/embedded-agent-runner/run/images.ts:233

Tests

  • Missing end-to-end proof: Provide redacted Gateway/model output showing generated-image inspection with workspaceOnly and a profile-specific state directory after the repair, plus a regression shown failing on the base and passing on the head.
Agent review details

How this fits together

The embedded runner discovers image paths in prompt text and hydrates admitted attachment facts, reads their bytes through media access controls, and supplies image blocks to the model provider.

flowchart LR
  A[Image generation] --> B[Gateway media store]
  A --> C[Completion event]
  C --> D[Prompt image loader]
  E[Prompt text paths] --> D
  D --> F[Local media access]
  B --> F
  F --> G[Model provider input]
Loading

Technical review

Best possible solution:

Carry the completion’s generated images through the existing admitted-attachment owner while keeping arbitrary prompt-discovered paths confined to the workspace.

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

Current-main source confirms that a non-admitted generated-image path outside the workspace is rejected when workspaceOnly is enabled; the linked report names an affected official version, but no runtime reproduction was executed during this review.

Is this the best way to solve the issue?

The one-line change reaches the reported host-loading case, but broadens permission beyond the requested generated-session images; the existing attachment handoff is the narrower repair boundary.

Full review comments:

  • [P1] Keep unrelated media outside native prompt discovery — src/agents/embedded-agent-runner/run/images.ts:233
    This fallback also handles arbitrary paths discovered in prompt text, with attachment=false. For example, a non-sandboxed workspaceOnly agent whose explicit image tools are denied can receive Inspect /srv/openclaw/media/tool-image-generation/other-session.png; the new root lets the loader read that unrelated existing PNG and send its bytes to the model. Previously the workspace-only root rejected it. Neither the generated-image directory nor this branch checks that the image belongs to the current completion. Preserve the discovered-path boundary and carry the intended generated images through the existing admitted-attachment path instead.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native workspaceOnly image loading changes intended behavior with a stated reason (370d115: Explicitly enforce workspaceOnly for native prompt image autoload; the later 161f76d performance refactor retained that boundary.)
  • Admitted managed images versus discovered paths changes intended behavior with a stated reason (fix: sandboxed turns lose managed image attachments #195992: Restore admitted managed attachments across sandboxed attempts while retaining containment for paths written in prompt text.)

Testing

Proof path: none.

Security

Needs attention: The added root bypasses the documented workspace restriction for unadmitted images referenced in prompt text.

Evidence

Security concerns:

  • [medium] Implicit reads bypass explicit media-tool policy — src/agents/embedded-agent-runner/run/images.ts:233
    The principal is a chat sender able to supply an existing media path; prompt preparation performs the read before model execution, so denying view_image does not prevent the newly admitted read.
    Confidence: 0.98

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit cbe182f adds src/agents/embedded-agent-runner/run/images.ts:183 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cbe182f49c4c; files: src/agents/embedded-agent-runner/run/images.ts)

PR surface

Source 0. Total 0 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 1 0

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Generated-image inspection fails under an advanced filesystem restriction, while generation and outbound delivery remain available.
  • merge-risk: 🚨 security-boundary: A prompt-supplied path can newly load an unrelated generated image outside the workspace without attachment admission or an explicit media-tool call.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 12, 2026, 11:11 AM ET / 16:11 UTC.

roboclaw-bot and others added 2 commits November 13, 2026 08:50
Admit the successful producer-owned image outputs through the existing completion-turn attachment path instead of widening workspace-only native image discovery. Preserve host delivery bookkeeping so inspection does not resend generated media.

Related: openclaw#197767

Co-authored-by: vincentkoc <[email protected]>
…spection

Preserve Alexi5000 original PR ancestry and issue credit. The original global media-root exception is superseded by the producer-owned completion attachment repair; the reviewed and tested candidate tree is unchanged.

Co-authored-by: vincentkoc <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes security Security documentation labels Nov 13, 2026
@roboclaw-bot roboclaw-bot changed the title fix(media): allow workspaceOnly agents to load their own generated images fix(media): inspect generated images with workspace-only tools Nov 13, 2026
roboclaw-bot added a commit that referenced this pull request Nov 13, 2026
Integrate only the named landed dependency c4f355b. Resolve the four repeated identity overlaps using the already-reviewed feature bytes, retaining both duplicate predicates, delivery-mode identity, bounded discovery and the coherent identity test extraction. Producer #197812 remains outside this branch pending its required approval.

Co-authored-by: vincentkoc <[email protected]>
Merge verified main 6b8bdec to repair the actual GitHub PR197812 view showing 1839 unrelated files. Preserve the original contributor ancestry and the scoped producer-owned image attachment repair. Production repair modules remain byte-identical; the auto-merged fixture retains main's removal of findDuplicate.

Affected 123 tests, targeted types, lint, format, and fresh six-file AutoReview P0-P2 passed. This is comparison repair, not a main-freshness update or landing.

Co-authored-by: vincentkoc <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot removed channel: discord Channel integration: discord channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes security Security documentation scripts Repository scripts commands Command implementations docker Docker and sandbox tooling extensions: anthropic extensions: qa-lab extensions: memory-wiki extensions: codex plugin: file-transfer extensions: oc-path extensions: google extensions: openrouter labels Nov 14, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

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 merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: with tools.fs.workspaceOnly the agent cannot load its own generated images (tool-image-generation outside workspace)

2 participants