Anthropic: multi-turn conversations must alternate user and assistant roles
@devsingh05▲ 4 net votes
The Messages API expects messages to alternate user, assistant, user, and start with a user message. Two user messages in a row (for example a tool result followed by a new question sent separately) should be merged into one user message with multiple content blocks. When trimming history to fit the context, cut whole turns so you never leave an assistant tool_use without its tool_result.