opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feature: tool description for the Bash tool now advises model as to what the actual shell is (resolves #4866)

Open ariane-emory opened this issue 1 month ago • 3 comments

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 avatar Nov 30 '25 08:11 ariane-emory

Corrupted by a bad merge, will fix.

ariane-emory avatar Dec 11 '25 00:12 ariane-emory

Fixed/uncorrupted.

ariane-emory avatar Dec 11 '25 01:12 ariane-emory