Skip to content

feat: real SSE streaming for llm_stream - #26

Merged
NekomyaDev merged 1 commit into
mainfrom
feature/real-streaming
Jul 29, 2026
Merged

NekomyaDev merged 1 commit into
mainfrom
feature/real-streaming

Conversation

@NekomyaDev

Copy link
Copy Markdown
Owner

What

llm_stream no longer falls back to llm_call on real providers — it streams for real (roadmap v1.2: real streaming ✅).

  • _sse_events — shared SSE reader with the same 429 backoff as the non-streaming path
  • _openai_chat_stream — OpenAI-compatible deltas (choices[].delta.content), stream_options.include_usage, covers OpenAI/Gemini/Groq/MiMo/Mistral/Ollama
  • _anthropic_chat_stream — Messages API events (message_start / content_block_delta / message_delta)
  • Real streams feed the same _PrefixValidator the fake path uses: an unsatisfiable prefix still aborts the stream early → counts as a schema violation → the §4.2 repair loop applies, now against a live model
  • Trace records carry the same additive fields (streamed/chunks/early_abort) plus real tokens (from usage events, word-count fallback) and priced cost_usd
  • Fake path byte-for-byte unchanged; replay semantics unchanged

Test (sandbox, mocked SSE server)

  • Mistral stream: 2 chunks assembled, schema validated, tokens 12/6, cost priced from the table ✓
  • Anthropic stream: usage from message_start/message_delta ✓
  • Early abort on garbage prefix → repair round 1 recovers (schema_violation early_abort then ok) ✓
  • Fake provider parity (deterministic chunking, explicit NUDGE_PROVIDER=fake override) ✓

@NekomyaDev
NekomyaDev merged commit 2acbc59 into main Jul 29, 2026
2 checks passed
@NekomyaDev
NekomyaDev deleted the feature/real-streaming branch July 29, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant