Repository navigation
fix(recorder): keep OpenRouter delta.reasoning when collapsing streams - #664
Merged
Merged
Conversation
jpr5
force-pushed
the
fix/recorder-openrouter-reasoning
branch
from
December 3, 2026 23:04
6a7a56d to
5cb647a
Compare
commit: |
OpenRouter streams reasoning as delta.reasoning (mirrored in reasoning_details), not delta.reasoning_content, so recorded OpenRouter fixtures lost their reasoning. Read reasoning_content when it is a string, else reasoning. Take one source per delta so a delta carrying both fields is not double-counted.
jpr5
force-pushed
the
fix/recorder-openrouter-reasoning
branch
from
December 3, 2026 23:18
017fb68 to
67d9b83
Compare
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.
When aimock records a real OpenRouter streaming chat completion, the reasoning is dropped. OpenRouter streams it as
delta.reasoning(with a mirroreddelta.reasoning_detailsarray), but the OpenAI-family collapser only readdelta.reasoning_content, so the recorded fixture had noreasoning.The collapser now reads
reasoning_contentwhen it is a string, otherwisereasoning. It takes one source per delta, so a delta that carries both fields with the same text (as aimock's own OpenRouter stream will after #663) is not counted twice.reasoning_detailsis not read anywhere in the collapse path, so it adds nothing here. Streams that only usereasoning_contentcollapse exactly as before.The new test file
src/__tests__/recorder-openrouter-reasoning.test.tsruns a recorder withproviders.openrouterpointed at a local upstream that streams OpenRouter-shaped SSE (the K9 drift shape), posts to/api/v1/chat/completions, and reads the fixture file the recorder writes. It also covers a delta with both fields, areasoning_content-only control, and areasoning: nulllength terminal.Red (origin/main, before the fix)
The both-fields recording test and the
reasoning_contentcontrol pass on main too. They are there to show the fix does not double-count and does not change existing behavior.Green (after the fix), with the related suites
Prettier, eslint and
pnpm run typecheckare clean.pnpm build && pnpm api:reportreports 14 entries with 0 failures and no change toetc/.