Repository navigation
fix(core): name the shell in the shell tool's Code Mode description - #65712
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Issue for this PR
Closes #
Type of change
What does this PR do?
With
full_codemodeon, 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 underfull_codemodeshell 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.
ShellSelectnow publishes an internalshell-select.updatedBus 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 changingshellin 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 checkpasses. Shell tool, shell target environment, machine path, session shell and Code Mode tests pass, plus automation shell and config command tests. Twoconditional process substitutiontests intool-shell.test.tsfail on my machine with and without this change.Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist