[codex] Repair legacy agent thinking state#93
Merged
utopiafar merged 2 commits intoMay 15, 2026
Merged
Conversation
Collaborator
Author
|
Audit update pushed in
Validation after this update: flutter test --no-pub test/agent/state_util_test.dart
flutter analyze --no-pub lib/agent/state_util.dart lib/llm_client/gemini_oauth_client.dart test/agent/state_util_test.dart |
This was referenced May 15, 2026
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/text/tool_usecontent blocks,并保存修复后的 state。reasoning_content导致下一轮 API 400。thoughtSignature只挂到一个模型 part,functionResponse.name使用函数名,并保留可选 call id。contentBlocks,不覆盖新状态。根因
dart_agent_core新版本已经会保存 Anthropic provider-native content blocks,但用户本地可能还有旧的、被中断的 Memex agent state。旧 state 只有扁平字段:thought、textOutput、functionCalls,没有 provider 原生 blocks。当这些旧状态继续跑 thinking/tool-use 模型时,API 要求上一轮 thinking/reasoning 内容必须被传回;如果 Memex 恢复会话时没有补齐,就会出现类似
the reasoning_content in the thinking mode must be passed back to the api的 400。这个 PR 是主 app 侧临时方案,用来保护已存在的用户状态。等 core 修复发布后,再升级依赖并收敛这层兼容逻辑。
验证
flutter test --no-pub test/agent/state_util_test.dart flutter analyze --no-pub lib/agent/state_util.dart lib/llm_client/gemini_oauth_client.dart test/agent/state_util_test.dart本轮已重新回归,全部通过。
备注:本 workspace 之前
flutter pub get下载阶段卡住过,所以这里继续使用现有 package config 和--no-pub做定向验证。