Repository navigation
feat(acp): apply model/effort for generic ACP workers via advertised config options - #41
qq75221502-cell wants to merge 1 commit into
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 78b7f5236d
ℹ️ 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".
| _current, offered = config_option_values(live.config_options, "model") | ||
| if offered and session.model not in offered: |
There was a problem hiding this comment.
Cache advertised config options for generic ACP workers
For custom ACP workers, _remember_config_options() still returns early unless the name is in _CONFIG_OPTION_AGENTS, but every name in that set is excluded from this fallback. Consequently, lifecycle and config-update responses never populate live.config_options for workers reaching this code. Generic effort selection never runs, and a tiered ID such as gemini-3.8-flash-high is sent unchanged and rejected even when the worker advertises the corresponding family and effort. Allow generic workers to populate and refresh the config snapshot before using it here.
Useful? React with 👍 / 👎.
| if self.agent.name not in _MODEL_EFFORT_AGENTS and (task.model or task.effort): | ||
| if ( | ||
| self.agent.name not in _MODEL_EFFORT_AGENTS | ||
| and not live.applied_model |
There was a problem hiding this comment.
Warn when effort is ignored despite an applied model
When a generic worker accepts the model but advertises no supported effort option, _sync_model_option() sets live.applied_model, while the effort-option loop exhausts its candidates without adding a warning. This new condition then suppresses the existing ignored-parameter warning too. A dispatch with a valid model and effort=high therefore completes with unchanged effort and an empty warnings list, leaving the coordinator unaware that its effort request was ignored. Check effort support separately or emit a warning when no compatible effort option exists.
Useful? React with 👍 / 👎.
klarkxy
left a comment
There was a problem hiding this comment.
Reviewed via Gemini App · Model: Gemini · Commit:
78b7f5236de1f772ff978ee097f4f970602864c9
整体评估
感谢贡献这一特性!在代码层面,本 PR 当前提交(78b7f523)仍遗留一处使通用 ACP Worker 配置同步完全不生效的白名单早退守卫,以及若干 session.model 原地改写与异常捕获问题;同时由于主干已合入架构级重构 #42(20a0882a),维护者已在保留原始作者提交署名(2674a93a)的基础上基于新架构提交了完整重做版本 PR #46。建议直接转向跟进 #46,待其合入后关闭本 PR 即可。以下记录本 PR 代码本身的审查发现供参考:
1. 建议修复(逻辑缺陷 / 潜在风险)
-
_remember_config_options仍保留_CONFIG_OPTION_AGENTS白名单早退,导致通用 ACP Worker 的live.config_options永远为空- 位置:
src/agent_bridge/adapters/acp.py:71-76, 1016-1022, 1534-1566 - 触发条件:任何不在硬编码
_CONFIG_OPTION_AGENTS(仅codex/claude)集合中的通用 ACP Worker(如 Gemini CLI 或第三方 ACP Agent)在session/new或session/load中返回configOptions。 - 原因分析:虽然
_apply_session_settings新增了通用 ACP 分支并读取live.config_options,但上游记录配置项的_remember_config_options第1018行依然执行if self.agent.name not in _CONFIG_OPTION_AGENTS: return,导致通用 ACP Worker 的live.config_options始终停留在空列表[],模型后缀档位拆分(如gemini-3.8-flash-high)与thought_level/effort下发在运行时永远不会触发。 - 修复建议:放开
_remember_config_options对通用 ACP Worker 的白名单限制,按 Worker 实际宣告的configOptions(优先依据 ACP 标准category字段)动态记录。
- 位置:
-
原地改写
session.model = family破坏会话持久化意图并导致跨重载档位丢失与旧effort覆盖- 位置:
src/agent_bridge/adapters/acp.py:1545-1549 - 触发条件:传入带思考档位后缀的复合模型名(如
family-high),随后会话空闲回收重载、切换回不带后缀的family,或之前残留了显式session.effort;亦或底层拒绝该模型调用。 - 原因分析:直接执行
session.model = family原地覆写了会话对象,不仅在空闲重载后丢失了原本隐含在模型名中的tier,还会让历史残留的session.effort反过来覆盖新指定的复合模型档位;从family-high切回基础family时无法复位底层档位,且在下发失败时也会污染session.model。 - 修复建议:保持用户请求的
session.model不被原地篡改,将解析出的生效底层模型与档位单独保存在运行态live上,并以回读确认后的currentValue为准。
- 位置:
-
缺少
max -> xhigh/off -> none档位别名映射且未捕获_set_config_option的RequestError- 位置:
src/agent_bridge/adapters/acp.py:1542, 1555, 1557 - 修复建议:对通用 ACP Worker 复用统一的档位别名归一化逻辑,并在设置不被对端接受的选项值抛
RequestError时妥善捕获转换或降级告警,避免直接中断整个回合。
- 位置:
2. 建议改进(边界条件 / 健壮性)
- 修正忽略
effort的告警条件并补充单元测试- 位置:
src/agent_bridge/adapters/acp.py:1773 - 问题与建议:当通用 ACP Worker 仅宣告支持
model而不支持thought_level/effort时,and not live.applied_model条件会误把“effort 被忽略”的提示吞掉;建议补充基于 Fake ACP Worker 的单元测试覆盖配置发现、复合模型拆分与回退逻辑(注:以上问题在 PR #46 中均已得到覆盖与测试验证)。
- 位置:
## Problem
Custom ACP workers (any
[agents.<name>]withprotocol = "acp", e.g. Google Antigravity'sagy acp) are not in_MODEL_EFFORT_AGENTS, sodispatch_task'smodel/effortare silently ignored (only a task warning). The worker always runs its default model — foragy acpthat is Gemini 4 Neon regardless of the requested model.Meanwhile such sessions often do advertise the standard typed config surface.
agy acp(v1.5.12)session/newreturns:configOptions[id=model]: base families (gemini-4-neon,gemini-3.8-flash,claude-opus-5-5, …)configOptions[id=thought_level]:low/medium/high/xhigh## Change
Add
_sync_generic_acp_selection, appended to_sync_selection:_MODEL_EFFORT_AGENTS, if the session advertises amodeloption, applysession.modelthrough the existing_sync_model_option(same fail-loud semantics as the named agents).gemini-3.8-flash-high→ modelgemini-3.8-flash, tierhigh);session.modelis rewritten to the applied family so state/audits record reality. This matters for workers like the built-inantigravityadapter whose ids carry the tier.effortor the tier split out above) is applied to the first advertised option amongthought_level/effort/reasoning_effort/thinking; a value with no counterpart warns instead of failing.run_turn's "model/effort were ignored" warning now checkslive.applied_model, so a successfully synced generic worker no longer reports the selection as ignored.Named agents (
grok,kimi,zcode, …) keep their dedicated sync paths untouched; the generic path self-exits for them.## Evidence
Local install patched identically (Windows,
agy1.5.12, workerantigravity-acp=agy acp):model=gemini-3.8-flash+thought_level=low→ answers "Gemini 3.8 Flash";gemini-4-neon+high→ "Gemini 4 Neon,思考档位:高";claude-opus-5-5+low→ "Claude Opus 5.5".Happy to add a unit test against a fake ACP worker advertising
model+thought_levelif you point me at the preferred fixture style.