Permission check for tool-output directory never matches, causes hang in headless mode #4780

Open
opened 2026-02-16 17:45:24 -05:00 by yindo · 3 comments
Owner

Originally created by @Th0rgal on GitHub (Jan 11, 2026).

Originally assigned to: @rekram1-node on GitHub.

When running in headless/automated mode (e.g. ralph loops), opencode hangs indefinitely when trying to read truncated tool output.

The issue is in agent.ts - the allow rule for Truncate.DIR uses the directory path directly, but external-directory.ts creates patterns with /* appended. The wildcard matching fails and falls through to "ask", which hangs without a UI.

Logs show:

pattern=/Users/thomas/.local/share/opencode/tool-output/*
action={"pattern":"*","action":"ask"} evaluated

The rule pattern is /tool-output but the requested pattern is /tool-output/*.

Originally created by @Th0rgal on GitHub (Jan 11, 2026). Originally assigned to: @rekram1-node on GitHub. When running in headless/automated mode (e.g. ralph loops), opencode hangs indefinitely when trying to read truncated tool output. The issue is in `agent.ts` - the allow rule for `Truncate.DIR` uses the directory path directly, but `external-directory.ts` creates patterns with `/*` appended. The wildcard matching fails and falls through to "ask", which hangs without a UI. Logs show: ``` pattern=/Users/thomas/.local/share/opencode/tool-output/* action={"pattern":"*","action":"ask"} evaluated ``` The rule pattern is `/tool-output` but the requested pattern is `/tool-output/*`.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

This issue might be related to a previously reported problem:

  • #7758: external_directory permission triggered for .opencode/state within git worktree (CLOSED)

While #7758 was closed and focused on a different directory access pattern, both issues involve permission rule matching for internal opencode directories. The root cause in #7758 involved pattern matching logic and containment checks that might have similarities to the wildcard matching issue described here.

Feel free to ignore if your specific case (tool-output directory pattern mismatch with wildcards) is distinct from that closed issue.

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be related to a previously reported problem: - #7758: external_directory permission triggered for .opencode/state within git worktree (CLOSED) While #7758 was closed and focused on a different directory access pattern, both issues involve permission rule matching for internal opencode directories. The root cause in #7758 involved pattern matching logic and containment checks that might have similarities to the wildcard matching issue described here. Feel free to ignore if your specific case (tool-output directory pattern mismatch with wildcards) is distinct from that closed issue.
Author
Owner

@rekram1-node commented on GitHub (Jan 13, 2026):

I did a tweak that was kinda ugly that I think fixes this

@rekram1-node commented on GitHub (Jan 13, 2026): I did a tweak that was kinda ugly that I think fixes this
Author
Owner

@TomLucidor commented on GitHub (Jan 20, 2026):

Directory issues and other tool call bugs are always annoying ngl, maybe there are ways to fuzzy-checking them beforehand?

@TomLucidor commented on GitHub (Jan 20, 2026): Directory issues and other tool call bugs are always annoying ngl, maybe there are ways to fuzzy-checking them beforehand?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4780