fix(cli): route openai-compatible providers through streamText for memory consolidation - #12748
fix(cli): route openai-compatible providers through streamText for memory consolidation#12748rusak47 wants to merge 6 commits into
Conversation
Code Review SummaryStatus: 1 Issue Found | Recommendation: Suggestion only — safe to merge once considered Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Resolved in the latest commits: Residual note on the memo (not re-raised inline): the No memory-leak concerns: the timeout timer is cleared and the controller aborted in Notes/assumptions: incremental review of Fix these issues in Kilo Cloud Previous Review Summaries (3 snapshots, latest commit d815e31)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit d815e31)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Resolved since the last review: the guard now also unwraps No memory-leak concerns: the timeout timer is cleared and the controller aborted in Notes/assumptions: dependencies are not installed in this environment, so the exact Fix these issues in Kilo Cloud Previous review (commit d3451d0)Status: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (3 files)
Previously reported issues are resolved: the changeset now targets Notes/assumptions: dependencies are not installed in this environment and network fetches were unavailable, so the Fix these issues in Kilo Cloud Previous review (commit 039ebfe)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (2 files)
Notes/assumptions: the underlying claim that these providers emit SSE on non-streaming requests could not be verified from the code (nothing in Reviewed by claude-opus-5 · Input: 28 · Output: 8.8K · Cached: 714.2K Review guidance: REVIEW.md from base branch |
f123f5f to
7319125
Compare
d3451d0 to
b9127b5
Compare
…mory consolidation Openai-compatible providers (incl. 9router -> opencode.ai/zen -> DeepSeek) return SSE bodies even on non-streaming requests. generateText cannot parse them, producing 'Invalid JSON response'. Route openai-compatible providers through streamText (via the openai branch path).
d815e31 to
f0a21f8
Compare
Follow-up: streamText fix — captured
|
Issue
Fixes # — (no reported issue; related to #12674)
Context
OpenAI-compatible providers (
api.npm === "@ai-sdk/openai-compatible"), including the 9router -> opencode.ai/zen -> DeepSeek chain used during memory consolidation, return SSE bodies even on non-streaminggenerateTextrequests. The SDK cannot parse them, raisingInvalid JSON response, which surfaces as the recurring DeepSeek 400s and failed memory consolidation.Implementation
Extends the existing
openaibranch condition inmemoryText(packages/opencode/src/kilocode/memory/ports.ts) to also matchopenai-compatible, so those providers are routed throughstreamText, which already consumes SSE parts correctly. Additive single-line condition (+3/-1); no behavior change for the non-openai path.This commit carries only the routing fix
Screenshots / Video
N/A — no UI or end-user-visible behavioral change.
How to Test
Manual/local verification
bun test test/kilocode/memory/memory-ports.test.tsonfix/memory-streamtext: 3 pass / 11 expect calls (base memory-ports suite).bun run typecheck(@kilocode/cli+@kilocode/kilo-memory): clean, on this branch and on theort-merged combination withmemory-output-cap.Reviewer test steps
opencode.json(e.g. a 9router/DeepSeek entry exposed viaapi.npm: "@ai-sdk/openai-compatible").memory.updatedbus event fires) with noInvalid JSON responsein the log. (Without this change, the same flow raised the parse error.)Blocked checks and substitute verification
bun test/ typecheck against live DeepSeek traffic could not run (no DeepSeek/9router credentials in CI/local). Substituted: theortmerge of routing-only + config-cap passed all tests on the combined tree, and the routing target (streamText) is the existing, test-covered branch.api.npm === "@ai-sdk/openai-compatible"is left for follow-up to avoid coupling this fix to mock-LLM harness work.Checklist
.changeset/memory-streamtext-openai.md,patch).Get in Touch
realcash-4u@inbox.lv