Add budget config - #9783
Open
samisgod wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Agent 内置了固定的进度检查点:当活跃 todo 连续 8 轮工具调用没有新的主机可见进展(新完成、新读取、新命令、新写入)时,主机强制注入一条“重新评估”提示。该阈值写死在
internal/agent中,对长任务(大范围重构、批量迁移)过低,会频繁打断正常工作流,且用户无法调整或关闭。本 PR 将该检查点变为用户可拥有的设置:
agent.Options新增ProgressBudgetRounds,由NormalizeProgressBudgetRounds统一归一化(0= 内置默认 8;负数 = 关闭;越界值钳制到 3–64)。Goal 模式的二级重规划检查点改为nudgeRounds × 2派生,默认值下与旧行为(8/16)完全一致。[agent]新增两个 TOML 键——progress_budget(*bool,缺省视为开启,仅显式false关闭)与progress_budget_rounds(0= 内置默认);提供SetProgressBudgetEnabled/SetProgressBudgetRounds编辑器方法(关闭时保留轮次数,重新开启即恢复用户阈值而非回退默认值),TOML 渲染/差异输出同步支持。boot构建 executor 时经progressBudgetRoundsFromConfig注入;禁用时传入agent.ProgressBudgetRoundsOff哨兵,保证不会静默回退到内置默认。AgentView暴露progressBudgetEnabled/progressBudgetRounds(始终返回生效值,便于数字输入框直接渲染);新增App.SetProgressBudgetEnabled/App.SetProgressBudgetRoundsWails 方法,复用applyConfigChange自动热重建会话。docs/GUIDE.md、docs/GUIDE.zh-CN.md、reasonix.example.toml补充两个新键的说明。行为对照
0/缺省 = 内置默认)progress_budget_rounds(最高 64)progress_budget = false或 UI 关闭开关2 × nudgeRounds,默认下仍为 16兼容性
AgentView新字段仅追加,不破坏现有 JSON 契约。Changed files
内核(internal/)
internal/agent/storm_breaker.goNormalizeProgressBudgetRounds、ProgressBudgetRoundsOff、DefaultProgressBudgetRounds、progressRedirectRoundsinternal/agent/agent.goOptions.ProgressBudgetRounds;New归一化后写入 agentConfiginternal/agent/agent_config.goprogressBudgetRounds字段internal/agent/goal_run_boundary.gotrackTodoProgress改用配置阈值;<=0跳过催促与 Goal 重定向internal/agent/todo_progress_guard_test.goprogressRedirectRounds(...)internal/config/config.goProgressBudget *bool、ProgressBudgetRounds字段 +ProgressBudgetEnabled()/ProgressBudgetRoundsValue()internal/config/edit.goSetProgressBudgetEnabled/SetProgressBudgetRounds(拒绝负数)internal/config/render.gointernal/boot/task_budget.goprogressBudgetRoundsFromConfig映射(禁用 → off 哨兵)internal/boot/boot.goagent.Options注入桌面端(desktop/)
desktop/settings_app.goAgentView新字段;desktopProgressBudgetRounds帮助函数;SetProgressBudgetEnabled/SetProgressBudgetRoundsdesktop/reasoning_display_app.godesktop/frontend/src/components/SettingsPanel.tsxdesktop/frontend/src/lib/types.tsAgentView.progressBudgetEnabled?/progressBudgetRounds?desktop/frontend/src/lib/bridge.tsdesktop/frontend/src/locales/{en,zh,zh-TW}.tsdesktop/frontend/scripts/check-bundle-budget.mjs文档
docs/GUIDE.md/docs/GUIDE.zh-CN.md[agent]示例补充两个新键reasonix.example.tomlIssues
无关联 issue(功能需求来自桌面端使用反馈:内置阈值过低且不可配置)。
Verification
Go
前端
端到端构建:
wails build成功(含 eslint → tsc → vite → bundle 预算全链),产物desktop/build/bin/reasonix-desktop.exe;CLIbin/reasonix.exe version输出正常。Documentation impact
Documentation-impact: updated —
docs/GUIDE.md、docs/GUIDE.zh-CN.md与reasonix.example.toml已补充agent.progress_budget/agent.progress_budget_rounds两个新键的语义(缺省开启、0 = 内置默认、关闭后保留轮次数)。Cache impact
Cache-impact: none — 不触碰系统提示词、memory 前缀、output style、工具 schema、provider 请求序列化或压缩逻辑。检查点仅改变一条主机生成的用户消息(“Host progress check”/“Host progress redirect”)在会话中的注入时机,该消息本身及注入机制与改动前一致;默认阈值下会话内容与旧版本逐字节相同。
Cache-guard:
go test ./internal/agent/ -run "TestTodoProgress|TestGoalTodoProgress|TestCanonicalTodoProgress"覆盖默认阈值下的催促/重定向注入时机与内容;TestTodoProgressGuardNeverPausesARun保证检查点不会结束运行(与旧行为一致的额外防线)。系统提示词零改动,无需 System-prompt-review。System-prompt-review: N/A