Skip to content

agents: config-defined shell deny on free-model agent fails session with misleading free-tier error #51193

Closed as duplicate

Description

@dcsci

Summary

A custom agent defined in ~/.config/opencode/agents/*.md with a config-defined
shell: deny permission rule fails to start when assigned a free model
(opencode/mimo-v2.6-flash-free), reporting a misleading free-tier error that
appears unrelated to permissions.

Environment

  • opencode version: v2.0.16
  • OS: Windows_NT 10.0.26200.9457 (win32 x64)
  • Terminal: TERM=xterm-256color (TERM_PROGRAM not set)
  • Shell: C:\WINDOWS\system32\cmd.exe
  • Install/channel: latest
  • Active plugins: none ("plugins": [] in config)

Reproduction

  1. Create ~/.config/opencode/agents/review.md:

    ---
    description: Read-only code review
    mode: all
    model: opencode/mimo-v2.6-flash-free
    steps: 20
    permissions:
      - action: edit
        resource: "*"
        effect: deny
      - action: shell
        resource: "*"
        effect: deny
    ---
    
    You review code without modifying it.
  2. Reload config: opencode api post /api/location/reload

  3. Spawn the agent as a subagent with any prompt (e.g. Reply with exactly: OK).

Expected Behavior

The session starts and the permission rules are enforced (agent cannot edit or
run shell commands).

Actual Behavior

Session creation fails with:

OpenCode's free tier can only be used from within OpenCode

The error is unrelated to the free tier and reproduces 3/3 times. Removing or
relaxing the shell rule fixes it:

Permissions on the agent Result
none OK
edit: deny only OK
edit: deny + shell: deny fails (3/3)
edit: deny + shell: ask OK

The same free model works fine on other agents, including builtin explore,
which carries system-level *:deny (including shell) without issue — the
failure appears specific to config-defined shell: deny rules.

Additional Context

  • Same file with effect: ask for shell works and keeps the read-only guard
    (shell requires approval). Workaround applied locally.
  • Could not verify whether paid models are affected — the Go usage cap was
    active during testing.
  • Hypothesis: an internal free-tier validation path depends on shell
    availability, and a denied shell surfaces as this misleading error.

Activity

  1. scachemaille commented on Sep 30, 2026

    @scachemaille

    Corroborating this trigger on a primary agent (same class as #50627). Same error, 100% reproducible, and a bisect isolates it to the config-defined deny rule — the model is not involved.

    Environment

    • opencode version: v2.0.18
    • OS: Linux 6.18.54-1-MANJARO (linux x64)
    • Terminal: TERM=xterm-256color, COLORTERM=truecolor (TERM_PROGRAM unset)
    • Shell: /bin/zsh
    • Install/channel: latest
    • Active plugins: superpowers@git+https://github.com/obra/superpowers.git, opencode-cmd-provider

    Failing agent

    ~/.config/opencode/agents/ask.md:

    ---
    description: Web-only agent for knowledge and conversation.
    mode: primary
    model: opencode/mimo-v2.6-flash-free
    request:
      body:
        temperature: 0.1
    permissions:
      - action: "*"
        resource: "*"
        effect: deny
      - action: webfetch
        resource: "*"
        effect: ask
      - action: websearch
        resource: "*"
        effect: ask
    ---
    
    You are a helpful assistant limited to web research. ...

    Reproduction

    1. Select the ask agent (primary) with opencode/mimo-v2.6-flash-free.
    2. Send any message.
    3. Every time:
    Error from provider (Console): OpenCode's free tier can only be used from within OpenCode
    

    Bisect

    Removing only this block from the agent frontmatter fixes it:

      - action: "*"
        resource: "*"
        effect: deny

    mode: primary and request.body.temperature: 0.1 were left unchanged, so the trigger is the config-defined action: "*" deny rule (which includes shell). The same free model works on a config-defined agent with no permissions block, and on builtin agents.

    Notes

    Related

    the comment has been written by AI but all the tests has been done by me a human

  2. ggbdpq commented on Oct 2, 2026

    @ggbdpq

    Ran the code path down for anyone picking this up — two facts from dev source, plus a clearly-labeled guess:

    Fact 1: a config-defined rule like {action: "*", effect: deny} makes Permission.disabled() (packages/opencode/src/permission/index.ts) strip every tool from the agent's visible toolset, since Wildcard.match(anyTool, "*") always matches a deny rule whose pattern is *.

    Fact 2: the outgoing request body is built from that visible toolset (session/llm/request.ts), so the free-model request would go out with an empty (or near-empty) tools field. Builtin agents with *: deny are unaffected because their ruleset doesn't flow through the same config-agent permission merge — which matches the reports here.

    Guess (unverified): the Zen gateway rejecting with "can only be used from within OpenCode" appears to key off request shape rather than the identity headers (x-opencode-client is always sent, defaulting to cli), and an empty tools array is the obvious candidate signature. Confirming or killing that needs the gateway side, which isn't in this repo — so I'm leaving it here rather than guessing at a fix.

  3. neriousy commented on Oct 20, 2026

    @neriousy
    Member

    Thanks for narrowing this down with the custom-agent permission comparisons. This is the same problem as #51241, where denying shell or read access incorrectly triggers the free-tier error, and we're tracking it there. Please subscribe or add a 👍 there; your agent definition and deny-versus-ask results are worth adding too.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions