Skip to content

fix(zhipu): 诊断首选 tier 语义拒绝降级问题,增强可观测性并提取跨供应商清洗共享函数#243

Merged
ThreeFish-AI merged 4 commits into
feature/1.x.xfrom
ThreeFish-AI/edmonton-v1
May 23, 2026
Merged

fix(zhipu): 诊断首选 tier 语义拒绝降级问题,增强可观测性并提取跨供应商清洗共享函数#243
ThreeFish-AI merged 4 commits into
feature/1.x.xfrom
ThreeFish-AI/edmonton-v1

Conversation

@ThreeFish-AI

Copy link
Copy Markdown
Owner

Summary

  • 诊断 zhipu 作为首选 tier 频繁返回 400 invalid_request_error 导致降级到 copilot 的问题
  • 通过 curl 实证测试确认 GLM 原生支持 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 对各参数的实际处理方式
  • 测试: 新增 5 个 TestNormalizeForZhipu 测试 + 更新注释

根因诊断进展

日志中 855 次 zhipu semantic rejection 的具体原因尚未从日志中确认(旧日志缺失 error_message)。
增强后的日志部署后可捕获完整错误响应体,届时即可定位真正的 400 触发条件。

🤖 Generated with Claude Code, CodeX, Gemini

根因: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>
@ThreeFish-AI
ThreeFish-AI merged commit bf51e90 into feature/1.x.x May 23, 2026
6 checks passed
@ThreeFish-AI
ThreeFish-AI deleted the ThreeFish-AI/edmonton-v1 branch May 23, 2026 10:08
@ThreeFish-AI ThreeFish-AI mentioned this pull request May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant