Fix openRouter emits cumulative tool-parameter prefixes as deltas - #7132
Conversation
🦋 Changeset detectedLatest commit: 457824f The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 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 |
|
no API key found — this repo is configured to use To fix: add the key as a GitHub Actions secret (referenced from your workflow's Open repo secrets → · Configure model → · Setup docs → · Ask in Discord →
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Fixed cumulative tool-parameter deltas in
OpenRouterLanguageModel.makeStreamResponse: the continuation branch now emitstoolCall.function?.arguments ?? ""as the incrementaltool-params-deltainstead of the accumulatedactiveToolCall.params. - Added a regression test that streams two argument fragments (
{"a":and1}) and asserts the deltas are exactly those fragments, not the accumulated prefixes. - Added a patch changeset for
@effect/ai-openrouter.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta since prior Pullfrog review at 7428eca1d)
- Extracted
argumentsDeltainto a singleconstand re-used it across tool-call start init, params accumulation, and delta emission, moving thetool-params-deltapush out of the start/continuation branch into one shared site guarded byargumentsDelta.length > 0. - Unified the branch logic so the start and continuation paths converge, eliminating the duplicated
activeToolCall.paramsreads in favor of the incrementalargumentsDelta. - Extended the regression test with an argument-less continuation chunk (
delta: { tool_calls: [{ index: 0 }] }) to verify emptytool-params-deltaparts are suppressed; asserts the emitted deltas are exactly["{\"a\":", "1}"].
The refactor brings OpenRouterLanguageModel.makeStreamResponse into exact alignment with the reference pattern in openai-compat/src/OpenAiLanguageModel.ts:1301, and the added regression chunk proves the empty-delta suppression. All 8 tests in the file pass (pnpm vitest run packages/ai/openrouter/test/OpenRouterLanguageModel.test.ts).
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
9d712f4 to
57f965d
Compare
57f965d to
457824f
Compare

Summary
tool-params-deltaparts when a continuation chunk carries no arguments.@effect/ai-openrouter.Validation
pnpm test --run packages/ai/openrouter/testpnpm lintpnpm checkCloses EFF-564