Skip to content

Bedrock/Gemini/Vertex: drop empty messages before merging (an errored assistant turn sends content: []) #369

Closed

Description

@yuanhao

Bedrock, Gemini and Vertex send a message with no content (content: [] / parts: []) in two cases. Both APIs reject an empty message:

  • an assistant turn that errored and left no content (or, on Gemini, only thinking, which is not replayed);
  • a user message whose only text is empty.

The Anthropic builder skips such an assistant turn (anthropic.rs ~546-553). The other three could not do the same, because dropping it would have put two user messages side by side.

#368 (for #223) merges consecutive same-role messages in those builders, so now they can drop empty messages before merging, and the user messages around a dropped turn merge into one.

Fix: in build_bedrock_body, google::build_request_body and google_vertex::build_vertex_request_body, filter out messages whose content / parts array is empty, then call merge_same_role. Add a test with an errored, content-less assistant turn between two user turns.

Found by the review of #368. This existed before that PR; the PR does not create it.

Activity

  1. added
    bugSomething isn't working
    P3Design or idea; no implementation commitment
    on Oct 21, 2026
  2. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Design or idea; no implementation commitmentbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions