You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Inform the model what shell it's running inside of in Bash tool's description #4866
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Frequently, I'll see my model try to use shell syntax that only works in bash. This will fail, because I'm actually running opencode from inside fish. I assume similar models probably make similar mistakes in other non-bash shells: bash is probably the shell they're most trained on, so they're taking a safe bet and reaching for it first.
Generally, the model will see the error message, figure out what shell it's actually running in, and redo the shell command using syntax that's appropriate for the fish context it's running inside of. So, it's not a showstopper.
However, it isn't ideal: it still means at least one extra turn, more time spent, more requests/tokens exchanged with the provider, and one more failed tool call cluttering up its context.
All this could be avoided, saving us time and tokens, if the model was advised ahead of time in the generated system prompts as to what shell it's running inside of instead of having to discover it by trial and error.
changed the title [-][FEATURE]: Inform the model what shell it's running inside of in it's system prompting[/-][+][FEATURE]: Inform the model what shell it's running inside of in its system prompting[/+]on Nov 28, 2025
This issue might be a duplicate of or related to existing issues. Please check:
[FEATURE]: allow multiple shell setups and allow switching them at runtime via TUI command #4683: [FEATURE]: allow multiple shell setups and allow switching them at runtime via TUI command - This issue explicitly mentions the same concern about informing the LLM what shell is being used ("Most of LLMs try to use shell syntax, is it possible to add the shell information to system prompt based on the shell?")
Dynamic system prompts for custom agents #3195: Dynamic system prompts for custom agents - Related to the broader feature of dynamically generating system prompts with contextual information
Feel free to ignore if your use case requires a different approach.
Upon researching a little and doing some further review of the situation, I'm coming around to the idea that putting the advice into the tool description for the 'bash' tool in the tool scheme instead of in the system prompt body proper might be a superior option: if the advice about which shell is in use is in the tool schema, the model's presented with this information right at the time when it needs to see it (when it 'reaches' for the tool), and the advice won't be resent with every single message as part of the system prompt.
Alright. I've got something for it baking presently, so we might be racing each other.
Sent from [Proton Mail](https://proton.me/mail/home) for Android.
changed the title [-][FEATURE]: Inform the model what shell it's running inside of in its system prompting[/-][+][FEATURE]: Inform the model what shell it's running inside of in Bash tool's description[/+]on Nov 30, 2025
+1 for adding something around describing the bash tool to the model. As another flavor of example, I change my $SHELL to point to a custom script that runs in a docker container with readonly access to my fs, and I add this description to my AGENTS.md so the model knows to not bother trying doing certain operations with it:
- For my own safety, I've isolated the `bash` tool to run in a docker container with the current project dir mounted as readonly:
- So when you run shell commands, they will run in this isolated linux container that prevents changes to my project dir (code files, .git dir, etc.)
- For anything other than the `bash` tool, I'm using the platform stated above
- The `bash` tool works like this even in "build mode" -- this docker isolation is separate from "plan mode" vs. "build mode"
Once we get support to configure the bash tool in config instead of the $SHELL env var (#4702), that might be a natural place to put certain descriptions like this. Even moreso if we get support to configure and present multiple different shell tools to the model (#4683).
@jdanbrown To me, the immediacy of putting it in the tool's description in the tool schema sounded like it could be valuable. If many pages of conversation have already occurred in the session and the models context is starting to get crowded, the AI might have forgotten about things I told it earlier in AGENTS.md or wherever else. But, if my understanding is correct, the AI will see the description on the tool in the tool whenever it is selecting a tool to use, so by putting the actual shell there it'll be staring the model right in its metaphorical face when it 'reaches for' the Bash tool.
This seems pretty correct so far, as this PR has been working quite well for me: I've been using this PR in my personal fork since I made it, and I haven't seen a model try to use bash syntax in fish since.
Activity
[-][FEATURE]: Inform the model what shell it's running inside of in it's system prompting[/-][+][FEATURE]: Inform the model what shell it's running inside of in its system prompting[/+]github-actions commentedon Nov 28, 2025
This issue might be a duplicate of or related to existing issues. Please check:
[FEATURE]: allow multiple shell setups and allow switching them at runtime via TUI command #4683: [FEATURE]: allow multiple shell setups and allow switching them at runtime via TUI command - This issue explicitly mentions the same concern about informing the LLM what shell is being used ("Most of LLMs try to use shell syntax, is it possible to add the shell information to system prompt based on the shell?")
[FEATURE]: Add config to change shell for bash tool #4702: [FEATURE]: Add config to change shell for bash tool - Related to shell configuration for the bash tool
Dynamic system prompts for custom agents #3195: Dynamic system prompts for custom agents - Related to the broader feature of dynamically generating system prompts with contextual information
Feel free to ignore if your use case requires a different approach.
ariane-emory commentedon Nov 28, 2025
Upon researching a little and doing some further review of the situation, I'm coming around to the idea that putting the advice into the tool description for the 'bash' tool in the tool scheme instead of in the system prompt body proper might be a superior option: if the advice about which shell is in use is in the tool schema, the model's presented with this information right at the time when it needs to see it (when it 'reaches' for the tool), and the advice won't be resent with every single message as part of the system prompt.
rekram1-node commentedon Nov 28, 2025
yeah more coming soonnnnn
this weekend ill be doing something for this
ariane-emory commentedon Nov 28, 2025
[-][FEATURE]: Inform the model what shell it's running inside of in its system prompting[/-][+][FEATURE]: Inform the model what shell it's running inside of in Bash tool's description[/+]jdanbrown commentedon Dec 3, 2025
+1 for adding something around describing the bash tool to the model. As another flavor of example, I change my
$SHELLto point to a custom script that runs in a docker container with readonly access to my fs, and I add this description to myAGENTS.mdso the model knows to not bother trying doing certain operations with it:Once we get support to configure the bash tool in config instead of the
$SHELLenv var (#4702), that might be a natural place to put certain descriptions like this. Even moreso if we get support to configure and present multiple different shell tools to the model (#4683).ariane-emory commentedon Dec 3, 2025
@jdanbrown To me, the immediacy of putting it in the tool's description in the tool schema sounded like it could be valuable. If many pages of conversation have already occurred in the session and the models context is starting to get crowded, the AI might have forgotten about things I told it earlier in
AGENTS.mdor wherever else. But, if my understanding is correct, the AI will see the description on the tool in the tool whenever it is selecting a tool to use, so by putting the actual shell there it'll be staring the model right in its metaphorical face when it 'reaches for' the Bash tool.This seems pretty correct so far, as this PR has been working quite well for me: I've been using this PR in my personal fork since I made it, and I haven't seen a model try to use bash syntax in fish since.
feat: enable fish and nu shell support in Bash tool