fix(normalizer): 规范化 misplaced tool_result 剥离日志,消除跨请求重复警告#134
Merged
Conversation
将逐条 WARNING 汇总为单条去重日志:首次出现的 tool_use_id 输出含完整因果上下文的 WARNING,后续降级为 DEBUG。集合超过 500 条时保留最近一半条目防止无限增长。 🤖 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
request_normalizer.py中 misplaced tool_result 剥离的逐条 WARNING 日志改为汇总式单条日志,并对同一tool_use_id跨请求去重tool_use_id输出 WARNING(含完整因果上下文:vendor 降级原因 → Anthropic API 限制 → 剥离动作),后续降级为 DEBUGProblem
在 Zhipu GLM-5 跨供应商降级场景下,相同的
tool_use_id(如call_4071fb015ad24b2e8c699c1b)在每次请求中均触发 WARNING 日志,导致:以上两条日志在几十次请求中重复出现上百次,严重干扰运维日志的可读性。
Root Cause
tool_use和tool_result内容块normalize_content_block对每个错位块逐条输出 WARNINGtool_use_id在整个会话生命周期内持续重复触发Fix Details
After Fix
首次出现(整个会话仅一次):
后续请求(降级为 DEBUG):
Test Plan
🤖 Generated with Claude Code