diff options
Diffstat (limited to 'Omni')
| -rw-r--r-- | Omni/Agent/Worker.hs | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index cc5f730..38e29cb 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -209,14 +209,20 @@ runWithEngine worker repo task = do -- Check for retry context maybeRetry <- TaskCore.getRetryContext (TaskCore.taskId task) + -- Read progress file if it exists + progressContent <- readProgressFile repo (TaskCore.taskId task) + -- Build the full prompt let ns = fromMaybe "." (TaskCore.taskNamespace task) let basePrompt = buildBasePrompt task ns repo + -- Add progress context if present + let progressPrompt = buildProgressPrompt progressContent + -- Add retry context if present let retryPrompt = buildRetryPrompt maybeRetry - let prompt = basePrompt <> retryPrompt + let prompt = basePrompt <> progressPrompt <> retryPrompt -- Read AGENTS.md agentsMd <- @@ -314,22 +320,33 @@ buildBasePrompt task ns repo = <> "Your goal is to implement the following task:\n\n" <> formatTask task <> "\n\nCRITICAL INSTRUCTIONS:\n" - <> "1. Analyze the codebase to understand where to make changes.\n" - <> "2. Implement the changes by editing files.\n" - <> "3. BEFORE finishing, you MUST run: bild --test " + <> "1. Read AGENTS.md and any existing progress file for this task.\n" + <> "2. Pick ONE specific change to implement (not everything at once).\n" + <> "3. Analyze the codebase to understand where to make that change.\n" + <> "4. Implement ONLY that one change.\n" + <> "5. BEFORE finishing, you MUST run: bild --test " <> ns <> "\n" - <> "4. Fix ALL errors from bild --test (including lint issues).\n" - <> "5. Keep running bild --test until it passes with no errors.\n" - <> "6. Do NOT update task status or manage git.\n" - <> "7. Only exit after bild --test passes.\n\n" + <> "6. Fix ALL errors from bild --test (including lint issues).\n" + <> "7. Keep running bild --test until it passes with no errors.\n" + <> "8. After tests pass, write progress to: _/llm/" + <> TaskCore.taskId task + <> "-progress.md\n" + <> "9. Do NOT update task status or manage git.\n" + <> "10. Only exit after bild --test passes and progress is saved.\n\n" + <> "INCREMENTAL WORKFLOW (IMPORTANT):\n" + <> "- DO NOT try to implement everything in one go\n" + <> "- Make ONE focused change, test it, save progress, then stop\n" + <> "- The task may be run multiple times to complete all changes\n" + <> "- Each session should leave the code in a clean, testable state\n" + <> "- If the task is already complete, just verify tests pass and note that in progress\n\n" <> "IMPORTANT: The git commit will fail if lint finds issues.\n" <> "You must fix all lint suggestions.\n\n" <> "BUILD SYSTEM NOTES:\n" <> "- Running 'bild --test " <> ns <> "' automatically tests ALL dependencies of that namespace\n" - <> "- You do NOT need to run bild --test on individual files - just the main namespace\n" + <> "- You do NOT need to run bild --test on individual files - just the main namespace ONCE\n" <> "- Once tests pass, do NOT re-run them unless you make more changes\n" <> "- The 'lint' command will be run automatically during git commit via hooks\n" <> "- You can run 'lint --fix' on changed files if needed, but it's optional\n\n" @@ -341,6 +358,29 @@ buildBasePrompt task ns repo = <> ns <> "\n" +-- | Read progress file for a task if it exists +readProgressFile :: FilePath -> Text -> IO (Maybe Text) +readProgressFile repo taskId = do + let progressPath = repo </> "_" </> "llm" </> Text.unpack taskId <> "-progress.md" + exists <- Directory.doesFileExist progressPath + if exists + then Just </ readFile progressPath + else pure Nothing + +-- | Build progress context prompt +buildProgressPrompt :: Maybe Text -> Text +buildProgressPrompt Nothing = "" +buildProgressPrompt (Just progress) = + "\n\n## PROGRESS FROM PREVIOUS SESSIONS\n\n" + <> "This task has been worked on before. Here's what has been completed:\n\n" + <> progress + <> "\n\n" + <> "IMPORTANT:\n" + <> "- Review this progress to understand what's already done\n" + <> "- Do NOT repeat work that's already completed\n" + <> "- Pick the NEXT logical step that hasn't been done yet\n" + <> "- Update the progress file after completing your change\n\n" + -- | Build retry context prompt buildRetryPrompt :: Maybe TaskCore.RetryContext -> Text buildRetryPrompt Nothing = "" |
