fix(zhipu): 诊断首选 tier 语义拒绝降级问题,增强可观测性并提取跨供应商清洗共享函数#243
Merged
Conversation
根因:zhipu 作为首选 tier 时 source_vendor=None,不触发跨供应商转换通道, 原始请求体含 cache_control/thinking/reasoning_effort 等 GLM 不支持的参数, 导致 400 invalid_request_error 降级到 copilot 浪费 token。 改动: - 新增 normalize_for_zhipu() 共享清洗函数作为 zhipu 兼容性单一事实源 - ZhipuVendor._prepare_request() 覆写应用 GLM 兼容性清洗 - 重构 prepare_copilot_to_zhipu() 委托给 normalize_for_zhipu() 消除重复 - 增强 execute_message 语义拒绝日志输出 error_message 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
…忽略 cache_control/reasoning_effort; 通过 curl 实证测试确认 zhipu Anthropic 兼容端点对以下参数的处理: - thinking 参数:200 OK,GLM 原生支持并返回 thinking content block - cache_control 字段:200 OK,被静默忽略(GLM 使用隐式自动缓存) - reasoning_effort 参数:200 OK,被静默忽略 - extended_thinking 参数:200 OK,被静默忽略 - redacted_thinking block:200 OK,被静默忽略 - 空 messages:400 invalid_request_error [1214][输入不能为空] 根因需进一步诊断:保留 normalize_for_zhipu 共享函数和 executor 日志增强, 待收集到 zhipu 返回的完整错误响应体后定位真正的 400 原因。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](${S}) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
….py 实测结论的矛盾; _ZHIPU_UNSUPPORTED_PARAMS 注释错误声称参数会导致 400 错误,实际 GLM 原生支持 thinking 并静默忽略其余参数; docstring 声称服务于"首选 tier 场景"但无此类调用方,已更正为仅描述跨供应商转换通道的实际用途。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
合并 origin/feature/1.x.x (668858b) 到当前分支,解决 zhipu.py 模块 docstring 冲突:同时保留参数处理实测结论与 429 Rate Limit 重试机制说明。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
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.
Summary
invalid_request_error导致降级到 copilot 的问题thinking参数,静默忽略cache_control/reasoning_effort,这些参数不是 400 的根因execute_message语义拒绝日志输出error_message,为后续根因定位提供可观测性normalize_for_zhipu()跨供应商清洗共享函数,消除prepare_copilot_to_zhipu()的重复代码变更内容
vendor_channels.py: 新增normalize_for_zhipu()共享清洗函数 + 重构prepare_copilot_to_zhipu()委托它executor.py: semantic rejection 日志增加resp.error_message[:200]输出zhipu.py: 补充实测验证注释,记录 GLM API 对各参数的实际处理方式TestNormalizeForZhipu测试 + 更新注释根因诊断进展
日志中 855 次 zhipu semantic rejection 的具体原因尚未从日志中确认(旧日志缺失 error_message)。
增强后的日志部署后可捕获完整错误响应体,届时即可定位真正的 400 触发条件。
🤖 Generated with Claude Code, CodeX, Gemini