Skip to content

fix(delegation): defer activeModel Thinking validation to Adapter open - #1220

Merged
iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
lpmasser:fix/acp-active-model-thinking-delegation
Nov 26, 2026
Merged

iruriQ merged 1 commit into
BytePioneer-AI:mainfrom
lpmasser:fix/acp-active-model-thinking-delegation

Conversation

@lpmasser

Copy link
Copy Markdown
Contributor

Summary

Devin 与 CodeBuddy/WorkBuddy 的 ACP configOptions 只返回当前激活模型的 thought_level 选项,其余模型在 inspect() 目录里省略 supportedThinkingOptionIds。此前委派预检(resolveDelegationConfiguration)把缺失的 supportedThinkingOptionIds 一律按空数组处理,导致显式传 --model <非默认模型> --thinking <档位> 在调用 adapter.open() 前即以 validThinkingOptionIds: [] 被拒绝,而对应的 Adapter(DevinAdapter.open()、CodeBuddySession.initialize())原本就已支持先切换模型、再按目标模型真实返回的 thought_level 校验并应用思考档位。

本 PR 最小化收口为四处改动:

  1. 共享目录契约(@codexhost/shared-contracts):在 harnessModelCatalogSchema 新增向后兼容的可选字段 thinkingOptionsScope: z.enum(["catalog", "activeModel"]).optional()(省略默认为 "catalog",既有 Adapter、第三方插件与测试零改动)。
  2. ACP Adapter 声明(devin、codebuddy):在仅观测当前激活模型 thought_level 的 ACP 目录上标 thinkingOptionsScope: "activeModel"(同时覆盖复用 CodeBuddy 配置构建的 WorkBuddy)。
  3. 委派预检与错误归类(@codexhost/host-runtime):
    • 当目录声明 thinkingOptionsScope: "activeModel" 且目标模型在目录中省略 supportedThinkingOptionIds 时,对调用方显式传入的 --thinking 放行交给 adapter.open() 切换模型后由原生面校验(即使当前激活默认模型本身无 thought_level,例如 Devin 默认落在无思考档位的模型时,切往其他支持思考的模型仍可生效);
    • 若调用方仅显式传 --thinking(未显式传 --model)且原生默认模型已确认支持该档位,仍优先回退到原生默认模型;非显式的已保存委派默认思考档位仍按既有规则静默回退;
    • 仅在本次走延后校验路径时,将 adapter.open() 返回的 invalidRequest / unsupported 映射为 INVALID_ARGUMENT,非延后创建路径保持原有 DELEGATION_FAILED 契约;
    • harness inspect 紧凑/文本输出在 thinkingOptionsScope === "activeModel" 时透出该字段,并同步 docs/architecture/delegation-defaults.md。
  4. 聚焦回归测试:补充契约解析、Devin 无 thought_level 默认模型起步切换并设置档位、CodeBuddy 目录声明、harness inspect 输出以及 HarnessDelegationCoordinator 延后校验、原生拒绝回滚与兼容回退用例。

Related issues

无 / N/A

UI Demo

No visual changes: 仅涉及共享模型目录契约、Devin/CodeBuddy ACP 目录声明与 Host 委派配置预检逻辑,未修改界面。

Test plan

  • npx tsc -b packages/shared-contracts packages/adapters/devin packages/adapters/codebuddy packages/host-runtime:通过(exit 0)
  • npx tsc -p tests/tsconfig.json --noEmit:全部 12 个改动代码与测试文件 0 报错
  • npx vitest run --config tests/vitest.config.js 定向测试(8 个测试文件,共 216 项全部通过):
    • packages/shared-contracts/test/harness-models.test.ts(13/13)
    • packages/adapters/devin/test/thinking.test.ts(30/30)、devin-adapter.test.ts(18/18)、configuration.test.ts(14/14)
    • packages/adapters/codebuddy/test/history-projection.test.ts(42/42)、codebuddy-adapter.test.ts(36/36)
    • packages/host-runtime/test/delegation-cli-output.test.ts(13/13)、harness-delegation-coordinator.test.ts(50/50)
  • 改动文件的 npx eslint、npx prettier --check、node tools/check-boundaries.mjs、git diff --check:均通过(exit 0)

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 新功能
    • 支持按当前活动模型识别 Thinking 选项。切换模型后,可使用该模型适用的 Thinking 设置。
    • 当目标模型的可用选项尚未确认时,系统会在启动会话时验证显式指定的选项。
  • 问题修复
    • 优化 Thinking 设置的默认值回退:保留已保存默认设置的原有回退行为,并在原生默认模型明确支持指定选项时优先选择该模型。
    • 对不受支持的 Thinking 选项提供更明确的启动错误反馈。

模型目录现在可声明 Thinking 选项仅适用于活动模型。委派配置解析器会对未观测模型的显式选项延后校验,并在适配器打开会话时处理指定校验错误。目录输出、适配器配置、测试和架构文档也作了相应更新。

Changes: 活动模型 Thinking 选项

Layer / File(s) Summary
声明活动模型选项范围
packages/shared-contracts/src/harness-models.ts, packages/shared-contracts/src/index.ts, packages/shared-contracts/test/harness-models.test.ts, packages/adapters/codebuddy/src/configuration.ts, packages/adapters/codebuddy/test/history-projection.test.ts, packages/adapters/devin/src/models.ts, packages/adapters/devin/test/thinking.test.ts
共享目录 schema 新增 thinkingOptionsScope,可取 catalog 或 activeModel。CodeBuddy 和 Devin 的目录声明 activeModel。新增测试覆盖字段解析及模型切换后的 Thinking 选项配置。
延后校验与错误映射
packages/host-runtime/src/delegation-configuration.ts, packages/host-runtime/src/harness-delegation-coordinator.ts, packages/host-runtime/test/harness-delegation-coordinator.test.ts
当显式 Thinking 选项对应的模型未提供支持列表且范围为 activeModel 时,配置解析器标记延后校验。适配器打开会话返回 invalidRequest 或 unsupported 时,协调器将错误映射为 INVALID_ARGUMENT。测试覆盖活动模型即时校验、默认值回退和打开失败处理。
目录范围输出与处理说明
packages/host-runtime/src/delegation-cli-output.ts, packages/host-runtime/test/delegation-cli-output.test.ts, docs/architecture/delegation-defaults.md
精简目录输出在 activeModel 范围下保留作用域字段。测试覆盖 compact、JSON 和文本输出。架构文档说明显式选项延后校验及已保存默认值的回退规则。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant DelegateStart
  participant ConfigurationResolver
  participant DelegationCoordinator
  participant Adapter
  DelegateStart->>ConfigurationResolver: 提交显式 Thinking 选项
  ConfigurationResolver-->>DelegationCoordinator: 返回配置和延后校验标记
  DelegationCoordinator->>Adapter: 调用 adapter.open()
  Adapter-->>DelegationCoordinator: 返回 invalidRequest 或 unsupported
  DelegationCoordinator-->>DelegateStart: 映射为 INVALID_ARGUMENT
Loading

Possibly related issues

  • BytePioneer-AI/codex-host#1084:该 Issue 涉及委派时使用 --thinking 选择思考强度。本 PR 覆盖其显式选项预检查和延后校验失败映射为 INVALID_ARGUMENT 的相关目标;# 菜单 UI 部分不在本 PR 范围内。

Suggested reviewers: bytepioneer-ai, ump45nose

Merge Risk: Minimal · up to 88c04

Explicit --thinking values for non-default models on active-model-scoped catalogs (Devin, CodeBuddy) are now validated after the model switch instead of being rejected up front. Invalid values still surface as INVALID_ARGUMENT, and the changed paths have targeted test coverage. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(delegation): defer activeModel Thinking validation to Adapter open”准确描述了主要变更:对 activeModel 作用域的 Thinking 校验延后到 adapter.open() 执行。变更涉及共享契约、Devin/CodeBuddy 目录声明、委派预检与错误映射,标题覆盖了核心意图。
Description check Passed 描述详细说明了问题背景(Devin 与 CodeBuddy/WorkBuddy 的 ACP configOptions 仅返回激活模型的 thought_level)、四处改动、测试计划及验证结果,与变更集直接相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 466d54c and 88c040c.

Files selected for processing: 13

  • docs/architecture/delegation-defaults.md
  • packages/adapters/codebuddy/src/configuration.ts
  • packages/adapters/codebuddy/test/history-projection.test.ts
  • packages/adapters/devin/src/models.ts
  • packages/adapters/devin/test/thinking.test.ts
  • packages/host-runtime/src/delegation-cli-output.ts
  • packages/host-runtime/src/delegation-configuration.ts
  • packages/host-runtime/src/harness-delegation-coordinator.ts
  • packages/host-runtime/test/delegation-cli-output.test.ts
  • packages/host-runtime/test/harness-delegation-coordinator.test.ts
  • packages/shared-contracts/src/harness-models.ts
  • packages/shared-contracts/src/index.ts
  • packages/shared-contracts/test/harness-models.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check macos-26
  • GitHub Check: Vitest
  • GitHub Check: Static checks
  • GitHub Check: Check windows-latest
  • GitHub Check: Web Host tests
Additional context used

Code guidelines: 3

CLAUDE.md — auto-discovered
AGENTS.md — auto-discovered
docs/product/standalone-web.md — auto-discovered
Path-based instructions: 5

Source excerpt: `shared-contracts` must remain browser-safe and independent of other Workspace packages.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/shared-contracts/src/harness-models.ts
  • packages/shared-contracts/src/index.ts
  • packages/shared-contracts/test/harness-models.test.ts
Source excerpt: Host Runtime loads installed plugins through public contracts, not direct imports of concrete Adapter packages.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/host-runtime/src/delegation-cli-output.ts
  • packages/host-runtime/src/delegation-configuration.ts
  • packages/host-runtime/src/harness-delegation-coordinator.ts
  • packages/host-runtime/test/delegation-cli-output.test.ts
  • packages/host-runtime/test/harness-delegation-coordinator.test.ts
Applicability reference: AGENTS.md: # Repository Guidelines `npm start` / `npm start web` rebuild and relaunch the user's Desktop / Web and may restart the shared Host; `npm stop` stops all local codexhost services across worktrees.

CodeRabbit inference engine (docs/product/standalone-web.md)

Files:

  • packages/adapters/codebuddy/src/configuration.ts
  • packages/adapters/codebuddy/test/history-projection.test.ts
  • packages/adapters/devin/src/models.ts
  • packages/adapters/devin/test/thinking.test.ts
Source excerpt: Harness-specific protocol details must remain inside the corresponding Adapter.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/adapters/codebuddy/src/configuration.ts
  • packages/adapters/codebuddy/test/history-projection.test.ts
  • packages/adapters/devin/src/models.ts
  • packages/adapters/devin/test/thinking.test.ts
Source excerpt: Use package public exports for cross-package dependencies.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/adapters/codebuddy/src/configuration.ts
  • packages/adapters/codebuddy/test/history-projection.test.ts
  • packages/adapters/devin/src/models.ts
  • packages/adapters/devin/test/thinking.test.ts
  • packages/host-runtime/src/delegation-cli-output.ts
  • packages/host-runtime/src/delegation-configuration.ts
  • packages/host-runtime/src/harness-delegation-coordinator.ts
  • packages/host-runtime/test/delegation-cli-output.test.ts
  • packages/host-runtime/test/harness-delegation-coordinator.test.ts
  • packages/shared-contracts/src/harness-models.ts
  • packages/shared-contracts/src/index.ts
  • packages/shared-contracts/test/harness-models.test.ts
Additional comments: 3

packages/adapters/codebuddy/src/configuration.ts: 1

90-90: Functional Correctness

CodeBuddy 按切换后的 Model 配置验证显式 Thinking,不需要修改。

open() 先切换 Model,再设置 thought_level。#configure 会在每次成功配置后更新 this.#config,之后的 thought_level 检查使用的是切换后的选项列表。因此,目标 Model 列出的 Thinking 值会被接受,未列出的值会在本地以 invalidRequest 拒绝,且不会发出原生请求。评论中“提前检查旧能力”和“沿用旧支持列表接受 high”两种失败路径,都与此代码路径不符。

packages/host-runtime/src/harness-delegation-coordinator.ts: 2

391-392: Functional Correctness

该疑点不成立。DevinHistoryError 经 devinError 转换时保留原始 code(adapter.ts:72-73)。thinking.select 失败时,selected.error.code 也会原样包装进 DevinHistoryError(adapter.ts:240),再经 open() 的 catch 由 devinError 返回(adapter.ts:267-278)。因此,opened.error.code 在原生校验返回 invalidRequest 或 unsupported 时仍是这两个值,第 391-392 行的判断可以命中,不会退回 DELEGATION_FAILED。

仍未检查的是 devinError 第 74-86 行的非 DevinHistoryError 回退分类,以及 execute 返回的原生错误如何被映射为这两个代码。这些属于上游分类是否产生这两个代码的问题,与本行判断是否丢失代码无关,因此不构成本条评论的依据。

341-341: Functional Correctness

真实 Devin Adapter 在模型切换后使用新目录校验 thinking.select,不会拒绝切换后支持的 max。

该问题的前提是:切换模型后,thinking.select 仍读取切换前的目录。源码不支持这一前提。open() 先执行 model.select。该命令在 #applyConfiguration 中替换 this.info.configOptions(packages/adapters/devin/src/adapter.ts:441)。随后 thinking.select 调用 devinThinking(this.info)(packages/adapters/devin/src/adapter.ts:552),因此使用的是切换后的配置。

@iruriQ
iruriQ merged commit 9255d46 into BytePioneer-AI:main Nov 26, 2026
7 of 8 checks passed
@iruriQ

iruriQ commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

感谢修复!thinkingOptionsScope 契约向后兼容,正确将多模型切换的思考档位校验延后到 Adapter 打开阶段;已核实 macOS CI 失败为无关 antigravity 200ms 初始化超时抖动,现已合并。

@lpmasser
lpmasser deleted the fix/acp-active-model-thinking-delegation branch November 27, 2026 03:09
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