Skip to content

tool: shell tool is published to models as "bash" although it runs the host shell (zsh/sh/PowerShell/cmd) #780

Open

Description

@agenteinstinct1-max

Description

The shell tool is published to models under the id bash, but it does not run bash — it runs whatever shell the host provides. The name misdescribes the tool on every non-bash host, and the tool's own description text repeats the wrong name to the model even when it has just told the model the host runs PowerShell or cmd.exe.

Verified at commit 897e85177c03b0dfb8618e1f3cf09250a9cbebe6.

1. The public id is hardcoded to bash, with the rename already deferred once.

packages/opencode/src/tool/shell/id.ts:

// Keep the exposed tool ID and permission key as "bash" for compatibility with
// existing plugins, users, and saved permissions. Rename with opencode 2.0.
export const ToolID = "bash"

The file is named shell.ts, the tool namespace is ShellTool, the prompt module is ShellPrompt — only the public id still says bash. That id is what the model sees in the tool catalog, and it is also the permission action (packages/opencode/src/tool/shell.ts:287, permission: ShellID.ToolID).

2. The tool genuinely runs a non-bash shell on most hosts.

packages/core/src/shell.ts resolves the interpreter from config (Shell.acceptable(cfg.shell), used at packages/opencode/src/tool/shell.ts:706) and otherwise falls back:

function fallback() {
  if (process.platform === "darwin") return "/bin/zsh"
  const bash = which("bash")
  if (bash) return bash
  return "/bin/sh"
}

Its META table enumerates bash, dash, fish, ksh, nu, powershell, pwsh, sh, zsh, and Windows resolves through win(). So the default macOS interpreter is zsh, not bash, and on Windows it is PowerShell or cmd.exe.

3. The description sent to the model names the wrong tool, including on hosts it just described as non-POSIX.

packages/opencode/src/tool/shell/prompt.ts builds the description. chainGuidance() returns, for pwsh:

Chain dependent commands in a single bash tool call with '&&'.

and for cmd:

Chain dependent commands in a single bash tool call with `&&`.

bashCommandSection(), powershellCommandSection() and cmdCommandSection() each end with Independent commands: make multiple bash tool calls in one message. — so the PowerShell and cmd.exe sections instruct the model to make "bash tool calls". The POSIX profile() intro says Executes a given bash command in a persistent shell session, which is wrong when the resolved interpreter is zsh, sh, dash or fish.

This is self-contradictory within one description: shellAdaptationSection() opens with This host runs PowerShell (7+), not a POSIX shell, and the section immediately above it tells the model to make "bash tool calls".

Actual ShellPrompt.render(...) output, filtered to lines mentioning bash:

##### pwsh / win32 #####
  - Independent commands: make multiple bash tool calls in one message. Chain dependent commands in a single bash tool call with '&&'. ...

##### cmd / win32 #####
  - Independent commands: make multiple bash tool calls in one message. Chain dependent commands in a single bash tool call with `&&`. ...

##### zsh / darwin #####
Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.
  - Independent commands: make multiple bash tool calls in one message. Chain dependent commands in a single Bash call with '&&' ...

The zsh case is the clearest: the same description that reports OS: darwin, Shell: zsh opens by claiming it executes "a given bash command".

4. The V2 core tool has the same mismatch.

packages/core/src/tool/bash.ts:20 is export const name = "bash", while its own registered description says Execute one shell command string ... Uses the configured shell when set; otherwise uses /bin/sh on POSIX and COMSPEC or cmd.exe on Windows. Neither default is bash. Its external-directory advisory likewise tells the model Bash runs with host-user filesystem, process, and network authority.

5. The tool catalog carries a stale duplicate as a result.

packages/opencode/src/tool/catalog.ts:135-140 lists both names in CORE_TOOLS:

export const CORE_TOOLS = [
  "invalid",
  "tool_search",
  "tool_search_regex",
  "shell",
  "bash",

No builtin registers shell today — ShellTool registers under ShellID.ToolID, i.e. bash — so the "shell" entry matches nothing and "bash" is the only live one. The pair is a standing invitation to get the id wrong in either direction.

Why this matters beyond cosmetics. The id is the permission action, so "permission": { "bash": ... } in user config is the only spelling that works, and Permission.disabled() hides the tool only when a rule matches that literal. A user on Windows PowerShell has to write bash in their config to gate a tool that runs pwsh. Several renderers already accept both spellings defensively (packages/opencode/src/acp/tool.ts:296 returns tool === "bash" || tool === "shell"), which shows the ambiguity has already leaked into consumers.

Constraint on any fix. bash is load-bearing for existing users, so it cannot simply be swapped: permission.bash allow/deny rules (including per-pattern rules like "git *": "allow" and wildcards like "*"), saved permission grants, and persisted session history whose tool parts say tool: "bash" all have to keep working. Rules are matched with Wildcard.match(permission, rule.permission) and resolved with findLast, so a rename that made legacy bash rules stop matching would silently turn a configured deny into the default ask — a permission broadening, not a no-op. Legacy history also has to keep rendering and replaying from stored output rather than re-executing.

Two unrelated upstream/host contracts must not be renamed as part of this: ZEN_FINGERPRINT_TOOLS in packages/opencode/src/provider/opencode-zen.ts:77 is an opencode-zen free-tier wire requirement ({bash, glob, grep, read}; the comment records that requests with fake names get 403 FreeTierError), and the bash shell kind in ShellID.kinds, the tree-sitter bash grammar, bash-language-server, and Shell.args()/Shell.name() interpreter handling all refer to the real bash program.

Plugins

None. Observed in the repository source itself.

OpenCode version

Source checkout at commit 897e85177c03b0dfb8618e1f3cf09250a9cbebe6 (not a packaged release).

Steps to reproduce

  1. Read packages/opencode/src/tool/shell/id.ts — the exposed ToolID is "bash".
  2. On macOS, run the tool with no shell configured; fallback() in packages/core/src/shell.ts returns /bin/zsh.
  3. Render the tool description for a PowerShell host via ShellPrompt.render("pwsh", "win32", ...) and observe Chain dependent commands in a single bash tool call with '&&'. alongside This host runs PowerShell (7+), not a POSIX shell.
  4. Read packages/opencode/src/tool/catalog.ts:135 — CORE_TOOLS lists both "shell" and "bash".

Screenshot and/or share link

Not applicable — this is a source-level naming/contract defect, not a rendering bug.

Operating System

Linux (source inspection; the defect is platform-independent and the description text is wrong on macOS, Linux, and Windows)

Terminal

Not applicable

Activity

  1. added
    priority: high
    on Nov 12, 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

    priority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions