Conversation
…nt types When two consecutive assistant messages had mixed content types (one string, one list), the merge logic just replaced the earlier message entirely with the later one (fixed[-1] = m), silently dropping the earlier message's content. Apply the same normalization pattern used in the tool_use merge path (lines 952-956): convert both to list format before concatenating. This preserves all content from both messages.
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
In
agent/anthropic_adapter.py, when merging consecutive assistant messages (required by Anthropic's API which rejects consecutive same-role messages), the mixed-types case (one message has string content, the other has list content) simply replaced the earlier message with the later one:This caused data loss when the conversation had consecutive assistant messages with different content formats.
What changed
Applied the same normalize-and-merge pattern already used in the tool_use merge path (lines 952-956): convert both to
[{"type": "text", "text": ...}]list format before concatenating.Test plan