summaryrefslogtreecommitdiff
path: root/Omni/Agent/Subagent
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-12-19 22:59:34 -0500
committerBen Sima <ben@bensima.com>2025-12-19 22:59:34 -0500
commitba466ffdba886d1a30b8fd7c6727ad69a6d40f2c (patch)
tree5c373e900ee3aef0b64e8c4d019efdbba6b3170b /Omni/Agent/Subagent
parent104257d8667893a09f2c681c808804754cd5d929 (diff)
Omni/Agent/Subagent/Coder: improve token efficiency
- Rewrote system prompt with TOKEN EFFICIENCY section - Reduced defaults: timeout 600s, maxCost 50ยข, maxTokens 100k - Added output truncation (8000 char cap) to all tools - Tightened search limits (30 results, 5 context lines)
Diffstat (limited to 'Omni/Agent/Subagent')
-rw-r--r--Omni/Agent/Subagent/Coder.hs43
1 files changed, 27 insertions, 16 deletions
diff --git a/Omni/Agent/Subagent/Coder.hs b/Omni/Agent/Subagent/Coder.hs
index ad97ee7..63273f6 100644
--- a/Omni/Agent/Subagent/Coder.hs
+++ b/Omni/Agent/Subagent/Coder.hs
@@ -71,7 +71,7 @@ test =
[ Test.unit "CoderConfig has sensible defaults" <| do
let cfg = defaultCoderConfig "Omni/Task" "Implement feature X"
coderNamespace cfg Test.@=? "Omni/Task"
- coderTimeout cfg Test.@=? 1200,
+ coderTimeout cfg Test.@=? 600,
Test.unit "coderSystemPrompt includes namespace" <| do
let cfg = defaultCoderConfig "Biz/Cloud" "Fix the bug"
let prompt = coderSystemPrompt cfg Nothing
@@ -131,11 +131,11 @@ defaultCoderConfig namespace task =
coderTask = task,
coderContext = Nothing,
coderModel = "anthropic/claude-sonnet-4",
- coderTimeout = 1200,
- coderMaxCost = 200.0,
- coderMaxTokens = 300000,
- coderMaxIterations = 30,
- coderMaxVerifyRetries = 3
+ coderTimeout = 600,
+ coderMaxCost = 50.0,
+ coderMaxTokens = 100000,
+ coderMaxIterations = 20,
+ coderMaxVerifyRetries = 2
}
-- | Run a bash command and capture output
@@ -265,7 +265,7 @@ loadCoderSystemPrompt cfg maybeInitState = do
coderSystemPrompt :: CoderConfig -> Maybe Text -> Text
coderSystemPrompt cfg maybeInitState =
Text.unlines
- [ "You are a specialized Coder subagent.",
+ [ "You are a specialized Coder subagent with a STRICT TOKEN BUDGET.",
"",
"## Your Task",
coderTask cfg,
@@ -276,24 +276,35 @@ coderSystemPrompt cfg maybeInitState =
"",
maybe "" (\ctx -> "## Context\n" <> ctx <> "\n") (coderContext cfg),
maybe "" (\st -> "## Current State\n" <> st <> "\n") maybeInitState,
+ "## TOKEN EFFICIENCY (CRITICAL)",
+ "",
+ "You have LIMITED tokens. Every tool output consumes budget. Violating these rules will cause task failure:",
+ "",
+ "1. NEVER read entire files. Use search_and_read or read_file with start_line/end_line",
+ "2. ALWAYS search first (search_codebase or search_and_read) to find exact locations",
+ "3. Use edit_file for changes - NEVER write_file unless creating new files",
+ "4. Limit bash output: pipe through `head -50` or `tail -50` when possible",
+ "5. One focused action per step - don't chain unnecessary operations",
+ "",
+ "## Tool Strategy",
+ "",
+ "To find code: search_and_read (returns matches + context in one call)",
+ "To understand a function: read_file with start_line/end_line (get just that function)",
+ "To edit: edit_file with old_str/new_str (surgical patch, not full file rewrite)",
+ "To explore structure: search_codebase with small max_results",
+ "",
"## Guidelines",
"1. Make incremental changes - edit one file at a time",
"2. After each edit, consider running `lint " <> coderNamespace cfg <> ".hs` to catch issues early",
"3. Use `bild " <> coderNamespace cfg <> "` to check your work compiles",
- "4. If tests exist, run `bild --test " <> coderNamespace cfg <> "` to verify",
- "5. Keep changes focused on the task - don't refactor unrelated code",
- "6. If you find bugs unrelated to your task, note them but don't fix them",
+ "4. Keep changes focused on the task - don't refactor unrelated code",
"",
"## Completion",
- "When you believe you're done:",
- "1. Ensure all edits are complete",
- "2. The harness will automatically run lint --fix, build, and tests",
- "3. If verification fails, you'll be asked to fix the issues",
- "4. Provide a brief summary of what you changed",
+ "When done: provide a brief summary. The harness runs lint --fix, build, and tests automatically.",
"",
"## Important",
"- Do NOT commit - the harness handles git operations",
- "- Focus on making the code changes correctly"
+ "- Do NOT read files you don't need to edit"
]
-- | Format verify error for agent retry prompt