fix(deepseek): transport-neutral bounded-JSON policy with terminal SSE synthesis (#875) - #1026
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
a3dd247 to
ec5e666
Compare
45eb5b8 to
681f2e4
Compare
…E synthesis (#875) The registry's upstream-streaming hint was WS-scoped, so ordinary HTTP turns kept stream:true into DeepSeek's terminal-less SSE and stalled after tool calls. The policy is now transport-neutral: - registry hint renamed modelResponsesUpstreamStreaming, applied after final wire resolution for openai-responses adapters - shared bounded-JSON event sequence (responses-json-events.ts) used by both the WS bridge and a new HTTP SSE synthesis (created -> output_item.done -> terminal -> [DONE]) for streaming clients - stall activation test: terminal-less fake SSE proves the old hang; the client now gets the full synthesized sequence - structure/04 updated Supersedes PR #1006's mechanism with the contributor's core policy retained (attribution); avoids its duplicated event algorithm and adds the missing [DONE] trailer.
#1026 review blocker 3. The bounded-JSON policy answers a streaming client by synthesizing SSE from a completed JSON body, and reframes the same body into events for WS turns. Neither path goes through the SSE relay, so neither picked up the relay's item-id rewrite: enabling this reliability policy would silently DISABLE id repair for a provider that has it configured — canonical ids while streaming, placeholder ids the moment the policy engaged. Adds repairResponsesJsonItemIds for whole-object normalization and applies it to the synthesized-SSE and WS-reframe paths, after the raw recording. This layer no longer depends on the later #938 work to be safe on its own. Tests: repaired ids on both bounded-JSON paths, and a provider without repair keeps the body byte-identical.
ec5e666 to
710492c
Compare
681f2e4 to
62a5ee6
Compare
|
Rebased onto the current stack head, with a review blocker folded in. Blocker: this layer was not independently safe with item-id repair. The bounded-JSON policy answers a streaming client by synthesizing SSE from a completed JSON body, and reframes the same body into events for WS turns. Neither path goes through the SSE relay, so neither picked up the relay's item-id rewrite. The consequence is worse than a missing feature: for a provider that has id repair configured, enabling this reliability policy would silently disable it — canonical ids while streaming, raw upstream ids the moment the policy engaged. The later #938 PR happened to fix this, which meant this PR was only safe if its child landed with it.
|
Summary
Stack 04 of the bug-stack campaign (
devlog/_plan/260805_bug_stack_campaign/050), stacked on #1025. Fixes #875.The registry's upstream-streaming hint was WS-scoped: ordinary HTTP turns kept
stream:trueinto DeepSeek's terminal-less SSE and stalled after tool calls (reporter reproduced at e44d234 withwebsockets:false, bodyKind:sse).modelResponsesUpstreamStreaming(renamed, transport-neutral) applies after final wire resolution foropenai-responsesadapters — DeepSeek Flash now uses bounded JSON upstream on every transport.src/server/responses-json-events.ts): the WS bridge and the new HTTP synthesis emit the same canonical frames —response.created→ oneresponse.output_item.doneper item → status-preserving terminal; HTTP streaming clients get SSE with exactly one[DONE].Non-streaming clients and WS turns keep plain JSON (gate excludesinboundTransport: "websocket"`).[DONE]trailer, and bypass of the SSE item-ID repair branch are avoided.Tests
stream:trueis ever sent (the old hang), and the client receives the full synthesized sequence with[DONE]; function_call id/call_id byte-identical.tests/responses-json-events.test.tsandtests/ws-endpoint.test.ts.bun run typecheck0 errors;bun run privacy:scanpass.bun run teston Linux (ssh lidge): 8288 pass / 0 fail (baseline 8222).Limitations
DeepSeek Flash loses progressive token delivery — the intended provider-specific reliability tradeoff. structure/04 documents the transport-neutral policy.