Repository navigation
docs(mistral): reuse the OpenAI adapter for Responses streams - #104
Merged
Merged
Conversation
Kinfe123
commented
Oct 30, 2026
Kinfe123
left a comment
Collaborator
Author
There was a problem hiding this comment.
lgtm, mistral sdk frames reuse the adapter with tested cleanup.
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.
Problem
Mistral's Responses API uses OpenAI-style tool events, but passing an
@mistralai/mistralai@3.4.0stream directly tostreamfold/openaiproduces no updates. Unwrappingframe.dataalone still drops argument deltas and ends withEMPTY_INPUT, because the SDK converts the wire'sitem_idtoitemId.Root cause
The existing adapter consumes decoded OpenAI events with snake-case argument identifiers. Mistral's SDK exposes a frame envelope and camel-case identifiers.
Change
Add a small copyable example that unwraps the frame, normalizes the two argument-event identifiers, and delegates to the existing OpenAI adapter through
readStructured. It preserves immutable previews and managed iterator cleanup without introducing another stateful adapter.Add the Mistral SDK as a development dependency for real decoder and consumer-type coverage. The published package gains no dependencies or exports. Document use, item IDs, cancellation, and the application-owned validation and response-status responsibilities.
Verification
node --test examples/mistral.test.mjs: both cases pass. The real SDK decodes wire SSE into interleaved calls; assertions cover IDs, final values, retained immutable partial values, and cancelling the response body on early exit.itemIdconversion makes the interleaved replay fail withEMPTY_INPUTfor calla; restoring it passes.pnpm typecheck: passes, including a consumer of the actualclient.responses.create()return type.pnpm release:check: passes, including 199 JavaScript tests, 11 Rust tests, syntax/type checks, Rust formatting/lints, and package dry run.No credentials or live model requests were used. This PR makes no end-to-end performance claim.
Public surface
Documentation and an example only. No published source, declarations, exports, or runtime dependencies change.