Skip to content

[Bug]: OpenCode threads expose a browser namespace that can never attach, so agents report no browser available #40981

Open

Description

@disolaterX

Area

apps/server

Steps to reproduce

  1. Enable OpenCode 2 (@opencode/cli 2.3.2) as a provider and start a thread.
  2. Ask the agent to open a page, e.g. "open https://example.com and read the heading".
  3. The agent uses its browser Code Mode namespace (browser.tabs.open, browser.snapshot, …) and every call fails with [browser.disconnected] No desktop browser is connected to this session.
  4. In the same thread, preview_open works and opens a real tab.

Repeat in a Claude thread: no failure, because that namespace does not exist there.

Expected behavior

The agent uses T3's browser (preview_*), the same as in a Claude thread, and a tab opens.

Actual behavior

No tab opens. browser.* can never bind: OpenCode documents that namespace as "the browser attached by the OpenCode desktop app" (https://opencode.ai/docs/tools → Browser). Under T3, OpenCode runs as a headless opencode serve child of the provider adapter, so nothing ever attaches. The error is permanent, not transient — restarting the app, the server, or the thread does not change it.

Worse, the dead namespace is the discoverable one: OpenCode ships a bundled Browser skill whose instructions say to call tools.browser.*, and its tool descriptions are detailed, while T3's working browser arrives as generic t3-code-* MCP tools. Agents reliably pick the broken namespace and report "no browser access" even though preview_* works.

Impact

Major degradation: browser work is unusable in OpenCode threads on web, desktop, and mobile until a human notices preview_* exists.

Version or commit

T3 app 0.0.46-nightly.20261008.2801, server runtime 0.1.12-nightly.20261122.5098, OpenCode 2.3.2.

Environment

Linux (Ubuntu 24.04), T3 server on the same machine, desktop app attached.

Proposed fix

sessionRules() in packages/provider-opencode/src/server/v2/adapter.ts already builds the per-session rule list that writeRules() sends via client.session.update({ permissions: rules }). Appending one rule at the end of that array removes the unusable catalog:

  ...paths,
  ...mcpRules(mcpServerName),
  rule("browser", "deny"),
];

The array is last-match-wins and this entry lands after the rule("*", "allow") emitted for full-access mode, so it applies in every permission mode. sameRules() compares structurally, so a constant tail entry does not churn session updates.

OpenCode's docs state a browser deny with resource * "removes the browser catalog", so this hides the tools instead of only rejecting calls.

Verified on OpenCode 2.3.2 that the rule removes the catalog: a standalone session started with OPENCODE_CONFIG_CONTENT='{"permission":{"browser":"deny"}}' reported no browser.* tools at all, and OpenCode's bundled Browser skill no longer had a namespace to point at.

Notes

  • OpenCode 1.x does not expose this namespace (browser tools were not in the 1.x catalog), so the rule is a no-op there; the v2 adapter is the only site that needs it.
  • If you would rather keep the tools visible for people who point T3 at an external OpenCode server that does have a desktop host attached, gate the rule on the adapter owning a locally spawned server.
  • Related: [Bug]: With agent browser/device access off, the agent still sees every preview_* and device_* tool #17202 (the inverse problem — preview_* and device_* remain visible when agent browser access is off).
  • Also worth a sentence in docs/user/providers-opencode.md: in a T3 thread, the browser is preview_*; OpenCode's browser namespace belongs to the OpenCode desktop app.

