Skip to content

fix: add Task tool delegation instructions to gemini.txt system prompt#22245

Open
rrmistry wants to merge 3 commits intoanomalyco:devfrom
rrmistry:fix/gemini-task-tool-prompt
Open

fix: add Task tool delegation instructions to gemini.txt system prompt#22245
rrmistry wants to merge 3 commits intoanomalyco:devfrom
rrmistry:fix/gemini-task-tool-prompt

Conversation

@rrmistry
Copy link
Copy Markdown

@rrmistry rrmistry commented Apr 13, 2026

Issue for this PR

Closes #22244

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The gemini.txt system prompt is missing Task tool / sub-agent delegation instructions that are present in both anthropic.txt and default.txt. This causes Gemini models to never spawn sub-agents for codebase exploration — they run all searches inline in the parent context, consuming excessive tokens and producing shallow results.

Root cause: In anthropic.txt (lines 79-94) and default.txt (line 91+), there are explicit instructions telling the model to use the Task tool for codebase exploration, plus two concrete examples. gemini.txt has zero mentions of the Task tool or delegation. The tool is registered and available, but the model is never prompted to use it.

Fix: Added a ## Tool Usage Policy - Task Delegation section to gemini.txt with the same three directives and two examples already present in the other prompt files. This is a minimal, targeted addition — no restructuring of the existing prompt.

I investigated the source code (packages/opencode/src/session/system.ts line 29 selects PROMPT_GEMINI for Gemini models, and llm.ts line 109 shows agent prompts replace provider prompts entirely) to confirm the prompt selection path. The gemini.txt prompt appears to have been imported from gemini-cli (as noted in #13605) and never updated with Task tool guidance.

How did you verify your code works?

  • Tested with gemini-3.1-pro-preview via Vertex AI in automated code analysis workflows
  • Before fix: 0 sub-agents spawned across 10+ sessions requiring multi-file exploration (3-5 files examined per session)
  • After adding Task tool instructions via custom prompt override: Gemini begins delegating to explore sub-agents, file coverage increases significantly
  • Claude models using anthropic.txt consistently spawn 4-6 explore sub-agents for the same tasks, confirming the prompt is the differentiator
  • Verified the change does not break existing Gemini tool calling behavior

Screenshots / recordings

N/A - system prompt text change, no UI impact.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Related issues

The gemini.txt system prompt is missing Task tool / sub-agent delegation
instructions that are present in both anthropic.txt and default.txt.
This causes Gemini models to never spawn sub-agents for codebase
exploration, running all searches inline and consuming excessive context.

This adds the missing Task tool usage policy and examples to gemini.txt,
matching the guidance already present in the other prompts.

Fixes anomalyco#22244
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rrmistry
Copy link
Copy Markdown
Author

The e2e timeouts are pre-existing — reproducible on the dev branch itself (run 24358819443) and across multiple unrelated PRs (#22345, #22343, #22341, #22339, #22338). This PR only modifies a static text file (gemini.txt) with no code impact. Unit tests, typecheck, and compliance checks all pass.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini system prompt missing Task tool / sub-agent delegation instructions

1 participant