fix(kosong): preserve encrypted reasoning and data-URL MIME in provider conversion#731
Open
Dmatut7 wants to merge 3 commits into
Open
fix(kosong): preserve encrypted reasoning and data-URL MIME in provider conversion#731Dmatut7 wants to merge 3 commits into
Dmatut7 wants to merge 3 commits into
Conversation
In `_convertNonStreamResponse`, a `reasoning` output item only emitted a think part by iterating its `summary`. When `summary` was empty but `encrypted_content` was present, nothing was yielded and the encrypted reasoning token was silently dropped — unlike the streaming `response.output_item.done` path, which always emits an (empty) think part carrying the encrypted content. Since the provider explicitly requests `include: ['reasoning.encrypted_content']` and round-trips that token across turns, the non-stream path now emits the same empty-think-with-encrypted part, so multi-turn tool-use replay keeps the reasoning context. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`convertMediaUrl` only extracted the MIME type when the data-URL meta segment contained both `:` and `;`. A valid data URL with an explicit type but no `;base64` parameter (e.g. `data:image/png,<raw>`) has no semicolon, so its real MIME type was discarded in favor of the generic `image/jpeg` fallback when handing the image to Google GenAI. End the MIME slice at the first `;` when present, otherwise at the end of the meta segment, requiring only the leading `:` and a non-empty type. The common `data:<type>;base64,...` path is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d21c555 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Related Issue
No existing issue — two provider message-conversion bugs explained below.
Problem
(1) OpenAI Responses: in
_convertNonStreamResponse, areasoningoutput item only emitted a think part by iterating itssummary; whensummarywas empty butencrypted_contentwas present, nothing was yielded and the encrypted reasoning was dropped — unlike the streamingoutput_item.donepath, which preserves it. Since the provider requestsinclude: ['reasoning.encrypted_content']and round-trips that token, multi-turn tool-use lost reasoning context. (2) Google GenAI:convertMediaUrlonly extracted the MIME type when the data-URL meta segment had both:and;, so a valid data URL with an explicit type but no;base64(e.g.data:image/png,<raw>) fell back to the genericimage/jpeg.What changed
(1) The non-stream path now emits an empty think part carrying
encrypted_contentwhen the summary is empty, matching the streaming path. (2) End the MIME slice at the first;when present, otherwise at the end of the meta segment, requiring only a leading:and a non-empty type; the common;base64path is unchanged. Tests added for both.Checklist