Activity

  1. disolaterX commented on Nov 22, 2026

    @disolaterX
    Author

    Extra data from the same machine, testing the workaround a user would try first:

    Setting {"permission":{"browser":"deny"}} in the OpenCode config does not fix T3 threads in full-access mode, because sessionRules() emits rule("*", "allow") and the session-level rules are applied after the config's, so the wildcard allow wins. Measured on OpenCode 2.3.2, three fresh OpenCode threads started through create_threads:

    runtime mode browser.* tools seen
    full-access 45
    auto-accept-edits 0 (agent used preview_open, page opened)
    auto 0 (agent chose preview_open)

    So a config-level deny is only a partial user workaround, and the modes that T3 defaults to for agent-started threads are exactly where it fails. This reinforces that the rule needs to be appended inside sessionRules() after the mode-specific entries.

  2. disolaterX commented on Nov 22, 2026

    @disolaterX
    Author

    Checked every user-side lever for full-access threads, so nobody repeats the search. All measured on OpenCode 2.3.2 with fresh create_threads threads, runtimeMode: "full-access":

    attempt result
    permission: { browser: "deny" } 45 tools still listed
    policies: [{ action: "tool.use", resource: "browser:*", effect: "deny" }] (+ browser.*:*) 45 tools still listed; calls never reach the policy because the tool fails on "no host" before any permission check
    agent: { build: { permission: { browser: "deny" } } } 45 tools still listed

    Why: writeRules() sets session-level permissions via client.session.update(), and OpenCode resolves config rules first and session rules after, last match wins. sessionRules() emits rule("*", "allow") first for full-access, so it always beats a config-level deny that OpenCode placed earlier in the list. There is no config key or plugin hook that appends a rule after the session's own (the plugin tool.definition hook can only rewrite a description, and permission.ask fires at call time, not at catalog build).

    With auto and auto-accept-edits the same config deny does remove the catalog (0 tools), which is what makes full-access the interesting case: the mode a user is most likely to leave a browser-capable agent in is the one where the workaround silently fails and the agent still reports "no browser".

    So the adapter-level append is the only fix that covers every mode.

  3. disolaterX commented on Nov 22, 2026

    @disolaterX
    Author

    A supported user-side workaround exists, verified on OpenCode 2.3.2: the browser namespace is the built-in plugin opencode.browser, and OpenCode's own plugin docs allow disabling an id with a - prefix.

    {
      "$schema": "https://opencode.ai/config.json",
      "plugins": ["-opencode.browser"]
    }

    That removes the 45 browser.* tools and the bundled browser skill in every mode, including full-access, because a plugin disable is not a permission and nothing the session supplies can re-enable it. Measured: a T3 OpenCode thread with runtimeMode: "full-access" went from 45 browser.* tools to 0, with preview_* untouched.

    Two details worth knowing when considering the adapter change:

    • The matcher is the plugin id, not the package name: -@opencode/plugin-browser does nothing, -opencode.browser works, and -opencode.* would disable every built-in plugin (read/write/shell/execute included).
    • tool.use policies and plugin policies do not reach built-in plugins, and the deprecated permission: { browser: "deny" } / tools: { browser: false } keys both normalise to the same {action:"browser",resource:"*",effect:"deny"} rule that full-access overrides.

    So there are now two independent fixes: this config one, and the adapter-level append. The config one costs users a line; the adapter one makes it unnecessary for anyone running OpenCode under T3. Your call which belongs in the product.

  4. disolaterX commented on Nov 22, 2026

    @disolaterX
    Author

    Cross-link: PR #36983 ("honor native permission rules in OpenCode 2") addresses the root cause behind this report — sessionRules() emitting rule("*", "allow") for full-access and replacing the session's rule list every turn. If that lands, a native {action:"browser",resource:"*",effect:"deny"} rule survives full-access like any other native deny, and the browser namespace can be suppressed by permission rather than by disabling the plugin.

    Until then there is a second supported route besides the global config: the OpenCode provider instance's environment variables reach the spawned opencode serve verbatim (OpenCodeRuntime.ts — inputEnvironment.OPENCODE_CONFIG_CONTENT ?? inherited ?? "{}"), so setting OPENCODE_CONFIG_CONTENT={"plugins":["-opencode.browser"]} on the instance disables the built-in browser plugin for that instance only, without touching the user's global config. It only applies to a T3-spawned server, not an external serverUrl.

  5. juliusmarminge commented on Nov 22, 2026

    @juliusmarminge
    Member

    A fix for this was proposed in #41004, but when the reported steps were run in the real app the problem did not appear.

    What was run on bc13afaa3c, the commit before this change:

    On each commit, installed dependencies, started the isolated dev app, paired its web client, added an OpenCode provider instance pointing to the scratch 2.3.2 binary with Server URL blank, added the same synthetic Browser proof project, and started a full-access anthropic/claude-haiku-5-5 thread with: 'Open https://example.com and read me the page heading. Use whatever browser tool you have.' Inspected the completed conversation and expanded tool inputs and outputs. Base called browser.tabs.open and received browser.disconnected, but then recovered using T3 preview, loaded Example Domain, read its contents, and closed its tab. Head's browser namespace search returned no items; it used T3 preview_open and preview_evaluate successfully and closed its tab. Neither run ended with the reported no-browser refusal.

    How: Manual real web app comparison: separate worktrees and fresh databases, T3CODE_DEV_SEED=0, preview Chromium at 1280x800 CSS pixels, light theme. Real OpenCode CLI 2.3.2 with Claude Haiku 5.5 through the configured provider account. Synthetic project created through T3 CLI; full-access turns created through T3 CLI and inspected in the paired web clients. Captures crop the conversation to exclude private environment labels. Both apps were stopped and temporary worktrees removed.

    Could you share the exact steps, what you see, and the version and platform you are on? The pull request is closed for now; the fix is picked up again once the problem can be shown.

  6. added
    needs more info
    on Nov 22, 2026
  7. Nihalsaeed commented on Nov 23, 2026

    @Nihalsaeed

    Another real-app reproduction from an OpenCode-harness thread (same harness as this issue; provider opencode, model hy4-flash-free), where the agent did not self-recover.

    Environment

    • T3 Code thread running the opencode/hy4-flash-free provider/model, in a server-side scratch workspace (Linux).
    • The thread had both toolsets: OpenCode's browser Code Mode namespace (45 tools) and the generic t3-code-* MCP tools including preview_*.
    • No desktop browser attached to the session (headless server session).

    Steps

    1. Asked the agent to read a public Spotify profile page and extract its playlist links.
    2. Plain webfetch returned only the app shell — Spotify is a JS SPA and the playlist links were not in the server-rendered HTML.
    3. The agent loaded its bundled browser skill first (as the issue describes: that namespace is the discoverable one), then called tools.browser.tabs.open.

    Actual behavior

    The very first browser call failed with the exact string from the report:

    [browser.disconnected] No desktop browser is connected to this session.
    Open this session in the desktop app and wait for it to connect. Then call browser.tabs.list({}).
    Repeating browser actions while disconnected will not help.
    

    The agent concluded "no browser available" and worked around it with r.jina.ai text extraction. It did not try preview_open and did not know preview_* was the browser to use. The user had to ask "doesn't T3 Code provide headless sessions have browser?" before the agent checked the other namespace.

    Verification that this thread's preview_* works

    After the user asked:

    • preview_open({ url: "https://open.spotify.com/user/31qpq7bvgnc5ddrpgckk2nxapt2a", open: false }) returned available: true, tabId: tab_1_..., title "Spotify – Web Player", viewport 1280×800, control.owner: "agent", ownedByCaller: true.
    • preview_status showed a server-owned tab with runtime: "server".
    • The agent then closed the tab with t3_preview_close.

    So the same thread had a working headless browser the whole time — it just reached for the dead namespace first.

    Why the agent didn't follow the documented routing

    The explicit T3_CODE_BROWSER_TOOL_INSTRUCTIONS ("preview_* is the browser you share with the user: preview_status first, then preview_open…") was not present in this session's system prompt; only the "Visuals and preview" orchestration section was injected. Combined with a discoverable browser skill and detailed browser.* tool descriptions, the dead route won by default. This supports the issue's proposed fix (remove/suppress the browser catalog for T3-owned servers), and suggests also checking why the browser routing instruction was missing in this OpenCode session (see packages/provider-core/src/server/orchestrationInstructions.ts around line 95, where injection is gated on hasT3Mcp).

    Impact

    Browser work was only completed because a third-party text proxy existed and the user intervened. Without either, the turn would have ended with "no browser available" exactly as reported.

    Happy to share any further transcript details that help reproduce.

  8. removed
    needs more info
    on Nov 24, 2026
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