diff options
| author | Ben Sima <ben@bensima.com> | 2025-11-25 23:22:13 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-11-25 23:22:13 -0500 |
| commit | 01de0612b51b64077d10d05268e89f5e2b3b8001 (patch) | |
| tree | ab47e82acba4dcf5cb64b52cf5dcc5b6661403fe /Omni/Agent | |
| parent | 2e4bfbffba747efcee6c5de25f8a5325b36859c4 (diff) | |
jr: implement Gerrit-style conflict handling
- Add RetryContext to track failed attempts (merge conflicts,
rejections) - jr review checks for clean cherry-pick before showing
diff - If conflict detected, kicks back to coder with context -
Worker prompt includes retry context (attempt count, conflict files,
reason) - After 3 failed attempts, marks task for human intervention
Task-Id: t-1o2g8gudqlx
Diffstat (limited to 'Omni/Agent')
| -rw-r--r-- | Omni/Agent/Worker.hs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index 89800e4..1cdeb6d 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -84,7 +84,10 @@ processTask worker task = do runAmp :: FilePath -> TaskCore.Task -> IO (Exit.ExitCode, Text) runAmp repo task = do - let prompt = + -- Check for retry context + maybeRetry <- TaskCore.getRetryContext (TaskCore.taskId task) + + let basePrompt = "You are a Worker Agent.\n" <> "Your goal is to implement the following task:\n\n" <> formatTask task @@ -103,6 +106,35 @@ runAmp repo task = do <> fromMaybe "root" (TaskCore.taskNamespace task) <> "'.\n" + -- Add retry context if present + let retryPrompt = case maybeRetry of + Nothing -> "" + Just ctx -> + "\n\n## RETRY CONTEXT (IMPORTANT)\n\n" + <> "This task was previously attempted but failed. Attempt: " + <> tshow (TaskCore.retryAttempt ctx) + <> "/3\n" + <> "Reason: " + <> TaskCore.retryReason ctx + <> "\n\n" + <> ( if null (TaskCore.retryConflictFiles ctx) + then "" + else + "Conflicting files from previous attempt:\n" + <> Text.unlines (map (" - " <>) (TaskCore.retryConflictFiles ctx)) + <> "\n" + ) + <> "Original commit: " + <> TaskCore.retryOriginalCommit ctx + <> "\n\n" + <> "INSTRUCTIONS FOR RETRY:\n" + <> "- The codebase has changed since your last attempt\n" + <> "- Re-implement this task on top of the CURRENT codebase\n" + <> "- If there were merge conflicts, the conflicting files may have been modified by others\n" + <> "- Review the current state of those files before making changes\n" + + let prompt = basePrompt <> retryPrompt + let logFile = repo </> "_/llm/amp.log" -- Read AGENTS.md |
