Skip to content

feat: 冲突任务在合并结果之上重做; 修复成功运行多挂 15 分钟 - #18

Merged
2233admin merged 2 commits into
mainfrom
feat/conflict-retry
Oct 26, 2026
Merged

2233admin merged 2 commits into
mainfrom
feat/conflict-retry

Conversation

@2233admin

Copy link
Copy Markdown
Owner

堆叠在 #17 之上(报告文件的第三部分在那里)。#17 合并后本 PR 会自动改为以 main 为目标。

1. 冲突任务在合并结果之上重做(conflictRetries,默认 1,0 为关闭)

  • 合并时冲突的任务,在一个新的 worktree(基于当前 main)里再跑一次 agent,并在提示里写明哪些文件冲突、那些改动已经在工作区里。
  • 冲突的那次尝试保留为 fsc/<id>-attemptN,重试合并成功后才删除。
  • 一次干净的重试合并不等于两个任务都保留下来:两个互相矛盾的任务,后合并的会赢。所以重试后合并的任务,如果改了另一个已合并任务也改过的文件,会记入 report.retryOverlaps,CLI 打印 WARNING,让人去确认。
  • 每次重试都是多一次 agent 调用的费用。

2. 修复:成功的运行会多挂 15 分钟

每个 agent 的超时定时器(默认 15 分钟)从来不清除,Bun 要等它触发才退出进程。失败的运行通过 process.exit(1) 退出,所以只有成功的运行慢。我此前把这个现象归因于用户级 hook,是错的(#17 已更正)。清除定时器后,同一个两任务运行总耗时从 15 分 28 秒降到 1 分 18 秒,进程在报告打印后立即退出。

实测

  • 真实 claude,三个任务(两个改同一行):greet-b 冲突后重试合并成功,3/3 合并,69 秒。但最终 GREETING = "good day",greet-a 的 "hi there" 被覆盖,这正是上面 WARNING 要提示的情况。
  • 真实 claude,两任务冒烟:总耗时 1 分 18 秒,退出码 0。

测试

  • 新增:重试成功并清理被替代分支;conflictRetries: 0 保持旧行为;重试再次输掉竞争时如实报告并保留两次尝试;retryOverlaps;定时器回归测试(不加修复时失败)。
  • tsc --noEmit 退出码 0;bun test(packages/core)188 通过 / 45 跳过 / 0 失败

没做 / 没验证

  • 只重试一轮(可配置);三个以上互相冲突的任务大多仍会留下冲突。
  • 重试时 agent 如何取舍只靠提示引导,没有强制。
  • 只用 claude 测过;gemini、codex 未测。

🤖 Generated with Claude Code

https://claude.ai/code/session_016FSVfwwP6TVxGLUWatWM53

k-atana-agent and others added 2 commits October 26, 2026 02:54
…anging for 15 minutes

- scheduler: a task whose commit conflicts is run again in a fresh worktree from the current
  base branch with a note naming the conflicting files (conflictRetries, default 1, 0 = off).
  The conflicting attempt is kept as fsc/<id>-attemptN until a retry merges. Retried tasks that
  touch files another merged task also touched are listed in report.retryOverlaps and printed
  as a WARNING: a clean merge does not prove the retry kept the other task's change.
- local execution: clear the agent timeout timer when the agent exits. It was never cleared, so
  a successful run kept the process alive until the timer fired (15 min); failing runs exited via
  process.exit(1) and hid it. Measured: 2-task run 15m28s -> 1m18s. Regression test included.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016FSVfwwP6TVxGLUWatWM53
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016FSVfwwP6TVxGLUWatWM53
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T18:57:19.611251Z fa8e2bc PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa8e2bc8db

ℹ️ 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".

Comment on lines +230 to +234
const r = await this.execution.execute({ ...unit, id: task.ID, repoPath });
await this.worktrees.removeWorktree(r.worktreePath, repoPath);
retryResults.push(r);
executionResults.push(r);
retries[task.ID] = round;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update task state from the retry execution result

If a retry exits nonzero or times out after changing files, LocalExecution can return a failure result with an auto-committed partial change. This loop merges that commit without updating the task's original completed state. Reproducing with a retry that appends a line and exits 1 yields completed: 2, failed: 0, and two successful merges, so the CLI reports success and exits 0 despite the failed agent. Update the state and error from the latest execution result so retry failures cannot be reported as successful completion.

Useful? React with 👍 / 👎.

Comment on lines +229 to +230
const unit = this.buildUnit(task, repoPath, undefined, note);
const r = await this.execution.execute({ ...unit, id: task.ID, repoPath });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the task-specific Salacia plugin for retries

When Salacia is enabled, retries are built without their scope contract and execute using whichever plugin remains in this.execution.salaciaPlugin from the initial batch. For example, with concurrency 1, if task b conflicts and task c executes afterward, b's retry uses c's plugin; SalaciaPlugin.checkDrift finds no contract for b and returns blocked: false. Consequently, a retry that commits changes to protected paths can bypass the protection enforced on its original attempt. Preserve or recreate the task-specific plugin and use it both when building and executing the retry.

Useful? React with 👍 / 👎.

@2233admin
2233admin changed the base branch from fix/isolate-agent-settings to main October 26, 2026 04:31
@2233admin
2233admin merged commit aa0aafc into main Oct 26, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant