Skip to content

fix(core): name the shell in the shell tool's Code Mode description - #65712

Merged
rekram1-node merged 4 commits into
devfrom
shell-description
Nov 23, 2026
Merged

rekram1-node merged 4 commits into
devfrom
shell-description

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

With full_codemode on, the shell tool's description never said which OS and shell commands run in ("Commands run on macOS using zsh."). Session hooks added that sentence to the direct tool definitions each request, but under full_codemode shell is listed in the Code Mode catalog instead (#64284, #64515), so the hooks found nothing to change.

The tool now reads the shell when it is built and names it in both its direct and its Code Mode description. The context, compaction and generate hooks that patched it are gone. ShellSelect now publishes an internal shell-select.updated Bus event when the selected shell changes (defined in core, so it isn't part of the public event list), the same way agents and web search announce updates, and the shell tool rebuilds on it. The description always names the shell commands actually use, whichever plugin set it, and changing shell in config updates it after the selection reloads instead of depending on which plugin hears the config change first. The description is still the same string on every request, so it doesn't affect prompt caching.

How did you verify your code works?

bun run check passes. Shell tool, shell target environment, machine path, session shell and Code Mode tests pass, plus automation shell and config command tests. Two conditional process substitution tests in tool-shell.test.ts fail on my machine with and without this change.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Code Mode fix works. With full_codemode, the pinned shell catalog entry now names the shell (Commands run on Linux using bash.); on the base it named none. The direct definition names it too. I checked this with temporary logging in the existing tool-shell.test.ts Code Mode and registry tests on the base and on the PR. Shell tool, target environment and machine path tests pass (157 pass, 23 skip). tsc -b for packages/core passes.

The public API is unchanged.

One regression, explained inline: once shell is changed in config, the description keeps naming the old shell until something else rebuilds the tools. The removed hooks looked up the shell on every request, so they never had this problem. I reproduced it: after changing opencode.json from /usr/bin/sh to /usr/bin/bash, shell selection gave /usr/bin/bash, but the description still said sh.

Comment thread packages/core/src/tool/plugin/shell.ts Resolved

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stale shell name after a config change is fixed. I reran the earlier test: after opencode.json changes from /usr/bin/sh to /usr/bin/bash, the shell tool description now names bash. Shell, config command and pty tests pass, and tsc -b for packages/core passes.

The public API is unchanged. ShellSelect.Interface gains a required changes stream, but that interface is internal to core, and its only other implementation, a test stub, was updated.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to the internal shell-select.updated Bus event keeps the fix. After opencode.json changes from /usr/bin/sh to /usr/bin/bash, the shell tool description names bash. The shell, config command, pty and subagent tests pass, and tsc -b for packages/core passes.

The public API is unchanged. The new event is an ephemeral core event, like wellknown.updated, and isn't part of the SDK or OpenAPI event list.

@rekram1-node
rekram1-node merged commit 825986a into dev Nov 23, 2026
12 checks passed
@rekram1-node
rekram1-node deleted the shell-description branch November 23, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant