Skip to content

移除 runtime 的 max_loops 限制并同步 compact 语义#292

Merged
phantom5099 merged 1 commit into
1024XEngineer:mainfrom
wynxing:test_campact
Apr 14, 2026
Merged

移除 runtime 的 max_loops 限制并同步 compact 语义#292
phantom5099 merged 1 commit into
1024XEngineer:mainfrom
wynxing:test_campact

Conversation

@wynxing

@wynxing wynxing commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

背景

当前测试分支需要去掉 runtime 的 max_loops 限制,避免 ReAct 主循环在固定轮数后被 runtime 强制中断。

这次改动同时清理了围绕 max_loopsloop_limit continuation checkpoint 的实现、配置、测试与文档,避免仓库中继续保留已经失效的配置项和语义说明。

变更

  • 移除 runtime.Run() 中的 max_loops 终止判断
  • 移除 loop_limit compact mode 及相关 continuation checkpoint 逻辑
  • 移除 config / YAML 持久化中的 max_loops 配置项
  • 更新相关测试:
    • 删除依赖 max_loops/loop_limit 的旧测试
    • 补充“多轮工具调用仍可继续直到最终 assistant 回复”的回归覆盖
    • 保留并对齐 reactive compact 的多次降级重试语义
  • 同步更新文档:
    • 配置指南不再暴露 max_loops
    • compact / runtime 流程文档不再描述 loop_limit
    • 明确当前 reactive compact 最多 3 次降级尝试
    • 明确 runtime 不再有内部轮数上限,run 结束依赖最终回复、错误或外部取消

影响

  • config.yaml 中如果仍包含 max_loops,现在会按未知字段报错
  • runtime 不再提供内部轮数兜底;如果模型持续输出 tool call,session 会一直运行,直到模型收口、报错或被取消
  • compact 现仅保留 manualautoreactive 三种 mode

验证

  • go test ./internal/runtime ./internal/config ./internal/context/compact
  • go test ./...

@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Focused review completed. I found 2 noteworthy issues (runtime safety bound removal and config migration break).

Comment thread internal/runtime/run.go
return err
}

for {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removing the loop budget turns the run loop into an unbounded execution path. If the model keeps returning tool_calls, this can run indefinitely (unbounded tool invocations/token spend/session growth) until external cancellation. Please keep a hard safety guard (for example a per-run max-turn fail-safe, or a separate safety budget) even if max_loops is removed from user-facing config.

Comment thread internal/config/loader.go
@@ -25,7 +25,6 @@ type persistedConfig struct {
SelectedProvider string `yaml:"selected_provider,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

max_loops was removed from persisted config while strict YAML known-fields decoding is still enforced, so existing user configs containing max_loops now hard-fail to load. If this breaking change is intentional, consider adding a temporary compatibility shim (accept+ignore legacy key) or an explicit migration path in docs/release notes to avoid upgrade-time boot failures.

@phantom5099 phantom5099 merged commit 93fc18b into 1024XEngineer:main Apr 14, 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.

2 participants