Repository navigation
fix(external-engine): 启用 Codex 原生子智能体会话(AIR nativeSubagentSessions + multi_agent_v2) - #6
Merged
Merged
Conversation
…nd multi_agent_v2 codex-acp 2.2.2 strips `clientCapabilities.subagents` (SDK schema) and only emits subagent_spawned for multi_agent_v2 subAgentActivity items. Declare the AIR nativeSubagentSessions capability for Codex and merge features.multi_agent_v2=true into the adapter's CODEX_CONFIG session config, so the existing AIR subagent pipeline produces clickable child sessions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenX123
force-pushed
the
feat/codex-air-subagents
branch
from
November 18, 2026 19:13
a88d90f to
3d76e61
Compare
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.
背景
YCode 经 ACP(
@agentclientprotocol/codex-acp2.2.2)驱动 Codex 时,子智能体只显示为一条不可点击的“子智能体 general-purpose · 子智能体”工具行:没有 AIRsubagent_spawned/subagent_state_update,子线程正文不进入 YCode,现有 AIR 子智能体链路(subagent-frames.tsAIR 分支 + core owner)从未生效。根因(2026-11-19 本机抓帧 + adapter 源码核查)
两个条件同时缺失:
zClientCapabilities解析 initialize,该 schema 没有subagents字段,YCode 声明的subagents: {}在 adapter 内被丢掉;adapter 的clientSupportsSubagents实际只认 AIRcapabilities中的nativeSubagentSessions。subAgentActivity条目上发subagent_spawned,该条目来自 Codexmulti_agent_v2(codex features list:stable,默认 false)。旧 v1 的spawnAgent只登记待宣告子会话,子线程通知缓冲后随子轮结束丢弃。Spike 帧证据(脱敏)
subagents: {}tool_calltitlespawnAgent,无子会话CODEX_CONFIG={"features":{"multi_agent_v2":true}},AIR 只有 sessionFailureagentPath: /root/backend),但仍是旧工具行Start subagent backend/Complete subagent backendnativeSubagentSessionssubagent_spawned {name:"Backend", task:"Delegated task for Backend", capabilities:{}};子 sessionId 下有exec_command工具、tool_call_update、agent_message_chunk、usage_update;子轮结束发subagent_state_update {state:"completed"};主会话 prompt 等全部子会话结束才返回v2 帧不带
prompt,task固定为 adapter 兜底Delegated task for <name>,名称来自agentPath末段。修改
connection.tsclientCapabilities:Codex 的 AIR capabilities 改为["sessionFailure", "nativeSubagentSessions"](只改 initialize 能力,未动 openSession/update/execute/permission)。adapter-env.ts新增withCodexNativeSubagentConfig,index.ts的resolveLaunch只对 Codex 调用:在 adapter 读取的会话配置CODEX_CONFIGJSON 里合并features.multi_agent_v2 = true,保留其余键(API Key 配置的model),按大小写不敏感去重;非 JSON 对象原样保留。不写~/.codex/config.toml,不新增ZCODE_环境变量。能力和特性必须同时开,所以会覆盖同名的 false。subagent-frames.tsAIR 分支:名称取 AIRname;name缺失或等于兜底名Agent <末 8 位>时,取prompt首个非空行的Title: <title>。docs/desktop/external-agent-engines-spec.md(能力声明、启用方式、v2 真实形状、名称规则、验收)与apps/zcode-cli/docs/design/v2/external-agent-engines.md。修改前:Codex 子智能体是不可点击的工具行。修改后:每个子智能体建一个
subagent_child子会话,标题为原生名称,正文和工具写进子会话,可以下钻;结束后状态从 running 变为 ended。验证
bootstrap/tests/fixtures/native-subagents/codex-air-v2.json,走 adapter → Runtime → SQLite → V4 投影:initialize 声明nativeSubagentSessions,子会话标题 Backend/Reviewer,工具和正文落进子会话,结束后running: []、endedTotal: 2。CODEX_CONFIG合并(保留 model、覆盖 false、Claude 不注入、非法 JSON 原样保留);frames 的 v2 真实形状与Title:回退。pnpm -r --if-present run build/typecheck(apps/zcode-cli)通过;adapterstests/external-engine*+session-external-engine通过,bootstraptests/external-engine*29 个通过,coretests/external-engine*70 个通过;根目录pnpm lint0 errors(89 个已有 warning),pnpm architecture:check --changedOK。风险 / 未验证
multi_agent_v2都是 stable、默认 false)。multi_agent_v2版本的 Codex CLI 怎样处理未知 feature 键,没有验证。agentPath命名),模型行为可能和 v1 不同。Delegated task for <name>,Title:约定暂时用不上。nativeSubagentSessions后,session/load会回放子会话历史;按现有规则这些回放帧会被丢弃。🤖 Generated with Claude Code