Same Response, Two Code Paths: Replay Testing of Streaming Parity in LLM SDKs

Applications reach language models through SDKs that turn each provider's wire format into one result object. A provider can deliver a response as a single JSON document or as a stream of server-sent events, and an SDK handles the two with separate code. Developers switch between them and expect the same result. We test that expectation without knowing what the correct result is. We collect 1,158 recorded response streams from the test suites of 7 open-source projects, in four wire formats (OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, Gemini), and build for each the JSON document that carries the same response, using the providers' own accumulators. A replay server serves every response both ways to four SDKs (Vercel AI SDK, LiteLLM, LangChain, Pydantic AI), and the two results must agree. A second relation requires that writing the same events to the socket in six different ways changes nothing. In 46,320 runs we trace every difference to code. In 93 of 4,592 stream and non-stream comparisons (2.0%) the SDK returns two different results for the same response, from 0.1% and 0.4% for two SDKs to 3.0% and 4.5% for the other two, with 20 distinct causes in all. One SDK loses a model's refusal when streaming. The same SDK returns an empty or cut-off answer, without an error, when a Gemini stream contains comment lines, which the SSE standard allows, and two others raise on them. Two SDKs report token usage differently depending on the mode. Byte-level rewrites of the stream break nothing. A further 63 differences were produced by our own test rig and are reported as such. The corpus, the replay server and the harnesses are public. This is a preprint and has not been peer reviewed.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-12-02
DOI
https://doi.org/10.5281/zenodo.24734123
Primary Topic
Software Testing and Debugging Techniques
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Same Response, Two Code Paths: Replay Testing of Streaming Parity in LLM SDKs

Muhammad Ahmad
Zenodo (CERN European Organization for Nuclear Research)
Software Testing and Debugging Techniques
preprint

Same Response, Two Code Paths: Replay Testing of Streaming Parity in LLM SDKs

Muhammad Ahmad
preprint en

Abstract

Applications reach language models through SDKs that turn each provider's wire format into one result object. A provider can deliver a response as a single JSON document or as a stream of server-sent events, and an SDK handles the two with separate code. Developers switch between them and expect the same result. We test that expectation without knowing what the correct result is. We collect 1,158 recorded response streams from the test suites of 7 open-source projects, in four wire formats (OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, Gemini), and build for each the JSON document that carries the same response, using the providers' own accumulators. A replay server serves every response both ways to four SDKs (Vercel AI SDK, LiteLLM, LangChain, Pydantic AI), and the two results must agree. A second relation requires that writing the same events to the socket in six different ways changes nothing. In 46,320 runs we trace every difference to code. In 93 of 4,592 stream and non-stream comparisons (2.0%) the SDK returns two different results for the same response, from 0.1% and 0.4% for two SDKs to 3.0% and 4.5% for the other two, with 20 distinct causes in all. One SDK loses a model's refusal when streaming. The same SDK returns an empty or cut-off answer, without an error, when a Gemini stream contains comment lines, which the SSE standard allows, and two others raise on them. Two SDKs report token usage differently depending on the mode. Byte-level rewrites of the stream break nothing. A further 63 differences were produced by our own test rig and are reported as such. The corpus, the replay server and the harnesses are public. This is a preprint and has not been peer reviewed.

Zenodo (CERN European Organization for Nuclear Research)
Software Testing and Debugging Techniques
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon