Repository navigation
Stop agents retrying the same failing fix: roll back and retry on another provider (#391) - #1672
Conversation
…ther provider (#391) Thrash detector: when the same command fails with the same error three times, with a code edit before each retry (tool calls or the verify loop), stop the run, reset the worktree to the last verified-green checkpoint, switch to a different installed provider and retry with a plain-language explanation. One automatic recovery per problem; a second hit stops and explains. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a00d7c7a92
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| noteSuccess(threadId) { | ||
| const s = threads.get(threadId); | ||
| if (s) s.recovered = false; |
There was a problem hiding this comment.
Clear prior failures after a green turn
When a verification command fails twice and a subsequent fix passes, noteSuccess resets only the recovery flag while retaining the command's failure count and edit mark. If the same command fails once during a later task after another edit, noteFailure immediately reports a third attempt and triggers rollback/provider switching even though the previous problem was resolved. Clear the tracked keys when a turn lands green so the next failure starts a new sequence.
Useful? React with 👍 / 👎.
| const green = thread.lastGreenSha | ||
| ? list.find((c) => c.sha === thread.lastGreenSha) | ||
| : null; |
There was a problem hiding this comment.
Invalidate the green checkpoint when the verify command changes
When a user changes verifyCommand after an earlier command passed, setVerifyCommand updates only the command, leaving lastGreenSha intact. Three failures of the new command therefore cause this code to reset the worktree to a checkpoint that was only proven by the old command, even if the new command has never passed; associate the SHA with the command or clear it whenever the command changes.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Two Date.now() calls could straddle a millisecond on slow CI, so the tool_result never matched its tool_use and the edit never counted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
When an agent keeps retrying the same broken fix, Solenta now steps in instead of letting the run burn tokens: it stops the run, rolls the worktree back to the last green checkpoint, hands the task to a different provider, and posts a plain-language note saying what happened. Closes #391.
Changes
noteToolSpan) and the verify loop.restoreCheckpointto the last checkpoint where verify passed (lastGreenSha, now recorded on each pass). With no verify command it uses the last finished turn; if verify has never passed it skips the rollback. Then it switches to the first installed provider that differs from the current one (quota failover order first) and retries with the original request plus an account of what kept failing.Verification
electron/test/thrash.test.js: tracker unit cases, plus two real-runner cases with a fake Claude CLI:npm test: stopped, worktree reset to the checkpoint, the run's stray file gone, provider switched to a fake OpenCode, retry prompt carries the original requesttest:electronlocally (before the rebase): 38 failures, all from machine load. Several other worktrees were running their suites at the same time, and the files that hung here also hung there on branches without this change. Run alone, every failing file passes, and the same set passes 194/194 on a clean checkout of the base commit. CI is the real check.Notes for reviewers
git reset --hardon the thread worktree. Uncommitted edits are saved in a safety commit first, recoverable withgit reflog(the event message says so), and there is no setting to turn it off. Asking before acting, like OpenCode'sdoom_loopapprove/reject, would be a follow-up if wanted.listCheckpointsis local), and a provider installed only on the remote machine won't be picked.claude-opus-5-5 via Claude Code
🤖 Generated with Claude Code