Skip to content

fix(#869): add targeted search guidance to reduce token waste in agentic prompt - #2142

Open
xielixing wants to merge 1 commit into
GCWing:mainfrom
xielixing:fix/issue-869-file-scan-efficiency
Open

fix(#869): add targeted search guidance to reduce token waste in agentic prompt#2142
xielixing wants to merge 1 commit into
GCWing:mainfrom
xielixing:fix/issue-869-file-scan-efficiency

Conversation

@xielixing

Copy link
Copy Markdown

Summary

Addresses issue #869: "智能体为什么老是要去扫描很多文件? 感觉很浪费token" (Why does the agent always scan many files? It feels like a waste of tokens.)

The agent was performing overly broad file searches and reading entire files when targeted searches would suffice, wasting tokens on unnecessary scanning.

Changes

Added a new bullet to the Tool usage policy section of the agentic mode prompt (agentic_mode.md) guiding the agent to:

  • Narrow Grep scope with path, glob, and type filters before scanning
  • Use output_mode: "files_with_matches" to locate candidate files first, then Read only the relevant ones
  • Use head_limit to cap broad search results
  • Read specific line ranges (offset/limit) instead of entire large files
  • Avoid re-reading files already inspected in the session or repeating searches whose results are still in context

Validation

  • cargo test -p bitfun-agent-content --test prompt_catalog_contracts — 3/3 tests pass (confirms embedded prompt matches source markdown)
  • No Rust source files changed; only a prompt markdown file was modified

Relation to #216

This is complementary to PR #2141 (issue #216), which addressed Explore subagent overuse specifically. This PR addresses the broader problem of general search/Read efficiency across all tool usage.

…n agentic prompt

Add a bullet to the Tool usage policy section of agentic_mode.md guiding
the agent to narrow Grep scope with path/glob/type filters, use
files_with_matches mode first, cap broad searches with head_limit, read
specific line ranges instead of entire large files, and avoid re-reading
files already inspected or repeating searches whose results are in context.

This directly addresses issue GCWing#869 where the user reports the agent scans
too many files and wastes tokens.
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.

1 participant