条件化 thinking block 剥离,仅跨供应商场景触发#182
Merged
Merged
Conversation
将 thinking block 剥离从 AnthropicVendor._prepare_request()(无条件执行) 提升至 _RouteExecutor._prepare_body_for_tier()(条件执行),基于请求规范化 信号(has_cross_vendor_signals)和会话历史信号(provider_state)判断是否 需要剥离。纯 Anthropic 会话中 thinking blocks 保持原样以维持上下文连续性。 - 新增 NormalizationResult.has_cross_vendor_signals 属性 - 迁移 strip_thinking_blocks() 至 request_normalizer.py - 新增 _RouteExecutor._needs_thinking_strip() 条件判断方法 - 补充 count_tokens 端点的安全剥离(无会话上下文时回退到始终剥离) 🤖 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.
概要
将 thinking block 剥离从
AnthropicVendor._prepare_request()(无条件执行)提升至_RouteExecutor._prepare_body_for_tier()(条件执行),解决纯 Anthropic 会话中 thinking blocks 被不必要剥离的问题。变更内容
has_cross_vendor_signals)和会话历史信号(provider_state)判断是否需要剥离,纯 Anthropic 会话保留 thinking blocks 以维持上下文连续性compat_session_store未配置(session_record为None)时,回退到始终剥离,确保向后兼容count_tokens端点加固: 因无会话上下文,安全剥离防止跨供应商 signature 导致 400 错误_strip_misplaced_tool_results仍在AnthropicVendor._prepare_request()中保持不变测试验证
_needs_thinking_strip条件判断测试_prepare_body_for_tierthinking 剥离行为测试has_cross_vendor_signals属性测试strip_thinking_blocks函数测试🤖 Generated with Claude Code, CodeX, Gemini