Skip to content

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

Closed
ariane-emory/opencode
#278

Description

@ariane-emory

Feature hasn't been suggested before.

  • 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.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 28, 2025
  2. 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
  3. github-actions commented on Nov 28, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of or related to existing issues. Please check:

    Feel free to ignore if your use case requires a different approach.

  4. ariane-emory commented on Nov 28, 2025

    @ariane-emory
    ContributorAuthor

    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.

  5. self-assigned this
    on Nov 28, 2025
  6. rekram1-node commented on Nov 28, 2025

    @rekram1-node
    Contributor

    yeah more coming soonnnnn

    this weekend ill be doing something for this

  7. ariane-emory commented on Nov 28, 2025

    @ariane-emory
    ContributorAuthor
  8. 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
  9. jdanbrown commented on Dec 3, 2025

    @jdanbrown
    Contributor

    +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).

  10. ariane-emory commented on Dec 3, 2025

    @ariane-emory
    ContributorAuthor

    @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.

  11. added a commit that references this issue on Dec 13, 2025
    6753987
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions