[PR #4917] feat: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866) #11173

Open
opened 2026-02-16 18:15:58 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4917

State: open
Merged: No


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.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4917 **State:** open **Merged:** No --- 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.
yindo added the pull-request label 2026-02-16 18:15:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11173