Repository navigation
fix(title-routes): 归一化客户端标识,标题路由不再因大小写失配而永不命中 - #706
Open
Tan-yi-xiong wants to merge 1 commit into
Open
Tan-yi-xiong wants to merge 1 commit into
Tan-yi-xiong wants to merge 1 commit into
Conversation
title_routing::client_for_request 拿 pipeline::request_source 的 behavior_client(core::client::classify() 的归类名,如 "Codex" / "ZCode" / "Claude Code")与规则里保存的配置 id("codex" / "zcode" / "claude-code")做严格相等比较,两套词汇永远不相等: 1. match_rule 的 rule.clients 比对恒不命中 → 直接返回 None; 2. 即使规则匹配成功,client == CLIENT_CODEX 与 match client 分支 也全部失配,Codex 头部判据与 ZCode / Claude Code 提示词判据 都不可达。 结果是标题生成路由对所有客户端都是死代码:titleRoute 恒为 null、 [Title] 改写日志零条。对照:压缩路由可用,因为它的门卫写死的是 classify 风格的大写 "ZCode"。 修复:新增 canonical_client()(小写 + 空白/下划线折叠为连字符), match_rule 与 client_for_request 的分支判断统一走归一形态。保存侧 validate / client_label 保持严格认小写 id,落库契约与存量数据零迁移; 运行态匹配对大小写与分隔符写法容错,后续新增客户端只要 classify 输出与配置 id 只差大小写/分隔符即自动命中,无需逐客户端加分支。
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
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.
问题
标题生成路由在 v3.5.1 上对所有客户端都永远不会命中(死代码)。
title_routing::client_for_request接收的client来自pipeline::request_source的behavior_client,即core::client::classify()的归类名:core/client.rs:CLIENT_CODEX = "Codex"(大写),classify()对 Codex 系 UA 返回"Codex"、ZCode 返回"ZCode"、claude-cli 返回"Claude Code"config/title_routes.rs:CLIENT_CODEX = "codex"(小写),CLIENTS = [("zcode", …), ("claude-code", …), ("codex", …)],面板保存的规则clients就是这些小写 id两套词汇在函数内三处严格相等比较全部失配:
因此
client_for_request恒返回None:titleRoute恒为 null,[Title]改写日志零条。对照旁证:压缩路由能用,因为compact_routing::client_for_request门卫写死的是 classify 风格的大写"ZCode"。实测证据(OP3T 部署的 v3.5.1):带
x-openai-subagent: thread_title的/v1/responses标题请求(Codex Desktop UA)走普通模型映射返回 200,titleRoute=null;x-codex-turn-metadata、client_metadata.thread_source等四种触发变体全部未命中;网关日志历史零条[Title]改写记录。修复
新增
canonical_client()(小写 + 空白/下划线折叠为连字符),两处统一走归一形态:config/title_routes.rs::match_rule—rule.clients比对前对两侧归一;core/title_routing/mod.rs::client_for_request— Codex 分支判断、ZCode/Claude Code 提示词分支、CLIENTS回查都改用归一后的 id。兼容性设计
validate()/client_label()/ 面板 supported clients 仍只认小写 id,API 契约不变;rules.clients: ["codex"]直接兼容,运行态匹配同时容错"Codex"等写法;classify()输出与配置 id 只差大小写/分隔符即自动命中,无需逐客户端加映射分支。验证
cargo check -p agent2api-server通过(仅既有警告);codex → <标题模型>规则后,携带x-openai-subagent: thread_title的 Codex 标题请求应产生[Title] … 标题生成:source → target日志且请求统计titleRoute非空。