Skip to content

OpenCode 2 Plan mode is writable: bb session edit allow overrides the Plan agent deny #8487

Backlog

Description

@martinlevesque

Summary

An OpenCode 2 thread created through bb's acp-opencode provider remains on the plan agent, but bb writes a session-level edit: allow rule. OpenCode evaluates session rules after agent rules, so this overrides Plan's edit: deny and makes a supposedly read-only session able to edit files.

This appears to be a regression from #7551, which added OpenCode 2 session-permission enforcement. The current main source still unconditionally generates the blanket edit allow.

Versions and environment

  • bb 0.50.1, macOS desktop app (/Applications/bb.app)
  • macOS 26.7.3 (25G342), arm64 (Apple Silicon)
  • Provider: acp-opencode, supplied by the bundled provider-acp plugin
  • OpenCode CLI: opencode v2.4.3 (opencode --version)
  • Local machine; no bb Connect, remote host, custom data dir, or custom ACP launch command
  • Reproduced in a bb personal-workspace environment
  • bb offers accept-edits and full for this provider; the affected sessions were observed in both

Steps to reproduce

  1. In bb, create a thread with the acp-opencode provider and choose Plan in the Mode menu. Leave bb's permission mode at Accept Edits (Full Access also produces the conflicting edit rule).

  2. Send a planning request so the ACP session is initialized.

  3. Run bb thread options <thread-id> --json. The mode option reports value: "plan".

  4. Find the OpenCode session for the thread's environment directory and inspect it:

    opencode api get '/api/session?directory=<url-encoded-environment-directory>'

    The session has agent: "plan" and a permissions array beginning with:

    {
      "action": "edit",
      "resource": "*",
      "effect": "allow"
    }
  5. Compare the selected agent:

    opencode api get '/api/agent'

    The plan agent has edit: deny on *, with only its plan-file path allowed. The session-level allow wins over that deny.

Observed on bb 0.50.1 with OpenCode 2.4.3. I did not run a separate source build of main; I inspected the current source at 7ec9cd1f7eb7151a5049492ec015faf959507dbe, where the same rule generation remains.

Expected vs actual

Expected: selecting OpenCode's Plan agent keeps its read-only permission policy. bb's Accept Edits or Full Access setting must not silently turn Plan into a writable session.

Actual: the selected agent remains plan, but bb adds edit: allow at session scope. OpenCode's permission resolver combines the selected agent's rules followed by the session's rules, with the last matching rule winning:

Thus the UI and ACP session both say Plan while the effective edit permission is Build-like.

Evidence

  • Investigation thread: @thread:thr_hshw5unaky
  • bb thread: thr_hshw5unaky; project: proj_personal; environment: env_h6ci4knuf7
  • OpenCode session: ses_dcda54dc6ffesfO50xAK75v2TS
  • bb thread options thr_hshw5unaky --json reported mode.value: "plan"; the OpenCode session and its assistant messages also reported agent: "plan". This is not a mode-label mismatch or a fallback to the build agent.
  • The live session's permissions contained edit: allow on *, followed by the other bb-managed rules and the thread-storage directory allow.
  • In the latest 100 local OpenCode sessions, 47 were Plan sessions; 42 had the blanket edit: allow. All five exceptions were older sessions. The first five unaffected Plan sessions were created before the regression commit; affected sessions began appearing immediately afterward. This is supporting history, not a clean-version bisect.
  • The regression was introduced by cb627c8574af3a5916ab027b2cc549517006ad3f / #7551, which moved OpenCode 2 enforcement from OPENCODE_PERMISSION to PATCH /api/session/<id>. That change correctly addressed shell approvals, but its unconditional edit allow also overrides Plan.

What you ruled out

  • Not an actual switch to OpenCode Build: the session and assistant messages stay on plan; the permission override explains the Build-like behavior.
  • Not a stale local installation alone: the same unconditional rule is present on main at 7ec9cd1f7eb7151a5049492ec015faf959507dbe; no source-build runtime repro was performed.
  • Related to ACP: map bb permission modes and Plan onto the agent's own session modes #7536's general ACP mode/permission mapping, but not a duplicate: this is a specific OpenCode 2 session-rule regression that defeats an already-selected Plan agent.
  • Searched open and closed bb issues/PRs for OpenCode Plan, edit: allow, and session permissions; no existing report of this exact conflict found.

Suggested priority and effort

High — every OpenCode 2 Plan session created through the affected bb integration can lose its read-only boundary; no reliable bb-side workaround while retaining Plan. Likely a contained fix in opencode-session-permissions.ts, with mode-change and session-resume regression tests.

AGENT GENERATED

Activity

  1. added theissue type on Dec 1, 2026
  2. added
    providers
    security
    provider-acp
    partial-repro
    on Dec 1, 2026
  3. bb-slop-cop commented on Dec 1, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Classification: Bug · High priority · Medium effort · providers, provider-acp, security

    Report: PARTIALLY REPRODUCED · medium confidence · partial-repro. Two clean checkouts confirmed that bb's ACP bridge applies managed session permissions without accounting for the selected agent's policy. Live file-write behavior was not tested.

    No PR: The fix changes permission enforcement, which is outside the simple-fix rule.

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

    partial-reproprovider-acpproviderssecurity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions