Repository navigation
Description
What version of Effect is running?
[email protected]@effect/[email protected]
What steps can reproduce the bug?
I am using Inception Mercury 2 through the OpenAI-compatible provider.
During ordinary text streaming, Inception returns chunks containing valid text alongside tool_calls: null:
{
"id": "chatcmpl-example",
"object": "chat.completion.chunk",
"created": 1,
"model": "inception/mercury-2",
"choices": [
{
"index": 0,
"delta": {
"content": "Hello",
"role": "assistant",
"tool_calls": null
},
"finish_reason": null
}
]
}When this chunk is processed by @effect/ai-openai-compat, the low-level client emits an UnknownChatCompletionEvent.
When using OpenAiLanguageModel.streamText, no text-delta part is emitted for "Hello".
This can be reproduced without an Inception credential by returning the payload above from a mocked SSE response and collecting the events from createResponseStream or the parts from streamText.
What is the expected behavior?
The valid delta.content text should be available through OpenAiLanguageModel.streamText.
A response containing tool_calls: null when no tool call is present should not cause the text in the same chunk to be lost.
What do you see instead?
The low-level client classifies the complete chunk as:
{
"_tag": "UnknownChatCompletionEvent",
"data": {
"choices": [
{
"delta": {
"content": "Hello",
"tool_calls": null
}
}
]
}
}The high-level language-model stream skips the unknown event.
The stream reaches its finish event, but the resulting text is empty.
In a live Mercury 2 request, every text-bearing chunk had tool_calls: null, so all streamed text was lost.
Complete text generation, structured output, complete tool calls, and streamed tool calls otherwise worked in the same compatibility test.
Additional information
This appears related to #6346 and #6667.
Those changes made schema-mismatched SSE payloads observable as UnknownChatCompletionEvent, which made this incompatibility diagnosable.
In this case, however, the payload also contains ordinary text that a high-level streamText consumer cannot recover.
I can provide a focused pull request with regression coverage if that would be helpful.
Activity