Repository navigation
fix(model-proxy): 移除工具调用的额外数量限制 - #1763
Merged
Merged
Conversation
xiongz-c
force-pushed
the
codex/proxy-tool-call-limit
branch
from
October 9, 2026 09:55
eec82b0 to
9feed56
Compare
xiongz-c
marked this pull request as ready for review
October 9, 2026 10:08
xiongz-c
requested review from
47seek,
LucasIcarus,
deepcoldy and
xiaoxueSunn
as code owners
October 9, 2026 10:08
xiongz-c
force-pushed
the
codex/proxy-tool-call-limit
branch
from
October 9, 2026 10:10
9feed56 to
354f38c
Compare
Owner
|
已 squash 合入 master(462c7bf80),感谢贡献。 合入后保留的行为: 说明:两个 commit 合为一个,最终树只包含移除固定 16 次限制这一净改动(第一个 commit 引入的 |
|
🚀 Released in v3.39.0 |
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.
背景 / 动机
模型透明代理的
POST /v1/chat/completions在单条 assistant 消息上额外限制最多 16 个工具调用。即使调用方允许多个调用、原生推理成功且每个调用都合法,只要返回 17 个或更多,代理仍会返回 HTTP 502tool_choice_violation;包含同样调用数量的历史消息也会在请求解析时返回 HTTP 400unsupported_or_invalid_parameter。根因是模型透明代理在响应转换和历史解析中自行添加了固定数量阈值。这个阈值既不是调用方指定的工具选择规则,也不是 Botmux 公共受约束执行层的限制。代理只返回工具调用建议,实际执行和并发由调用方管理,因此该阈值无法控制工具执行并发,却会拒绝原本有效的协议数据。
改动
parallel_tool_calls:false最多一个调用、tool_choice、工具名称和参数逐项校验,以及历史调用 ID 与结果的完整关联校验。默认值 / 兼容性依据
OpenAI Function calling 指南允许
auto/required返回多个调用,parallel_tool_calls:false则限制为零个或一个。移除的是代理额外施加的固定 16 次阈值;本次没有新增替代阈值或配置项。现有
tools最多 128 项限制针对可用函数定义,同一函数仍可被多次调用。请求体 1 MB、最多 2000 条消息、序列化 prompt 512000 字符、原生输出收集 8 MB,以及推理 deadline 和并发限制继续生效。这不代表模型或调用方可以无限输出、执行工具。测试覆盖
none时,仍可接收上一轮的多调用历史。验证
本次验证基于 Bun 1.4.2、Codex CLI 0.153.4:
354f38cbf的 完整 CI 通过:三个 Node 测试分片及汇总、Bun 全量测试、构建、Linux glibc/musl 与 macOS 二进制检查;对应提交的 CodeQL 分析和网络边界检查也通过。bun x vitest run --project unit test/model-proxy.test.ts test/constrained-invocation.test.ts test/ipc-constrained-invocation.test.ts test/model-only-print.test.ts test/find-launched-cli-pid.test.ts -t '^(?!returns structured syntax/content-size)':114 项通过,1 项单独排除。排除的既有大请求用例在本机运行出现ECONNRESET,未修改代理的基线也复现,不能据此宣称本地全部测试通过。BOTMUX_CONSTRAINED_CODEX=codex bun x vitest run --project e2e test/constrained-codex.e2e.ts:8 项通过,2 项可选集成测试因未配置跳过。bun run build、git diff --check通过。bun test --timeout 180000 <file>:test/find-launched-cli-pid.test.ts29 项、test/model-proxy.test.ts52 项、test/constrained-invocation.test.ts14 项全部通过。以上原生验证使用合成 provider,未验证真实模型生成效果,尚未部署。
影响范围
行为变化仅发生在模型透明代理的请求解析和响应转换,对使用该入口的已适配 CLI 一致生效。直接受约束调用接口及普通交互式 CLI 会话不经过这两处检查。
共享执行层、原生 CLI 适配、生成提示、输出 schema、权限和进程隔离机制均未修改;已有正常请求的幂等 fingerprint 保持不变。