Skip to content

fix(web): allow v2 agents to read spilled tool output - #519

Open
ixjosemi wants to merge 9 commits into
mainfrom
fix/v2-tool-output-access
Open

ixjosemi wants to merge 9 commits into
mainfrom
fix/v2-tool-output-access

Conversation

@ixjosemi

@ixjosemi ixjosemi commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #518. On OpenCode V2, unattended flow agent steps hang forever when the agent reads its own spilled tool output. Large tool results are written to $XDG_DATA_HOME/opencode/tool-output/, which is outside the workspace, so reading them hits the rendered external_directory: * -> ask. Because rules are last-match-wins, neither access nor an agent's own rules could allow it.

Changes

  • Keep external_directory: * -> ask, and right after it, both globally and per agent, allow only <toolOutputDirectory>/*.
  • Pass the directory through RuntimeConfigModel the same way scratch is passed, so the adapter hardcodes no container path:
    • web: WEB_XDG_DATA_HOME/opencode/tool-output, the same constant now used for the container's XDG_DATA_HOME;
    • desktop: getDesktopXdgDataHome()/opencode/tool-output, the same value that feeds the spawned runtime's XDG_DATA_HOME.
  • Validate the directory like scratch: it must be absolute with no wildcards, and a filesystem root is rejected.
  • Nothing extra is rendered when the field is absent. V1 is unaffected.

Trade-off to confirm

The tool-output folder is shared by every session and agent of the workspace (OpenCode keeps it for about 7 days). With this allow, an agent that has read/glob can read what another agent's tools returned without an approval prompt. The boundary is still the same user's workspace. OpenCode V1's own defaults allowed this directory, and there is no per-session folder to narrow the rule to. @Inakitajes, please confirm this is acceptable (also asked in #518).

Deployment note

The rendered V2 config changes, so every running V2 workspace reports config-status: pending (config) until it restarts. The fix applies on that restart.

Testing

  • Adapter tests:
    • the allow follows the ask, globally and per agent, including with an agent's own external_directory rules and a tools allowlist;
    • sibling paths and secrets still ask;
    • Windows path normalization;
    • invalid and root values are rejected.
  • Wiring tests: runtime artifacts, the runtime config hash, the desktop host and the desktop workspace dirs.
  • pnpm test, pnpm lint and bash scripts/check-podman-images.sh pass on the final HEAD.
  • Verified on a live deployment: the scheduled Magua daily-report flow previously hung on Approval required — external_directory: /home/workspace/.local/share/opencode/tool-output/*. With this fix it runs to completion.

🤖 Generated with Claude Code

ixjosemi and others added 5 commits October 23, 2026 14:39
Render an external_directory allow for the runtime tool-output directory
after the default ask, globally and per agent. The directory comes from
the runtime model, so the adapter hardcodes no container path.

Refs #518

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Web workspaces use the directory under the container XDG_DATA_HOME and
desktop derives it from its own XDG_DATA_HOME, including the config hash.

Refs #518

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #518

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #518

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #518

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ixjosemi
ixjosemi requested a review from Inakitajes October 23, 2026 19:52
@ixjosemi

Copy link
Copy Markdown
Contributor Author

cc @albertoperdomo2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flow agent steps on OpenCode V2 hang on reading spilled tool output

2 participants