Skip to content

Conversation

@ariane-emory
Copy link
Contributor

@ariane-emory ariane-emory commented Nov 30, 2025

Resolves #4866

This PR adjusts the tool description of the Bash tool dynamically so that it advises the model what shell the command it's going to run will actually be run in.

I've played with this for a couple of days, and it does seem to significantly reduce the likely hood of the what I'll call 'the usual shell rediscovery' loop which can happen if you're running opencode in a non-bash shell such as fish:

The usual shell rediscovery loop proceeds as follows:

  1. The model will initially try to run a command with bash syntax, this will fail because we're actually running under fish.
  2. Deducing that we are running under fish from the error message, the model will proceed to re-run the command using fish syntax, which will succeed.
  3. The same thing will happen again on your next new session, because a model can't remember having discovered that it is running in a non-bash shell during a prior session

Benefits

  • Fewer requests to the provider needed, saving on both inference time and token costs (or usage limit caps in e.g., Claude or z.ai plans).
  • Fewer failed Bash tools containing errors cluttering up the model's context.

@ariane-emory ariane-emory changed the title feat: tool description of the Bash tool now advises model what shell it's actually in (resolves #4866) feat: tool description of the Bash tool now advises model as to what shell it's actually in (resolves #4866) Nov 30, 2025
@ariane-emory ariane-emory changed the title feat: tool description of the Bash tool now advises model as to what shell it's actually in (resolves #4866) feat: tool description of the Bash tool now advises model as to what the actual shell is (resolves #4866) Nov 30, 2025
@ariane-emory ariane-emory marked this pull request as draft November 30, 2025 08:48
@ariane-emory ariane-emory marked this pull request as ready for review November 30, 2025 08:50
@ariane-emory ariane-emory changed the title feat: tool description of the Bash tool now advises model as to what the actual shell is (resolves #4866) feat: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866) Dec 3, 2025
@ariane-emory ariane-emory marked this pull request as ready for review December 12, 2025 20:57
@ariane-emory ariane-emory marked this pull request as draft December 13, 2025 20:24
Remove the fish/nu blacklist so commands execute in the user's actual
shell. Previously, fish and nu were blacklisted and commands would fall
back to zsh/bash, causing the tool description to incorrectly report
the shell being used.

Changes:
- Remove fish/nu blacklist from bash.ts shell detection
- Remove unused BLACKLIST constant and Shell.acceptable() from shell.ts
- Add fish shell test case to bash.test.ts

Resolves sst#4866
@ariane-emory ariane-emory marked this pull request as ready for review December 13, 2025 21:23
@ariane-emory ariane-emory force-pushed the feat/shell-advice branch 2 times, most recently from 392aaa2 to 0ece1f7 Compare December 21, 2025 19:49
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.

[FEATURE]: Inform the model what shell it's running inside of in Bash tool's description

2 participants