Skip to content

fix(llm): real retry jitter; read data: lines without the space - #504

Merged
mrnasil merged 3 commits into
mainfrom
fix/llm-retry-jitter-sse-data
Nov 26, 2026
Merged

mrnasil merged 3 commits into
mainfrom
fix/llm-retry-jitter-sse-data

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 25, 2026

Copy link
Copy Markdown
Member

Jitter. full_jitter seeded its PRNG with Instant::now().elapsed(), which is about 0 ns. Every retry, and every client, waited the same "random" time, which is the thundering herd jitter is meant to avoid. It now draws from a fresh RandomState per call (std; randomly seeded per thread, and different on every new()). Test: 32 draws over 1000 s produce more than 16 distinct values; with the old seed all 32 were identical.

data: lines. The chat, anthropic, codex and codeassist SSE parsers all required data: with a space. The SSE spec makes that space optional, so a gateway sending data:{...} lost the whole reply. A single helper, openai_compat::sse_data, now reads both forms. Test: a chat stream written as data:{...} / data:[DONE] yields its text and stops.

Lines still uncovered in these files are the same as on main.

This touches the same push_data_line in codeassist as #496. Whichever lands second may need a one-line merge.

🤖 Generated with Claude Code

- full_jitter seeded its PRNG with Instant::now().elapsed(), which is
  about 0 ns, so every retry and every client waited the same "random"
  time. It now draws from a fresh RandomState per call.
- Every SSE parser required `data: ` with a space; the space is optional
  in the SSE spec, and a `data:{...}` line was dropped. One helper,
  openai_compat::sse_data, now reads both forms for the chat, anthropic,
  codex and codeassist parsers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil enabled auto-merge (squash) November 25, 2026 16:01
mrnasil and others added 2 commits November 26, 2026 03:19
Resolve codeassist.rs: keep sse_data() line parsing from this branch and
the done/finished flags from main.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@mrnasil
mrnasil merged commit f22cec1 into main Nov 26, 2026
7 checks passed
@mrnasil
mrnasil deleted the fix/llm-retry-jitter-sse-data branch November 26, 2026 00:59
@mrnasil mrnasil mentioned this pull request Nov 26, 2026
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