Skip to content

bug: Codex CLI 会话异常中断 — ReasoningSummaryDelta 和 apply_patch 类型映射问题 #63

Description

@z-qinghui

问题描述

使用 Codex CLI 通过 moonbridge 连接 DeepSeek V4 Pro 时,会话频繁异常中断,主要有两个错误:

1. ReasoningSummaryDelta without active item

当 DeepSeek 返回 thinking 内容时,moonbridge 无条件发送 response.reasoning_summary_part.addedresponse.reasoning_summary_text.deltaresponse.reasoning_summary_part.done 事件。但 Codex Responses API 在没有 active response item 的情况下无法处理这些事件,导致大量错误(单次会话 1640+ 次)。

错误日志:

ReasoningSummaryDelta without active item

临时修复:adapter.go 中注释掉了 3 处 reasoning summary 事件发送,并在配置中设置 supports_reasoning_summaries: false

2. apply_patch 工具类型映射失败

codex_tool_proxy 扩展启用时,apply_patch 被展开为 5 个代理工具(apply_patch_add_file 等)。但 DeepSeek 有时直接调用 apply_patch 而非代理工具名。此时 BuildToolMapFromCore 构建的映射表中没有 apply_patch 条目,导致 fallback 到 function_call 类型,Codex 无法处理。

错误日志:

Fatal error: tool apply_patch invoked with incompatible payload
apply_patch verification failed: invalid patch: The first line of the patch must be '*** Begin Patch'

临时修复:BuildToolMapFromCore 中增加 fallback 注册逻辑,当代理工具存在时同时注册原始工具名。

环境

  • moonbridge 版本:最新 main 分支
  • Codex CLI 版本:0.134.0
  • 上游模型:DeepSeek V4 Pro(通过 https://api.deepseek.com/anthropic
  • 配置:mode: Transformcodex_tool_proxy 默认启用

建议修复方向

  1. ReasoningSummary: adapter 应检查是否有 active item 才发送 reasoning summary 事件,或在配置 supports_reasoning_summaries: false 时完全跳过
  2. apply_patch 映射: BuildToolMapFromCore 应自动为代理工具注册原始工具名的 fallback 条目

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