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 changed the title feat: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866) [FEATURE]: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866) Dec 5, 2025
@ariane-emory ariane-emory changed the title [FEATURE]: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866) feature: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866) Dec 5, 2025
@ariane-emory ariane-emory deleted the feat/shell-advice branch December 6, 2025 05:47
@ariane-emory ariane-emory restored the feat/shell-advice branch December 6, 2025 06:36
@ariane-emory ariane-emory reopened this Dec 6, 2025
@ariane-emory ariane-emory marked this pull request as draft December 7, 2025 22:56
- Remove fish from shell exclusion set to allow proper shell detection
- Fix test infrastructure by wrapping tests with Instance.provide()
- Remove duplicate test function
- Bash tool now correctly shows 'fish' instead of falling back to 'zsh'
- Resolves issue where models couldn't determine actual shell syntax to use
@ariane-emory ariane-emory marked this pull request as ready for review December 8, 2025 00:56
@ariane-emory ariane-emory marked this pull request as draft December 8, 2025 15:00
@ariane-emory ariane-emory marked this pull request as ready for review December 8, 2025 18:39
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