Describe the bug
JAN Chat's SSE (Server-Sent Events) parser fails when an OpenAI-compatible API server uses custom event: types in the SSE stream. The parser appears to read ALL data: lines regardless of the event: type and tries to parse them as standard chat.completion.chunk format (expecting a choices[] array). This causes a "Generation failed / Type validation failed" error and the chat breaks.
To Reproduce
- Set up an OpenAI-compatible API server that emits custom SSE events (e.g. tool progress events with
event: hermes.tool.progress)
- In JAN Chat, add a provider pointing to this server:
- Type: OpenAI Compatible
- API URL:
http://<server>:8642/v1
- API Key: (any valid key)
- Select the model and send a message
- The server sends back SSE events like:
event: hermes.tool.progress
data: {"tool":"terminal","emoji":"💻","label":"ls -la ~","toolCallId":"call_xxx","status":"running"}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":...,"model":"hermes-agent","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":...,"model":"hermes-agent","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
- JAN Chat shows: "Generation failed / Type validation failed" with an error similar to:
Type validation failed: Value: {"tool":"terminal","emoji":"💻","label":"ls -la ~","toolCallId":"call_d695aa830a5147b29e95cbc5","status":"running"}. Error message: [ { "code": "invalid_union", "errors": [ [ { "expected": "array", "code": "invalid_type", "path": [ "choices" ], "message": "Invalid input" } ], [ { "expected": "object", "code": "invalid_type", "path": [ "error" ], "message": "Invalid input" } ] ], "path": [], "message": "Invalid input" } ]
Expected behavior
JAN Chat's SSE parser should filter data: lines by their event: type. Only the default "message" event (plain data: lines with no preceding event: header) should be parsed as OpenAI chat.completion.chunk chunks. Custom event types like hermes.tool.progress should be silently ignored when the client doesn't have a handler for them, or at minimum should not cause a fatal validation error.
A compliant SSE implementation handles unknown event types by skipping them — this is standard SSE behaviour as defined by the W3C spec.
Actual behavior
The client's SSE parser treats ALL data: lines as OpenAI stream chunks regardless of the event: type. When a custom event type payload doesn't match the chat.completion.chunk schema (which requires choices[] or error), the parser raises a "Type validation failed" error, which halts the entire stream and shows "Generation failed" to the user. No response content is displayed.
Describe the bug
JAN Chat's SSE (Server-Sent Events) parser fails when an OpenAI-compatible API server uses custom
event:types in the SSE stream. The parser appears to read ALLdata:lines regardless of theevent:type and tries to parse them as standardchat.completion.chunkformat (expecting achoices[]array). This causes a "Generation failed / Type validation failed" error and the chat breaks.To Reproduce
event: hermes.tool.progress)http://<server>:8642/v1Expected behavior
JAN Chat's SSE parser should filter
data:lines by theirevent:type. Only the default "message" event (plaindata:lines with no precedingevent:header) should be parsed as OpenAIchat.completion.chunkchunks. Custom event types likehermes.tool.progressshould be silently ignored when the client doesn't have a handler for them, or at minimum should not cause a fatal validation error.A compliant SSE implementation handles unknown event types by skipping them — this is standard SSE behaviour as defined by the W3C spec.
Actual behavior
The client's SSE parser treats ALL
data:lines as OpenAI stream chunks regardless of theevent:type. When a custom event type payload doesn't match thechat.completion.chunkschema (which requireschoices[]orerror), the parser raises a "Type validation failed" error, which halts the entire stream and shows "Generation failed" to the user. No response content is displayed.