From 253a83bfdec3a0aab2f87fd08dc11811c8df7fdd Mon Sep 17 00:00:00 2001 From: xlx1212 Date: Fri, 7 Aug 2026 07:11:01 +0800 Subject: [PATCH] fix(#869): add targeted search guidance to reduce token waste in 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 #869 where the user reports the agent scans too many files and wastes tokens. --- src/crates/assembly/agent-content/prompts/agents/agentic_mode.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crates/assembly/agent-content/prompts/agents/agentic_mode.md b/src/crates/assembly/agent-content/prompts/agents/agentic_mode.md index 8311e884d..b10ece2c9 100644 --- a/src/crates/assembly/agent-content/prompts/agents/agentic_mode.md +++ b/src/crates/assembly/agent-content/prompts/agents/agentic_mode.md @@ -88,6 +88,7 @@ The user will primarily request you perform software engineering tasks. This inc # Tool usage policy - Prefer the most direct tool path that preserves accuracy: use Read, Grep, and Glob for narrow lookups; use Task subagents for broad, multi-area, or independently delegable work. +- Keep searches targeted to reduce token waste. Narrow Grep with `path`, `glob`, and `type` filters before scanning; prefer `output_mode: "files_with_matches"` to locate candidates first, then Read only the relevant files. Use `head_limit` to cap broad searches. Read specific line ranges (`offset`/`limit`) instead of entire large files. Do not re-read files already inspected in this session or repeat searches whose results are still in context. - When the user explicitly asks to complete work and review it carefully, finish the implementation first, then dispatch one independent read-only `CodeReview` Task. Do not run concurrent review tasks or fan out `CodeReview` into architecture, performance, security, product, or other invented dimensions: broader coverage belongs to the unified `/review` path, which selects bounded review lenses and owns cost confirmation. Do not launch review by default for every task. - Treat reviewer output as adversarial evidence. The reviewer never fixes its own findings. Apply accepted fixes in the implementation agent. If substantive fixes make the original verdict stale and the risk warrants another pass, request at most one fresh independent re-review. - When WebFetch reports a redirect, follow the redirect URL if it is relevant and safe for the user's request.