fix(codex): 适配 MiMo 2.6 Chat 工具调用 - #103
Merged
BigStrongSun merged 1 commit intoSep 22, 2026
Merged
Conversation
MattLYT
force-pushed
the
codex/mimo-opencode-chat-adapter
branch
from
September 22, 2026 06:39
e855104 to
b8ae324
Compare
MattLYT
force-pushed
the
codex/mimo-opencode-chat-adapter
branch
from
September 22, 2026 08:28
b8ae324 to
ba963c1
Compare
按模型能力适配输出上限、工具选择、custom schema 与 FREEFORM 输入契约,统一完整原始补丁的流式/非流式转换。已注册普通函数的无效 JSON 参数保留原文交由 Codex 返回工具解析错误,避免一次参数错误中断整轮或影响并列有效调用;未知和 hosted 工具不放宽。 验证:代理 providers 1126 项回归、Clippy、目标格式和 diff 检查通过;覆盖混合好坏函数调用、控制字符原文及 SSE 一致性、长补丁与续轮。真实 Flash custom 工具/续轮已有验证,本次普通函数错误路径以离线回归和 Codex 原生处理契约核验,未重演原用户任务。
MattLYT
force-pushed
the
codex/mimo-opencode-chat-adapter
branch
from
September 22, 2026 09:02
ba963c1 to
73eec50
Compare
MattLYT
marked this pull request as ready for review
September 22, 2026 09:31
BigStrongSun
added a commit
that referenced
this pull request
Sep 22, 2026
本版内容: - 4 个用户报告问题修复:MFJS 工具 schema 422(#87/#101)、Codex App 跨线程消息 毒化第三方会话(#98,提交 4f76aae)、设置页"应用界面加载失败"(env injection 空状态 wire 契约)、严格诊断版 Codex Desktop unrecognized configuration 警告。 - 社区贡献合入:#95(Responses 重复 namespace 整合)、#97(原生图片编辑官方回退 路由)、#103(MiMo 2.6 Chat 工具调用适配)、#69(Codex 插件登记安全修复)、 #5(actions/cache 5→6)。 - #90 Rust 依赖批次拆批与适配:3 项破坏性 major 升级回退(rusqlite 0.40、 toml 1.0/toml_edit 0.25),其余 55 项保留并做行为等价适配(sha2 0.11 hex 编码、hmac 0.13 KeyInit、tungstenite 0.30/axum 0.8 通配路由与提取器适配), 详见提交 ecd6ce2。 - 既有前端测试回归修复(AddProviderDialog 保存路径补 restore 证据 mock 边界)。 改动: - package.json / src-tauri/Cargo.toml / src-tauri/Cargo.lock / src-tauri/tauri.conf.json:版本 3.20.2-19 -> 3.20.2-20 - docs/release-notes/v3.20.2-20-zh.md / v3.20.2-20-en.md:发布说明 验证: - Rust 全量单线程 4259 passed / 0 failed / 8 ignored - 前端 vitest 1656/1656,typecheck 0 错误 本次提交由BigStrongsSun完成
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.
概述
MiMo V2.6 Pro/Flash 通过 Chat Completions 接入 Codex 时,除了输出上限和工具参数差异,还会遵循原工具的 FREEFORM 描述,直接在 function.arguments 返回原始 apply_patch 补丁。代理此前将其按 JSON 校验并丢弃,导致整轮 response.failed 与客户端重连;完整补丁因此无法执行。
本 PR 在共享 Codex Chat 转换层按 MiMo 模型 ID 适配,适用于不同供应商地址。OpenCode Go 是本次真实联调入口;小米官方原生 Responses API 留待独立适配。
变更
补充 Pro/Flash 目录:1M 上下文、131072 输出、多模态输入、thinking 开关和禁止并行工具。
使用 max_completion_tokens,归一 tool_choice=auto,移除 parallel_tool_calls;仅 MiMo custom 工具启用 strict 与 additionalProperties=false。
明确 Chat 外层 JSON 与内层 FREEFORM/grammar 输入契约。
流式和非流式共用原始补丁归一化:仅 MiMo 2.6、当前已注册的 custom apply_patch、首尾标记完整时,将参数原文封装为 input 字符串。保留 Unicode、换行、引号、反斜杠及工具结果续轮;截断补丁、损坏 custom JSON 和其他 custom 工具继续原校验。
对有明确结束标记的 MiMo 已注册普通函数及 namespace 函数,非法 JSON 参数原样交给 Codex 返回工具解析错误;不再丢弃并升级为整轮流失败。混合调用中的正常工具保留,未知、hosted 和 custom 工具不进入该通路。参数不修补、不改写为可执行内容。
GLM、DeepSeek、Kimi 保持原转换行为,复用既有 thinking/reasoning_content 回放与 SSE 累积机制。
协议依据:MiMo Chat API。
验证
最终修复:
MiMo 定向 Rust 11 项通过;proxy::providers 模块最终 1126 项通过。
超过 16 KiB 的 raw patch 和合法 JSON 分片均逐字无损;覆盖非流式、legacy function_call、续轮回放、截断与损坏参数、其他模型和工具隔离。
混合非法/合法函数调用回归通过:控制字符导致的非法 arguments 在 delta、done 和 completed 中逐字一致,正常调用保留,终止为 response.completed;非流式/legacy 和非 MiMo 隔离通过。
精确 rustfmt、git diff --check、cargo clippy --lib --no-deps 通过,Clippy 仅报告未改文件的既有告警。
真实 Flash 直连合成复现:finish_reason=tool_calls,2681 bytes arguments 直接以 *** Begin Patch 开始、以 *** End Patch 结束;确认错误是 raw/custom 与 JSON/function 契约错配。
安装修复构建后,经本机 15721 Responses→Chat→OpenCode Go Flash:custom_tool_call 完整返回,工具结果续轮正常回复 CANARY_OK,两轮共 790 tokens。合成测试只验证补丁结构,没有执行文件写入。
Tauri 嵌入前端的 debug 构建已部署到本机安装路径;旧可执行文件已备份,部署文件哈希一致,重启与健康检查通过。
已有且未变部分的验证:原提交 Rust 全库 4203 passed / 8 ignored;TypeScript typecheck、目录 Vitest 5 项、目标 Prettier 通过。
边界:复杂动画页面的 3 KiB 在线生成在 90 秒诊断上限内未完成,已停止;用户后续复杂页面任务已生成页面并最终完成,但工具清理阶段出现 238 字节 malformed arguments 与两个并列调用的错误。日志未保存失败参数原文及工具名,不能断言具体坏参数形态。长参数转换由确定性本地回归覆盖,不能将短烟测描述成原任务端到端通过。本次普通函数错误反馈路径通过离线流式/非流式回归及 Codex 原生工具路由 与解析错误反馈机制核验;尚未在原用户任务重演验证。Pro 未追加计费调用。
基线说明
基线 main 7b7aa48 的 CI 已有格式检查失败。此前 PR 检查同样停在未改动的两处前端 Prettier 和 codex_config.rs、codex_subagent_profiles.rs、services/usage_stats.rs 的 Rust 格式检查;本 PR 不纳入这些无关格式修改。最终 HEAD 的检查以 GitHub Checks 为准。
此前全量 Vitest 失败集重跑为 322/323,通过范围外的 AddProviderDialog 因未 mock 的本地接口请求 ECONNRESET 失败。
Checklist
未变化的 TypeScript 部分已通过类型检查与目录测试
最终 Rust 定向/模块回归及 Clippy 通过
目标文件格式检查通过
真实 Flash custom tool 与结果续轮通过
仓库全量格式 CI 通过(存在基线失败)