Skip to content

Add List Tool Back to Stop Unwanted Grep/Find Usage #6506

Closed

Description

@heimoshuiyu

Description

I recently noticed that OpenCode often uses command-line (bash) tools like grep and find, specifically with the glm-4.7 model.

I tried modifying the descriptions of the bash and grep tools to emphasize avoiding command-line searches for files, but the model still doesn’t comply.

Using command-line tools frequently leads to issues like searching through node_modules or bundled JavaScript, which fills the context with garbage structures.

This tends to occur especially in long-context scenarios.

After some informal ablation experiments, I found that reintroducing the List tool alleviates this problem.

I suspect this is because the presence of the List tool encourages the model to use the provided tools for browsing the codebase. If the List tool is absent, the model resorts to using ls commands to explore the codebase. Once it starts doing this, the model seems to assume that shell-based exploration is the correct approach and ends up invoking a series of find and grep commands.

I’d also like to know why the List tool was removed from the registry. Perhaps we should consider adding it back. Commit is f397c92

OpenCode version

v1.0.218

Steps to reproduce

  1. cd to opencode source code
  2. start opencode v1.0.218
  3. ask explain this project to trigger opencode using ls to explore the project
  4. ask explain /compact command (or explain other things), opencode will trigger a lots of grep

Screenshot and/or share link

explain this project

Image

after that, explain /compact command

Image

After adding the List tool back

explain this project

Image

explain /compact command use Grep tool correctly

Image

Operating System

linux

Terminal

Alacritty

Activity

  1. added
    perfIndicates a performance issue or need for optimization
    on Dec 31, 2025
  2. github-actions commented on Dec 31, 2025

    @github-actions
    Contributor

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

    The core issue here is about how system prompts and tool descriptions influence model behavior. Issues #4483 and #5715 suggest that system prompt configuration and tool description size can prevent models from following instructions properly, which aligns with your observation that modifying tool descriptions doesn't reliably prevent bash/grep usage.

  3. added a commit that references this issue on Dec 31, 2025
  4. ry2009 commented on Jan 2, 2026

    @ry2009
    Contributor

    #6675 put it back here with test to not remove list in later pr's

  5. removed
    perfIndicates a performance issue or need for optimization
    on Jan 2, 2026
  6. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  7. heimoshuiyu commented on Mar 25, 2026

    @heimoshuiyu
    ContributorAuthor

    Yes still don't know why list tool getting removed

  8. samerbahri98 commented on Apr 7, 2026

    @samerbahri98

    I was going to comment on the commit itself f397c92dd , but yeah this is still relevant.
    I think some clarity on why the list tool was removed from the registry (packages/opencode/src/tool/registry.ts) is much appreciated. the docs and system prompts still mention that this builtin tool exists.
    maybe I'm bad at this but I cannot tie the commit back to a pull request to read the rationale for this breaking change, and I could not find a deprecation notice or period.
    some examples of system prompts in the repo:

    1. packages/opencode/src/session/prompt/default.txt (line 42):
      
       assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
       
    
    2. packages/opencode/src/session/prompt/trinity.txt (line 34):
      
       assistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]
       
    
    3. packages/opencode/src/session/prompt/gemini.txt (line 77)
    
       model: [tool_call: ls for path '/path/to/project']
    

    I feel like it's relevant for me to say that I don't care one way or another if the tool needs to be removed. But the communication about this removal and workarounds is still needed even now.

  9. heimoshuiyu commented on Apr 28, 2026

    @heimoshuiyu
    ContributorAuthor

    Wrote a very simple plugin https://github.com/heimoshuiyu/opencode-bash-guard-plugin to address this issue. Works well. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions