Skip to content

feat(cohere): stream v2 tool arguments - #103

Merged
Kinfe123 merged 2 commits into
mainfrom
feat/cohere-tool-arguments
Oct 30, 2026
Merged

Kinfe123 merged 2 commits into
mainfrom
feat/cohere-tool-arguments

Conversation

@Kinfe123

Copy link
Copy Markdown
Collaborator

Closes #102.

Problem

Cohere v2 streams tool calls as indexed start/delta/end events. Its TypeScript SDK also converts wire tool_calls fields to toolCalls, so a consumer that only understands the wire shape silently misses SDK arguments.

Change

Add streamfold/cohere, using the existing integration and parser pool. Accept both the SDK and decoded wire envelopes, correlate indexes with tool IDs, and finalize at tool-call end or EOF. Ignore text and tool-plan events; reject malformed input and generation error messages while releasing active parsers. Cohere remains a development-only dependency.

Verification

  • Four focused tests cover the actual Cohere 8.3.0 SDK's SSE decoding and field conversion, interleaved calls, immutable partial values, duplicate ends, reused indexes, initial arguments, EOF, parser limits, malformed input, errors, and unmatched diagnostics.
  • pnpm typecheck includes CohereClientV2.chatStream() passed directly to readStructured and manual consumption.
  • pnpm release:check: 201 JavaScript tests and 11 Rust tests pass, plus type/syntax, WASM, formatting, Clippy, and package checks.
  • The real SDK uses a deterministic fetch response in conformance tests. No live model request or speedup claim is involved.

Public surface

Adds streamfold/cohere, cohere, createStructuredStream, and CohereToolCallEvent. Updates README/API documentation and the unreleased changelog. No existing export or runtime dependency changes.

@Kinfe123 Kinfe123 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, cohere sdk and wire events preserve streamed tool arguments.

@Kinfe123
Kinfe123 merged commit cc2660c into main Oct 30, 2026
7 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.

Support Cohere v2 streamed tool arguments

1 participant