fix(#869): add targeted search guidance to reduce token waste in agentic prompt - #2142
Open
xielixing wants to merge 1 commit into
Open
fix(#869): add targeted search guidance to reduce token waste in agentic prompt#2142xielixing wants to merge 1 commit into
xielixing wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:path,glob, andtypefilters before scanningoutput_mode: "files_with_matches"to locate candidate files first, then Read only the relevant oneshead_limitto cap broad search resultsoffset/limit) instead of entire large filesValidation
cargo test -p bitfun-agent-content --test prompt_catalog_contracts— 3/3 tests pass (confirms embedded prompt matches source markdown)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.