Repository navigation
fix(media): let media tools read agent-rendered files outside default roots - #289
Merged
Merged
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
✅ Approved
Resolves ENG-21228 and Sentry OPENCLAW-FLEET-XM by aligning media tools (image, pdf, image_generate, video_generate, music_generate) with the outbound MEDIA: send path, allowing them to read agent-rendered files (e.g., under /tmp) when host-level read is permitted.
Strengths
- Parity with outbound media access: Fixes the asymmetry where
MEDIA:/tmp/x.pngsucceeded butimage(/tmp/x.png)failed, directly mitigating recurring Sentry errors on agent plan/diagram generation. - Strict policy containment:
rootExpansionAllowedis gated on!fsWorkspaceOnly && isToolAllowedByPolicies("read", layeredToolPolicies), checking all 11 policy layers (group, sender, sandbox, subagent, inherited).workspaceOnlyremains authoritative and strictly fails closed. - Symlink & traversal safety: Traversal protection remains anchored in realpath checks via
assertLocalMediaAllowed, backed by explicit test coverage. - Graceful error classification: Converts raw uncaught exceptions into structured
{ status: "denied", details: { error: "media_path_not_allowed", status: "denied" } }responses, preventing Sentry host defect alerts while giving the agent clear guidance to copy to the workspace and retry.
Technical Verification
- ✅ Test execution: Verified locally with
node scripts/run-vitest.mjsacrossmedia-tool-shared.test.ts,image-tool.test.ts,pdf-tool.test.ts, andlocal-media-access.test.ts(150/150 tests passing). - ✅ Static analysis: Zero import cycles (
check-import-cycles.ts) and zero oxlint violations. - ✅ CI checks: All GitHub Actions check runs are passing green.
- ✅ Prior feedback addressed: Thoroughly handled bot review feedback in commit
6266124542607633b5c70f44e6162191c0ef26e3.
LGTM!
orswn
approved these changes
Oct 14, 2026
… roots Agent scripts that render crops/pages into /tmp (pdf2image, matplotlib, etc.) and then hand that path to a media tool were blocked with "Local media path is not under an allowed directory", even though the same path already sends fine through MEDIA:. The outbound send path widens its allowlist to a referenced file's own directory when the agent is permitted host reads outside its workspace (getAgentScopedMediaLocalRootsForSources); the media tools (image, pdf, image_generate, video_generate, music_generate) never did the same, silently discarding the media source they were given (resolveMediaToolLocalRoots's third parameter was literally `_mediaSources`). Carry the already-resolved fs policy decision forward as a prepared `rootExpansionAllowed` fact on ToolFsPolicy, computed once in createOpenClawCodingTools (agent-tools.ts) where workspaceOnly and the memory- flush trigger are both known, and thread it through the five media tools' local-roots resolution. Reuses the existing appendLocalMediaParentRoots helper, so traversal/symlink containment checks in assertLocalMediaAllowed are unaffected. Agents that are workspaceOnly, or whose policy denies read, are unchanged. Also: a blocked media path was thrown as a raw error and classified "upstream" by classifyToolCallErrorKind, paging Sentry as a host defect (OPENCLAW-FLEET-XM). image and pdf now catch the path-not-allowed case and return a `denied` tool result the model can act on instead, same pattern as the existing image-too-large handling. Fixes ENG-21228. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…licy Address cubic review feedback on PR #289: - rootExpansionAllowed was computed from resolveEffectiveToolFsRootExpansionAllowed, which only checks profile/global/agent policy. It missed group/sender/sandbox/subagent/ inherited policies that applyToolPolicyPipeline also applies, so a policy layer denying `read` could still leave media tools able to widen past the workspace. Now checks isToolAllowedByPolicies("read", ...) against the same full layered policy list already used for allowBackground, extracted as a shared `layeredToolPolicies` array. - The graceful media-path denial result used details.denied, which is reserved in this codebase for inline gateway exec approval denials (where `status` is already overloaded by exit-code semantics). Switched to `status: "denied"`, which classifyToolCallErrorKind already reads directly. - Doc fix: list the state canvas/workspace/sandboxes directories explicitly in the local-roots description. Co-Authored-By: Claude Sonnet 5 <[email protected]>
convyusboy
force-pushed
the
ridho/eng-21228-media-tmp-media-access
branch
from
October 14, 2026 11:10
6266124 to
9afb9de
Compare
convyusboy
added a commit
that referenced
this pull request
Oct 15, 2026
Cut the fork release that ships the six commits on boon since v2026.6.34-boon.7: - #292 (ENG-21407): resolve relative media/PDF paths against the agent workspace in pdf, image_generate, video_generate, and music_generate, instead of the gateway process cwd; delete the image tool's duplicate inline resolution now that the loader owns it canonically. - #289 (ENG-21228): let image, pdf, image_generate, video_generate, and music_generate read agent-rendered files outside the default roots (e.g. /tmp crops) when the agent is permitted host reads outside its workspace, matching the outbound MEDIA: path; a blocked path now returns a denied tool result instead of a raw error that paged Sentry. - #293 (ENG-21406): raise the image tool's default vision timeout 60s -> 150s (above boon-llm-gateway's 120s fallback-chain budget), share one deadline across setup and the provider request, and return a graceful timeout status instead of letting the raw error end the turn; mirrored in the Codex dynamic-tool watchdog; sentry-monitor downgrades image timeouts to a warning. - #291: sentry-monitor no longer pages on ordinary non-zero exec exit codes; only shell lookup failures (126/127) stay exceptions, now fingerprinted per missing binary. Runtime Docker image adds unzip. - #288 (ENG-21227): memory_search no longer pauses/pages Sentry while the index is still building ("missing" identity); only a real "mismatched" embedding provider pauses it. - #294 (ENG-21405, test-only): regression coverage confirming the cron delivery-target guard already rejects a directory-less channel's unknown target end to end; root cause for the live Sentry errors was a stale anychat-boon-web plugin install, not a core gap. Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version field in every extension's npm-shrinkwrap.json via pnpm plugins:sync, hand-patched the same way as boon.7 (the npm-shrinkwrap generator still can't regenerate cleanly on this fork: pre-existing, unrelated @sentry/node nested @opentelemetry/resources / sdk-trace-base registry-resolution drift, reproduced again on this base). Verified via test/package-manager-config.test.ts (12/12) and the full release-preflight check suite (plugin versions, inventory, base config schema, bundled channel config metadata, config docs baseline, plugin SDK exports/API baseline/surface budget, root dependency ownership) -- all green except the known shrinkwrap generator drift. Add the 2026.6.34-boon.8 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No config schema, plugin-SDK surface, or plugin source/dependency change in slack/msteams/diagnostics-prometheus; this is a gateway-only roll (bundled-plugin source changes in codex, memory-core, and sentry-monitor ship inside the gateway tarball). Targeted tests for all three touched extensions plus the codex dynamic-tool-execution suite: 1075/1075 passing. Co-authored-by: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes ENG-21228: Sentry
OPENCLAW-FLEET-XM(51 events, 7 customer sessions across tc-browne,power-solutions, affinity, guido, builders-inc, boon-test-automation). Agent
scripts that render crops/pages into
/tmp(pdf2image, matplotlib, etc.) andthen hand that path to the
imagetool are blocked withError: Local media path is not under an allowed directory: /tmp/..., so customers never get thetakeoff/plan diagrams they were promised.
Why This Change Was Made
The allowed media-read roots are
/tmp/openclaw+ state/config media dirs +the agent workspace (
src/media/local-roots.ts). The outboundMEDIA:send path already widens that allowlist to a referenced file's own directory
when the agent is permitted host reads outside its workspace
(
getAgentScopedMediaLocalRootsForSources, gated onresolveEffectiveToolFsWorkspaceOnly/resolveEffectiveToolFsRootExpansionAllowed).The media tools (
image,pdf,image_generate,video_generate,music_generate) never got the same treatment —resolveMediaToolLocalRootssilently discarded the media source it was handed (the parameter was literally
named
_mediaSources). That asymmetry is whyMEDIA:/tmp/x.pngsends finebut
image(/tmp/x.png)throws — exactly what the Sentry telemetry shows(
tool: imageon every event).This carries the already-resolved fs-policy decision forward as a prepared
rootExpansionAllowedfact onToolFsPolicy(computed once increateOpenClawCodingTools, the only place bothcfgandagentId— and thememory-flush trigger — are known), and reuses the existing
appendLocalMediaParentRootshelper in the five media tools. No new configkey, no
/tmpadded to the default allowlist, no change for agents that areworkspaceOnlyor whose policy deniesread— they stay exactly as lockeddown as before. Traversal/symlink containment in
assertLocalMediaAllowed(realpath-based) is unaffected and covered by a new test.
Also fixed: a blocked path was thrown as a raw error and classified
"upstream"byclassifyToolCallErrorKind, paging Sentry as a host defecteven though it's a policy outcome.
imageandpdfnow catch thepath-not-allowedcase and return adeniedtool result the model can acton (same pattern as the existing image-too-large handling), so genuinely
denied paths (e.g.
workspaceOnlyagents) stop paging while still failingthe turn for the model to see and self-correct.
User Impact
default — no
tools.fs.workspaceOnly, no restrictivetools.profile) cannow hand the
image/pdf/*_generatetools a file they just renderedanywhere on the host, including
/tmp, matching what already worked forMEDIA:sends.workspaceOnlyagents and restrictive tool-policy agents: unchanged.instead of an unhandled exception; stops paging
OPENCLAW-FLEET-XM.Out of scope (follow-up, different repo): updating
boon-skillsagentskills to prefer writing media under the workspace directory in the first
place.
Evidence
node scripts/run-vitest.mjs src/agents/tools/{media-tool-shared,image-tool,pdf-tool,image-generate-tool,video-generate-tool,music-generate-tool}.test.ts src/media/{local-media-access,local-roots,read-capability,load-options}.test.ts— all green (new tests included: root-expansion widening,workspaceOnlystill wins, symlink-escape still rejected, graceful denial result).node --import tsx scripts/check-import-cycles.ts— 0 cycles.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental ...— clean.node_modules/.bin/oxlint <touched files>— exit 0, no issues.$autoreview --mode local(Claude engine; Codex unavailable — not logged in in this environment) — scoped-clean, 0 accepted/actionable findings, "patch is correct (0.72)".Remaining gap: live Crabbox proof of an actual
/tmp-rendered image upload toSlack/Web, and post-release Sentry zero-event confirmation, are not done in
this session — flagging for follow-up before/after merge.
Summary by cubic
Fixes ENG-21228: the
image,pdf,image_generate,video_generate, andmusic_generatetools rejected files an agent just rendered under/tmp(via pdf2image, matplotlib, etc.), even though the same path already works throughMEDIA:sends. Those tools now widen their read allowlist to the referenced file's own directory when the agent is permitted host reads outside its workspace, matching the outbound send path. The widening's permission check runs against the full layered tool policy set, so any layer (group, sender, sandbox, subagent, inherited) that deniesreadkeeps the narrow default roots.workspaceOnlyagents and restrictive tool policies are unchanged and keep the narrow default roots.deniedtool result (status: "denied", whichclassifyToolCallErrorKindreads directly) the model can act on — write the file under the workspace and retry — instead of throwing, so genuine denials stop paging Sentry as host defects.Written for commit 9afb9de. Summary will update on new commits.