Skip to content

diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志,定位 zhipu glm-4.7 [1210] 祸根参数#244

Merged
ThreeFish-AI merged 1 commit into
feature/1.x.xfrom
ThreeFish-AI/sacramento-v1
May 23, 2026
Merged

diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志,定位 zhipu glm-4.7 [1210] 祸根参数#244
ThreeFish-AI merged 1 commit into
feature/1.x.xfrom
ThreeFish-AI/sacramento-v1

Conversation

@ThreeFish-AI

@ThreeFish-AI ThreeFish-AI commented May 23, 2026

Copy link
Copy Markdown
Owner

背景

日志分析发现 zhipu vendor 处理 claude-haiku-*glm-4.7 请求时间歇性返回 [1210][API 调用参数有误](7/170 ≈ 4.1%),导致所有失败请求降级到 copilot,影响响应延迟和成本。

间接证据

  • [1210] 只影响 haiku 请求:7 次 rejection 后 copilot 接管的全是 claude-haiku-4-5-20251001
  • glm-4.7 模型有效:163/170 次成功(含真实 token),问题在参数而非模型名
  • 时段对比:22:30 时段 transition channel 剥离 thinking_blocks + cache_control + thinking_param 后 42 次全部成功;22:24 时段只剥离 cache_control 后全部失败
  • 证据缺口:日志无请求体内容记录,无法直接证明失败请求包含了哪些具体参数

变更内容

src/coding/proxy/routing/executor.py 的语义拒绝路径增加请求体可疑参数诊断快照:

  1. 新增 _build_semantic_rejection_diagnostic() 共享函数,提取请求体中的可疑字段
  2. execute_message 的非流式 semantic rejection 日志处附加诊断上下文
  3. _handle_http_error 的流式 semantic rejection 返回前附加等价诊断日志

诊断内容包括:thinking/extended_thinking/reasoning_effort 顶层参数值、会话历史中 thinking blocks 数量、cache_control 存在情况、模型名、消息条数。

实现细节

  • 诊断函数为纯函数,无副作用,仅遍历请求体提取关键字段
  • 流式路径仅在 request_body is not None 时输出诊断(避免 NPE)
  • 不影响现有请求处理逻辑和熔断器行为
  • 所有 1464 个测试通过

后续计划

  1. 部署后观察日志,等待 [1210] 再次出现时获取具体祸根参数的铁证
  2. 拿到铁证后在 ZhipuVendor._prepare_request 中增加参数剥离,复用 normalize_for_zhipu() + strip_thinking_blocks() 共享函数

🤖 Generated with Claude Code

在 execute_message 和 execute_stream 的 semantic rejection 日志中
附加请求体参数快照(thinking/extended_thinking/reasoning_effort 顶层参数、
会话历史中 thinking blocks 数量、cache_control 存在情况、模型名、消息数),
用于定位 zhipu glm-4.7 [1210] 参数校验拒绝的具体祸根参数。

🤖 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 changed the title diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志 diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志,定位 zhipu glm-4.7 [1210] 祸根参数 May 23, 2026
@ThreeFish-AI ThreeFish-AI merged commit 35dee36 into feature/1.x.x May 23, 2026
3 of 6 checks passed
ThreeFish-AI added a commit that referenced this pull request May 25, 2026
…t_types 等维度

PR #244 部署后的诊断日志反转了原推断:失败请求均不含 thinking/cache_control,
说明祸根在更细粒度的参数。扩展 _build_semantic_rejection_diagnostic 函数:

新增维度(仅存在时输出):
- system 形态(string/blocks + cache_control 计数)
- tools 数量 + tool_choice 形态
- 采样参数(max_tokens/temperature/top_p/top_k/stop_sequences)
- stream / metadata_keys
- messages.content 类型分布(含 string content)
- 请求体字节数估算(json.dumps)

新增 14 个单元测试(TestBuildSemanticRejectionDiagnostic)覆盖各字段组合
与真实失败请求形态。所有测试通过(1478 passed)。
ThreeFish-AI added a commit that referenced this pull request May 25, 2026
* diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志;

在 execute_message 和 execute_stream 的 semantic rejection 日志中
附加请求体参数快照(thinking/extended_thinking/reasoning_effort 顶层参数、
会话历史中 thinking blocks 数量、cache_control 存在情况、模型名、消息数),
用于定位 zhipu glm-4.7 [1210] 参数校验拒绝的具体祸根参数。

🤖 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>

* diag(executor): 扩展语义拒绝诊断日志覆盖范围至 system/tools/sampling/metadata/content_types 等维度

PR #244 部署后的诊断日志反转了原推断:失败请求均不含 thinking/cache_control,
说明祸根在更细粒度的参数。扩展 _build_semantic_rejection_diagnostic 函数:

新增维度(仅存在时输出):
- system 形态(string/blocks + cache_control 计数)
- tools 数量 + tool_choice 形态
- 采样参数(max_tokens/temperature/top_p/top_k/stop_sequences)
- stream / metadata_keys
- messages.content 类型分布(含 string content)
- 请求体字节数估算(json.dumps)

新增 14 个单元测试(TestBuildSemanticRejectionDiagnostic)覆盖各字段组合
与真实失败请求形态。所有测试通过(1478 passed)。

* docs(agents): 记录 zhipu [1210] 诊断阶段进展(证据反转 + Step 1 v2)

* build(version): 版本号升级至 0.4.1a6;
ThreeFish-AI added a commit that referenced this pull request May 26, 2026
* diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志;

