Skip to content

[Bug][Codex V2] Longnows 第三方父模型派生第三方子模型时仍生成 opaque 加密 payload #16

Description

@sanjink

Self Checks / 自检

  • 已阅读 README FAQ。
  • 已搜索 open/closed issues,未发现包含相同错误文本或相同 Longnows parent -> Longnows child 复现的 Issue。

CC Switch Version / 版本号

3.19.2-5

Operating System / 操作系统

macOS

Related App / 涉及应用

Codex Desktop / Codex CLI 0.148.0-alpha.9

Summary / 问题摘要

codex_model_router_v2multi_agent_v2.enabled=truetool_namespace="agents" 下,使用 Longnows 第三方模型作为 parent,再派生 Longnows 第三方 child 时,child 仍收到 gAAAAA... 开头的 opaque encrypted_content,随后被 CCSwitchMulti 在发送第三方上游前主动拒绝:

third-party child cannot read encrypted Codex agent payload; use a mixed-router non-reserved agents namespace so the official parent emits plaintext

同一个 child 模型在 OpenAI Official Luna parent 下可以正常收到任务并返回结果。因此问题不是 child 路由、V2 开关或 agents namespace 本身,而是第三方 parent 的 V2 明文投递边界。

Sanitized Configuration / 脱敏配置

model_provider = "codex_model_router_v2"
model = "gpt-5.6-sol-longnows-5-6"

[features.multi_agent_v2]
enabled = true
hide_spawn_agent_metadata = true
tool_namespace = "agents"

MultiRouter 包含:

  • OpenAI Official route:gpt-5.6-luna/sol/terra
  • Longnows Responses route:gpt-5.6-*-longnows-5-6
  • Longnows effective endpoint:https://aimp.longnows.cn/v1/responses

所有凭据均已省略。

Steps to Reproduce / 重现步骤

  1. 启用 Codex Multi-Agent V2,并设置 tool_namespace="agents"
  2. Parent 选择 gpt-5.6-sol-longnows-5-6
  3. 调用 agents.spawn_agent
agent_type = "gpt-5-6-luna-longnows-5-6"
fork_turns = "none"
message = "只返回唯一 CANARY,不调用工具"
  1. Child 创建后立即失败,未能读取 CANARY。

Controlled A/B Canary / 同条件 A/B

测试时间:2026-08-17。

Parent Child Result
OpenAI Official gpt-5.6-luna gpt-5.6-luna-longnows-5-6 成功,准确返回 CANARY
Longnows gpt-5.6-sol-longnows-5-6 gpt-5.6-luna-longnows-5-6 失败,opaque payload

成功路径:

  • Parent session:01a00e33-6621-7b50-804f-ba07530113d4
  • Child rollout:01a00e33-840a-7c81-a154-0fe4d46e13b1
  • Child encrypted_content 字段实际为可打印明文,长度 45,Stage B 可以恢复并投影。
  • Child route 正常出现 request_preparedupstream_status=200

失败路径:

  • Parent session:01a00e36-5666-7cf1-a73d-cb9e6023ee8c
  • Child rollout:01a00e36-7a8e-7d71-af0c-ad748501262c
  • Child content 结构:
    • input_text envelope:长度 94
    • encrypted_content:长度 228
    • 前缀:gAAAAABqgp1O...
  • Router 只记录 child route_resolved,没有后续 request_prepared;错误发生在发送 Longnows 上游之前。

此前较大提示也可稳定复现:opaque encrypted_content 长度 460、前缀同样为 gAAAAA...

Expected Behavior / 期望行为

当第三方 parent 返回的 agents.spawn_agent.arguments.message 本身是可读明文时,Codex V2 应将它作为明文 agent_message 投递给第三方 child;第三方 parent -> 第三方 child 应与官方 parent -> 第三方 child 一样可读。

Actual Behavior / 实际行为

Parent rollout 中 namespace="agents"spawn_agent.arguments.message 为明文,但生成的 child rollout 仍包含真实 Fernet/opaque encrypted_content。CCSwitchMulti 的 Stage B 正确拒绝该密文,因此 child 无法启动。

Code-Level Findings / 代码定位

当前 Stage B 的 project_codex_agent_messages_for_third_party() 已能处理:

  • 标准 plaintext agent_message
  • 被旧 bridge 错标为 encrypted_content 的可打印明文
  • opaque ciphertext 显式 fail-closed

但 Stage A 的 should_make_codex_v2_agents_plaintext() 明确要求:

matches!(app_type, AppType::Codex)
    && official_oauth_request
    && codex_multirouter_needs_plaintext_v2_collaboration(router_provider)

现有测试 agents_plaintext_rewrite_requires_codex_mixed_router_and_official_parent 也明确断言第三方 parent 不执行该 rewrite。

另外,当前生产代码中没有发现为第三方 parent 生成的 agents.spawn_agent/send_message/followup_task function call 补充 encrypted_function_args: [] 的逻辑。Chat -> Responses 的 response_function_call_item(_with_namespace) 只生成 id/type/status/call_id/name/arguments

因此目前第三方 -> 第三方属于条件支持:parent 已经生成可读 agent payload 时 Stage B 可以工作;Longnows 这类最终仍生成 opaque payload 的第三方 parent 不可用。

Suggested Fix / 建议修复方向

在确认 namespace="agents"、函数名属于以下集合且 arguments.message 为明文时:

  • spawn_agent
  • send_message
  • followup_task

为第三方 parent 的 function-call 响应明确提供直接明文语义,例如规范化 encrypted_function_args: [],并覆盖:

  • native Responses passthrough
  • Responses SSE streaming events
  • Chat/Anthropic -> Responses 转换
  • 非流式响应

或者在请求边界扩展非保留 agents.* 的 schema plaintext rewrite,但必须继续保持:

  • 不修改 reserved collaboration.*
  • 不回显或尝试解密真正的 opaque payload
  • official -> official 继续保留加密

建议增加以下回归:

  1. third-party Responses parent -> third-party Responses child
  2. third-party Chat parent -> third-party child
  3. spawn_agent/send_message/followup_task 三类调用
  4. streaming/non-streaming
  5. opaque payload 仍 fail-closed
  6. official parent/child 行为不变

Additional Notes / 补充说明

本机运行二进制包含 codexRouterPlaintextV2Collaboration 和上述 fail-closed 错误文本;已完全重启 CCSwitchMulti/Codex。远端 main 与本机检出的 v3.19.2-5 对应实现一致,因此不像是旧版本或旧进程问题。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions