feat(adapters): add cohere-chat adapter for Cohere Chat API v2 - #6
Merged
Conversation
…ripts - Import Cohere v2 message lists: tool_plan/tool_calls assistant messages, document-block tool results, message-level citations - Auto-detection scans Cohere-only markers (tool_plan, assistant-level citations, document blocks) before OpenAI rules, since Cohere shares the tool_calls wire shape with OpenAI - tool_plan maps to a model_response step marked metadata.source_field so plan text stays visible to safety checks - 11 new tests incl. cross-provider verdict-equivalence; docs + changelog - Version 0.2.2
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.
What
Adds a third provider adapter:
cohere-chat, importing Cohere Chat API v2 conversation transcripts into the canonical trace format, with auto-detection.Design notes
tool_calls/role: "tool"wire shape with OpenAI. Detection therefore scans the full message list for Cohere-only markers first —tool_planon assistant messages, assistant message-levelcitations, anddocumenttyped tool-result blocks — before falling through to the per-message OpenAI/Anthropic rules. Covered by dedicated tests, including an ambiguous transcript that carriestool_callsbut notool_plan.tool_planis agent behavior: it maps to amodel_responsestep (markedmetadata.source_field: "tool_plan") so plan text stays visible to safety scanning without being mistaken for the final answer.{type: document, document: {data}}block lists; validdatapayloads are joined in order, and malformed blocks are recorded undermetadata.adapter.notes(never silently dropped) while still recovering the valid payloads around them.Testing
mypy --strictclean; benchmark suite thresholds all met.Version
Bumps to 0.2.2 (new feature, backward compatible). Changelog updated.