summaryrefslogtreecommitdiff
path: root/Omni/Agent
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-12-02 14:55:57 -0500
committerBen Sima <ben@bensima.com>2025-12-02 14:55:57 -0500
commit4c1ccb6d43f90db7db08b56239ca229404f0acfd (patch)
tree3e5f39c6f9b1f201b76fb47c2288e80887ea3d85 /Omni/Agent
parent8329b760082e07364a6f6c3e8e0b240802838316 (diff)
Improve agent system prompt for better token efficiency
Add explicit guidance on: - Reading files with large ranges (500+ lines) instead of many small chunks - Using read_file directly when target file is known vs search_and_read - Cost awareness: planning refactors, avoiding redundant reads - Tool call limits for complex tasks
Diffstat (limited to 'Omni/Agent')
-rw-r--r--Omni/Agent/Worker.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs
index 0e4071d..66f894d 100644
--- a/Omni/Agent/Worker.hs
+++ b/Omni/Agent/Worker.hs
@@ -399,15 +399,24 @@ buildBasePrompt ns repo =
<> "- If tests pass, STOP. Do not verify again, do not double-check.\n\n"
<> "# Tool Usage\n\n"
<> "Your tools: read_file, write_file, edit_file, run_bash, search_codebase, search_and_read.\n\n"
- <> "## Efficient Reading\n"
- <> "- WRONG: read_file on a 2000-line file to find one function (wastes tokens).\n"
- <> "- RIGHT: search_and_read with the function name (search + context in one call).\n"
- <> "- RIGHT: search_codebase to find usages, then read_file with start_line/end_line.\n\n"
+ <> "## Efficient Reading (CRITICAL FOR BUDGET)\n"
+ <> "- Read files ONCE with large ranges (500+ lines), not many small 100-line chunks.\n"
+ <> "- WRONG: 10 separate read_file calls with 100-line ranges on the same file.\n"
+ <> "- RIGHT: 1-2 read_file calls with 500-1000 line ranges to cover the file.\n"
+ <> "- When you know the target file, use read_file directly with a path argument.\n"
+ <> "- WRONG: search_and_read across the whole repo when you know the file is Worker.py.\n"
+ <> "- RIGHT: read_file on Worker.py, or search_codebase with path='Worker.py'.\n"
+ <> "- search_and_read is for discovery when you DON'T know which file to look in.\n\n"
<> "## Efficient Editing\n"
<> "- Include enough context in old_str to match uniquely (usually 5+ lines).\n"
<> "- If edit_file fails with 'old_str not found', you are hallucinating the content.\n"
<> "- STOP. Call read_file on those exact lines to get fresh content. Then retry.\n"
<> "- After 3 failed edits on the same file, reconsider your approach.\n\n"
+ <> "## Cost Awareness\n"
+ <> "- Each tool call costs tokens. Large file writes are expensive.\n"
+ <> "- For refactors: plan all new files first, then write them in order.\n"
+ <> "- Don't write a file, then immediately read it back - you just wrote it!\n"
+ <> "- Monitor your progress: if you're on tool call 30+ and not close to done, simplify.\n\n"
<> "# Debugging\n"
<> "If 'bild' fails, do NOT guess the fix.\n"
<> "1. Read the error output carefully.\n"