Skip to content

Conversation

@ChuckJonas
Copy link
Contributor

@ChuckJonas ChuckJonas commented Jul 27, 2025

Anthropic is picky about the order of tool_calls. From their docs.

Tool result blocks must immediately follow their corresponding tool use blocks in the message history. You cannot include any messages between the assistant’s tool use message and the user’s tool result message.

There's probably a more elegant fix, and IDK if this might conflict with other model providers.

Fixes #2327

@ChuckJonas ChuckJonas changed the title Fix ag_ui message toolcall order to support Anthropic requirements Fix: ag_ui message toolcall order to support Anthropic requirements Jul 27, 2025
@DouweM DouweM changed the title Fix: ag_ui message toolcall order to support Anthropic requirements Fix: AG-UI assistant text and tool call order Jul 28, 2025
@DouweM DouweM self-assigned this Jul 28, 2025
@DouweM DouweM enabled auto-merge (squash) July 28, 2025 13:42
@DouweM
Copy link
Collaborator

DouweM commented Jul 28, 2025

@ChuckJonas Thanks Charlie! I'll get this out in a release in the next few hours

@DouweM DouweM merged commit 86d70b5 into pydantic:main Jul 28, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock Agent Error:The number of toolResult blocks exceeds the number of toolUse blocks of previous turn

2 participants