在 execute_message 和 execute_stream 的 semantic rejection 日志中
附加请求体参数快照(thinking/extended_thinking/reasoning_effort 顶层参数、
会话历史中 thinking blocks 数量、cache_control 存在情况、模型名、消息数),
用于定位 zhipu glm-4.7 [1210] 参数校验拒绝的具体祸根参数。

🤖 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>

* diag(executor): 扩展语义拒绝诊断日志覆盖范围至 system/tools/sampling/metadata/content_types 等维度

PR #244 部署后的诊断日志反转了原推断:失败请求均不含 thinking/cache_control,
说明祸根在更细粒度的参数。扩展 _build_semantic_rejection_diagnostic 函数:

新增维度(仅存在时输出):
- system 形态(string/blocks + cache_control 计数)
- tools 数量 + tool_choice 形态
- 采样参数(max_tokens/temperature/top_p/top_k/stop_sequences)
- stream / metadata_keys
- messages.content 类型分布(含 string content)
- 请求体字节数估算(json.dumps)

新增 14 个单元测试(TestBuildSemanticRejectionDiagnostic)覆盖各字段组合
与真实失败请求形态。所有测试通过(1478 passed)。

* docs(agents): 记录 zhipu [1210] 诊断阶段进展(证据反转 + Step 1 v2)

* build(version): 版本号升级至 0.4.1a6;

* fix(zhipu): 兼容转换 thinking.type=adaptive 为 GLM 支持的 enabled 格式,修复 [1210] 语义拒绝

基于 2026-05-26 16:30–16:31 日志证据(8 次连续拒绝均含 thinking.type=adaptive),
在 ZhipuVendor._prepare_request 中实现兼容转换:
- adaptive → enabled(budget=16000):保留 thinking 能力,使用 GLM 原生确认支持的格式
- 新增 _build_zhipu_request_snapshot 诊断快照(成功/失败统一格式,可 diff 对比)
- 扩展语义拒绝日志错误体截断(200→500 字符),保留完整字段级诊断
- metadata 暂不处理,待进一步诊断确认兼容性

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(executor): 删除旧版重复定义的 _build_semantic_rejection_diagnostic 函数

Step 1 v2 扩展版本与 Step 1 旧版本同名重复定义,Python 运行时后者覆盖前者
不报错但旧版成为死代码。删除旧版仅保留扩展版本。

🤖 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>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ThreeFish-AI added a commit that referenced this pull request May 27, 2026
* diag(executor): 为语义拒绝路径增加请求体可疑参数诊断日志;

在 execute_message 和 execute_stream 的 semantic rejection 日志中
附加请求体参数快照(thinking/extended_thinking/reasoning_effort 顶层参数、
会话历史中 thinking blocks 数量、cache_control 存在情况、模型名、消息数),
用于定位 zhipu glm-4.7 [1210] 参数校验拒绝的具体祸根参数。

🤖 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>

* diag(executor): 扩展语义拒绝诊断日志覆盖范围至 system/tools/sampling/metadata/content_types 等维度

PR #244 部署后的诊断日志反转了原推断:失败请求均不含 thinking/cache_control,
说明祸根在更细粒度的参数。扩展 _build_semantic_rejection_diagnostic 函数:

新增维度(仅存在时输出):
- system 形态(string/blocks + cache_control 计数)
- tools 数量 + tool_choice 形态
- 采样参数(max_tokens/temperature/top_p/top_k/stop_sequences)
- stream / metadata_keys
- messages.content 类型分布(含 string content)
- 请求体字节数估算(json.dumps)

新增 14 个单元测试(TestBuildSemanticRejectionDiagnostic)覆盖各字段组合
与真实失败请求形态。所有测试通过(1478 passed)。

* docs(agents): 记录 zhipu [1210] 诊断阶段进展(证据反转 + Step 1 v2)

* build(version): 版本号升级至 0.4.1a6;

* fix(zhipu): 兼容转换 thinking.type=adaptive 为 GLM 支持的 enabled 格式,修复 [1210] 语义拒绝

基于 2026-05-26 16:30–16:31 日志证据(8 次连续拒绝均含 thinking.type=adaptive),
在 ZhipuVendor._prepare_request 中实现兼容转换:
- adaptive → enabled(budget=16000):保留 thinking 能力,使用 GLM 原生确认支持的格式
- 新增 _build_zhipu_request_snapshot 诊断快照(成功/失败统一格式,可 diff 对比)
- 扩展语义拒绝日志错误体截断(200→500 字符),保留完整字段级诊断
- metadata 暂不处理,待进一步诊断确认兼容性

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(executor): 删除旧版重复定义的 _build_semantic_rejection_diagnostic 函数

Step 1 v2 扩展版本与 Step 1 旧版本同名重复定义,Python 运行时后者覆盖前者
不报错但旧版成为死代码。删除旧版仅保留扩展版本。

🤖 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>

* feat(vendor-channels): 新增过渡管线诊断快照与 Anthropic 配对自检;

在 prepare_zhipu_to_anthropic 管线中新增两个辅助函数:
1. _dump_message_digest: 输出各阶段消息结构摘要(DEBUG 级别),
   用于过渡管线变换前后的可观测性诊断
2. _validate_anthropic_pairing: 独立的 tool_use/tool_result 配对
   自检(纯检测,不修改),定位 enforce/sanity 未覆盖的边界 case

🤖 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>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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