gemini-3-pro-preview in opencode tends to avoid grep/glob (possible system prompt issue) #7474

Open
opened 2026-02-16 18:07:18 -05:00 by yindo · 1 comment
Owner

Originally created by @smola on GitHub (Jan 24, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

How to reproduce?

gemini-3-pro-preview in opencode will sometimes use grep and glob tools, but compared to other models, it tends to avoid them in many circumstances.

For example:

  1. In a checkout of the opencode repo at commit 27b45d070d927c6fd423f9eb0f8ad6a3a612336f.
  2. runn: opencode run --model google/gemini-3-pro-preview "Where is the code testing global skills?"
  3. Most of the time you'll see a call to bash (find . -name "*skill*", grep -E "test|spec"), bash (find . -name "*skill*" -o -name "*test*", grep -v "node_modules", head -n), or something along these lines.

Possible root cause

I tried tweaking bash.txt with more explicit guidance and tool equivalences, which appeared to improve the issue in some cases, but it still had a strong avoidance of grep and glob.

Then I reviewed gemini.txt and noticed there's ambiguous guidance that could be interpreted as if grep and glob didn't support relative paths (I think they do?). So I tried to make that less ambiguous with this:

diff --git a/packages/opencode/src/session/prompt/gemini.txt b/packages/opencode/src/session/prompt/gemini.txt
index 87fe422bc..b607d45b9 100644
--- a/packages/opencode/src/session/prompt/gemini.txt
+++ b/packages/opencode/src/session/prompt/gemini.txt
@@ -50,7 +50,7 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
 - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information.
 
 ## Tool Usage
-- **File Paths:** Always use absolute paths when referring to files with tools like 'read' or 'write'. Relative paths are not supported. You must provide an absolute path.
+- **Absolute File Paths:** In tools like `read`, `write`, or `apply_patch`, always use absolute paths when referring to files. Relative paths are not supported in these tools. You must provide an absolute path. However, tools `grep` and `glob` do support relative paths.
 - **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase).
 - **Command Execution:** Use the 'bash' tool for running shell commands, remembering the safety rule to explain modifying commands first.
 - **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`. If unsure, ask the user.

This seems to fix the issue, at least as far as I tested with several cases.

Plugins

None.

OpenCode version

Tested with 1.1.34 and also with commit 9513ae23c3d6739fe17a3b9e758739696fb93d7c.

Steps to reproduce

See above.

Screenshot and/or share link

No response

Operating System

Linux

Terminal

Ghostty

Originally created by @smola on GitHub (Jan 24, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description ## How to reproduce? `gemini-3-pro-preview` in opencode will sometimes use `grep` and `glob` tools, but compared to other models, it tends to avoid them in many circumstances. For example: 1. In a checkout of the opencode repo at commit `27b45d070d927c6fd423f9eb0f8ad6a3a612336f`. 2. runn: `opencode run --model google/gemini-3-pro-preview "Where is the code testing global skills?"` 3. Most of the time you'll see a call to `bash (find . -name "*skill*", grep -E "test|spec")`, `bash (find . -name "*skill*" -o -name "*test*", grep -v "node_modules", head -n)`, or something along these lines. ## Possible root cause I tried tweaking `bash.txt` with more explicit guidance and tool equivalences, which appeared to improve the issue in some cases, but it still had a strong avoidance of `grep` and `glob`. Then I reviewed `gemini.txt` and noticed there's ambiguous guidance that could be interpreted as if `grep` and `glob` didn't support relative paths (I think they do?). So I tried to make that less ambiguous with this: ```diff diff --git a/packages/opencode/src/session/prompt/gemini.txt b/packages/opencode/src/session/prompt/gemini.txt index 87fe422bc..b607d45b9 100644 --- a/packages/opencode/src/session/prompt/gemini.txt +++ b/packages/opencode/src/session/prompt/gemini.txt @@ -50,7 +50,7 @@ When requested to perform tasks like fixing bugs, adding features, refactoring, - **Security First:** Always apply security best practices. Never introduce code that exposes, logs, or commits secrets, API keys, or other sensitive information. ## Tool Usage -- **File Paths:** Always use absolute paths when referring to files with tools like 'read' or 'write'. Relative paths are not supported. You must provide an absolute path. +- **Absolute File Paths:** In tools like `read`, `write`, or `apply_patch`, always use absolute paths when referring to files. Relative paths are not supported in these tools. You must provide an absolute path. However, tools `grep` and `glob` do support relative paths. - **Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase). - **Command Execution:** Use the 'bash' tool for running shell commands, remembering the safety rule to explain modifying commands first. - **Background Processes:** Use background processes (via \`&\`) for commands that are unlikely to stop on their own, e.g. \`node server.js &\`. If unsure, ask the user. ``` This seems to fix the issue, at least as far as I tested with several cases. ### Plugins None. ### OpenCode version Tested with 1.1.34 and also with commit `9513ae23c3d6739fe17a3b9e758739696fb93d7c`. ### Steps to reproduce See above. ### Screenshot and/or share link _No response_ ### Operating System Linux ### Terminal Ghostty
yindo added the bug label 2026-02-16 18:07:18 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 24, 2026):

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

  • #6506: Add List Tool Back to Stop Unwanted Grep/Find Usage - Reports similar behavior where models avoid using grep/glob tools and resort to bash find/grep commands instead, particularly in certain models/contexts. The root cause discussion suggests the absence of the List tool contributes to this problem.
  • #266: gemini doesn't handle edit tool very well - Another gemini-specific issue indicating that gemini models may have behavioral differences with certain tools.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 24, 2026): This issue might be a duplicate of existing issues. Please check: - #6506: Add List Tool Back to Stop Unwanted Grep/Find Usage - Reports similar behavior where models avoid using grep/glob tools and resort to bash find/grep commands instead, particularly in certain models/contexts. The root cause discussion suggests the absence of the List tool contributes to this problem. - #266: gemini doesn't handle edit tool very well - Another gemini-specific issue indicating that gemini models may have behavioral differences with certain tools. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7474