fix(cohere): allow parallel tool messages in message validation - #1022
Merged
Conversation
The _patch_messages validation only checked if the immediately preceding message was an assistant, causing failures when multiple tool result messages follow a single assistant message with parallel tool calls. Walk backwards past sibling tool messages to find the originating assistant message instead. Fixes agent loop integration tests for cohere provider. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
njbrake
temporarily deployed
to
integration-tests
April 13, 2026 10:23 — with
GitHub Actions
Inactive
Contributor
|
This PR appears to be missing the required checklist from the PR template. Please edit your PR description to include the checklist section. The checklist helps maintainers review your contribution. This PR will be automatically closed in 24 hours if the template is not restored. If you're using an AI coding tool, please ensure it preserves the PR template. |
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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
_patch_messages()validation in the Cohere provider only checked if the immediately preceding message was an assistant, but with parallel tool calls multiple tool result messages follow a single assistant message. The second tool message's predecessor is another tool message, not the assistant, causing aValueError.Fixes failing integration tests:
test_agent_loop_parallel_tool_calls[cohere]test_agent_loop_sequential_tool_calls[cohere]Regression introduced in #1013.
Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com