[codex] Fix legacy Claude thinking round-trip#13
Open
utopiafar wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
Audit update pushed in
Validation after this update: dart analyze
dart test |
This was referenced May 15, 2026
Contributor
Author
Collaborator
|
这个改动用真实的key测过了不 |
Contributor
Author
测过的,不过刚发现这个fix不全,并且暴露出memex另一个架构问题,先不着急merge,再梳理下 |
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.
摘要
ModelMessage.thought在 Claude / Bedrock Claude fallback 请求构造中没有被回放为thinkingblock 的问题。reasoning_content回放:保留显式空字符串,并为 DeepSeek V4 旧 tool-call turn 加兜底。functionResponse.name使用函数名,单独保留可选 call id。根因
PR #10 修到了 Anthropic provider-native
contentBlocks主路径,但旧状态 / 手动构造的 fallback 路径仍然会在thoughtSignature == null时丢掉 thinking 内容。thinking/tool-use provider 在下一轮继续请求时需要看到前一轮 reasoning/thinking 内容,因此会报 400。系统排查后还发现两个同类协议坑:
reasoning_content继续传回 API。name是函数名,call id 是独立字段;thought signature 也需要跟随上一轮模型 part 回放。兼容性
contentBlocks时继续优先原样回放。signature存在时继续保留。reasoning_content;空值兜底只覆盖旧状态 / 丢失 reasoning 的 tool-call turn。验证
dart test test/openai_client_test.dart test/gemini_client_test.dart test/claude_client_test.dart test/bedrock_claude_client_test.dart dart analyze本轮已重新回归,全部通过。