Repository navigation
[Bug] pi-ai/OpenAI Responses: data-only keep-alives reach JSON.parse #6593
xiangyuliu
started this conversation in
General
Replies: 1 comment
|
Additional independently observed keep-alive variant from the same class of It failed twice before any model token was produced ( This shows that matching only an empty payload or a single colon is too narrow. const payload = sse.data.trim()
const compatKeepAlive = payload === ''
|| /^:\s*(?:ping|keep[-_ ]?alive)?$/i.test(payload)
if (sse.event === null && compatKeepAlive) continueThe updated regression suite covers empty |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
With a third-party OpenAI Responses-compatible gateway, data-only keep-alive
frames can reach the OpenAI SDK JSON parser and fail an otherwise healthy DSH
turn.
The gateway is not emitting fully conforming SSE, but a narrowly scoped
compatibility guard would let DSH work with this class of relay without hiding
other malformed payloads.
Environment
@deepseek-ai/dsh@0.1.5-rc.1@deepseek-ai/dsh-llm-pi-ai@0.1.5-rc.1@earendil-works/pi-ai@0.85.1openai@6.40.0llm-pi-ai/openai-responsesSanitized wire evidence
Two observed forms were:
and:
The proper SSE comment lines are ignored, but the data-only lines are dispatched
as messages and passed to
JSON.parse.Actual behavior
The turn fails with messages equivalent to:
The Web UI then surfaces
Unexpected end of JSON inputorUnexpected token ':', ":" is not valid JSON.Expected behavior
When an SSE event has no explicit event type and its trimmed data payload is
exactly empty or a single colon, treat it as a malformed-but-empty keep-alive
and skip it. All other invalid JSON must still fail visibly.
Narrow workaround validated locally
At the streaming parser boundary, before
JSON.parse:This was tested with:
data:skipped;data: :skipped;response.completedevent still delivered;data: not-jsonstill throwingSyntaxError.The best upstream location may be the pi-ai/OpenAI Responses compatibility
boundary rather than a direct modification of the vendored OpenAI SDK. The
important property is that the tolerance stays exact and does not become a
general “ignore malformed JSON” rule.
All reactions