Skip to content

feat(acp): apply model/effort for generic ACP workers via advertised config options - #41

Open
qq75221502-cell wants to merge 1 commit into
Fei-Craft:mainfrom
qq75221502-cell:acp-generic-model
Open

qq75221502-cell wants to merge 1 commit into
Fei-Craft:mainfrom
qq75221502-cell:acp-generic-model

Conversation

@qq75221502-cell

@qq75221502-cell qq75221502-cell commented Nov 19, 2026 •

Copy link
Copy Markdown

## Problem

Custom ACP workers (any [agents.<name>] with protocol = "acp", e.g. Google Antigravity's agy acp) are not in _MODEL_EFFORT_AGENTS, so dispatch_task's model/effort are silently ignored (only a task warning). The worker always runs its default model — for agy acp that 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/new returns:

  • 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:

  • For agents outside _MODEL_EFFORT_AGENTS, if the session advertises a model option, apply session.model through the existing _sync_model_option (same fail-loud semantics as the named agents).
  • Tiered coordinator slugs that miss the advertised family list are split into family + tier (gemini-3.8-flash-high → model gemini-3.8-flash, tier high); session.model is rewritten to the applied family so state/audits record reality. This matters for workers like the built-in antigravity adapter whose ids carry the tier.
  • The effort (explicit effort or the tier split out above) is applied to the first advertised option among thought_level / effort / reasoning_effort / thinking; a value with no counterpart warns instead of failing.
  • run_turn's "model/effort were ignored" warning now checks live.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, agy 1.5.12, worker antigravity-acp = agy acp):

  • Before: identity probe answers "Gemini 4 Neon" for every requested model (default; selection dropped).
  • After: 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_level if you point me at the preferred fixture style.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T17:09:32.080561Z 78b7f52 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.

@qq75221502-cell qq75221502-cell changed the title feat(acp): sync model/effort for generic ACP workers via advertised config options feat(acp): apply model/effort for generic ACP workers via advertised config options Nov 19, 2026

@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: 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".

Comment on lines +1540 to +1541
_current, offered = config_option_values(live.config_options, "model")
if offered and session.model not in offered:

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 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

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 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 klarkxy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed via Gemini App · Model: Gemini · Commit: 78b7f5236de1f772ff978ee097f4f970602864c9

整体评估

感谢贡献这一特性!在代码层面,本 PR 当前提交(78b7f523)仍遗留一处使通用 ACP Worker 配置同步完全不生效的白名单早退守卫,以及若干 session.model 原地改写与异常捕获问题;同时由于主干已合入架构级重构 #42(20a0882a),维护者已在保留原始作者提交署名(2674a93a)的基础上基于新架构提交了完整重做版本 PR #46。建议直接转向跟进 #46,待其合入后关闭本 PR 即可。以下记录本 PR 代码本身的审查发现供参考:

1. 建议修复(逻辑缺陷 / 潜在风险)

  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 字段)动态记录。
  2. 原地改写 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 为准。
  3. 缺少 max -> xhigh / off -> none 档位别名映射且未捕获 _set_config_option 的 RequestError

    • 位置:src/agent_bridge/adapters/acp.py:1542, 1555, 1557
    • 修复建议:对通用 ACP Worker 复用统一的档位别名归一化逻辑,并在设置不被对端接受的选项值抛 RequestError 时妥善捕获转换或降级告警,避免直接中断整个回合。

2. 建议改进(边界条件 / 健壮性)

  1. 修正忽略 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 中均已得到覆盖与测试验证)。

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