Skip to content

feat(agent): add bounded implementation retry loop - #79

Merged
NianJiuZst merged 1 commit into
NianJiuZst:mainfrom
dangzitou:codex/issue-76-bounded-retry
Jun 26, 2026
Merged

feat(agent): add bounded implementation retry loop#79
NianJiuZst merged 1 commit into
NianJiuZst:mainfrom
dangzitou:codex/issue-76-bounded-retry

Conversation

@dangzitou

@dangzitou dangzitou commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Related to #76
这个 PR 为 agent implementation 阶段增加了一个有边界的重试 loop,让 OpenMeta 在第一次 implementation draft 返回 needs_review 时,不会立刻收口为 artifact-only,而是先保守地补充少量相邻上下文,再重试生成 concrete patch。

之前的行为更像:

  1. patch draft 生成完成
  2. 第一次 implementation 尝试返回 needs_review
  3. 直接结束为 review/artifact 模式
  4. 最终 changed files: none

这在一些“其实已经很接近可改,只是还差几个邻近文件”的场景里会过早放弃。

这次改动的目标不是放宽安全门,也不是引入无限 agent loop,而是给 implementation 一个小范围、可控、保守的二次推进空间。

What changed

  • 在 agent orchestration 中加入 bounded implementation retry loop
  • 当第一次 implementation draft 需要更多上下文时,按小批量补充相邻上下文后再重试
  • 限制重试次数和上下文扩张规模,避免无界增长和 token 浪费
  • 在 machine-readable 结果中暴露 retry 诊断信息:
    • implementationAttempts
    • implementationStopReason
    • implementationContextFilesAdded
  • 补充测试,覆盖:
    • 上下文扩展后重试成功
    • 达到边界后正确停止
    • machine 输出中的 retry diagnostics
    • workspace context expansion 行为

Design goals

  • 保持 agent 默认保守
  • 不让上下文扩展变成全仓库无方向蔓延
  • 提高“第一次实现只差一点上下文”的场景下生成真实 changed files 的概率
  • 如果模型在补充上下文后仍然不能安全改动,继续保留现有 artifact-only / review fallback

Scope

这个 PR 有意保持最小改动:

  • 不引入开放式 autonomous loop
  • 不做大范围重构
  • 不放宽现有安全门

目标是以尽量低的 upstream conflict 风险,提高 implementation 阶段的跟进能力。

Validation

  • bun run typecheck
  • bun run check
  • bun run build
  • bun test
image

Notes

这个 PR 不保证每个 issue 最终都会产出 patch。

它主要解决的是这样一类情况:第一次 implementation draft 已经接近可用,但还缺少少量局部上下文,导致 agent 过早停止。


Summary

This PR adds a bounded implementation retry loop to the agent flow so OpenMeta can conservatively expand local context before falling back to artifact-only / review mode.

Previously, the flow often behaved like this:

  1. patch draft is generated
  2. the first implementation attempt returns needs_review
  3. the run exits into artifact/review mode immediately
  4. final result is changed files: none

That can be too eager to give up in cases where the model is already close and only needs a few adjacent files to produce a safe patch.

The goal here is not to relax safety gates or introduce an open-ended autonomous loop, but to give implementation a small, controlled, conservative retry window.

What changed

  • add a bounded implementation retry loop in agent orchestration
  • expand implementation context in small adjacent batches before retrying patch generation
  • cap retry attempts and expansion size to avoid unbounded growth and token waste
  • expose retry diagnostics in machine-readable results:
    • implementationAttempts
    • implementationStopReason
    • implementationContextFilesAdded
  • add tests covering:
    • successful retry after context expansion
    • bounded stop behavior
    • machine-output retry diagnostics
    • workspace context expansion behavior

Design goals

  • keep the agent conservative by default
  • avoid turning context expansion into repository-wide drift
  • improve the chance of producing real changed files when the first implementation attempt is only slightly under-contextualized
  • preserve the existing artifact-only / review fallback when the model still cannot produce a safe patch

Scope

This PR intentionally keeps the change small:

  • no open-ended autonomous loop
  • no broad refactor
  • no relaxation of existing safety gates

The goal is to improve implementation follow-through with minimal upstream conflict risk.

Validation

  • bun run typecheck
  • bun run check
  • bun run build
  • bun test

Notes

This PR does not guarantee that every issue will end with a patch.

It specifically improves the case where the first implementation draft is close, but still needs a small amount of additional local context before a safe patch can be generated.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@NianJiuZst
NianJiuZst merged commit e87f456 into NianJiuZst:main Jun 26, 2026
2 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.

3 participants