Package
@flue/runtime@2.0.3, Cloudflare Workers AI binding provider.
Reproduction
Use a binding-backed model with an OpenAI-compatible streaming response whose
first assistant delta is a valid tool-call preamble:
{
"choices": [
{ "delta": { "role": "assistant", "content": null } }
]
}
The OpenAI/Workers AI contract permits content: null when an assistant turn
has no text (for example, a tool-call-only turn). Responses with other runtime
values, such as an object or array in delta.content, are malformed.
Expected behavior
- Treat
content: null (and an omitted content field) as no text delta and
continue processing tool calls.
- Reject other non-string content values with a clear provider error instead of
silently dropping the malformed response.
Proposed fix
Normalize the assistant delta at the binding boundary: return an absent text
delta for null/undefined, accept strings, and throw for all other runtime
types. A focused provider test should cover both the valid null shape and an
invalid non-string shape.
This matters because the provider parses binding responses manually rather than
using the upstream OpenAI stream parser. The current main branch
(832ad2ee, published as 2.0.3) ignores null, but also silently ignores
malformed non-string values because the TypeScript type is not a runtime guard.
Package
@flue/runtime@2.0.3, Cloudflare Workers AI binding provider.Reproduction
Use a binding-backed model with an OpenAI-compatible streaming response whose
first assistant delta is a valid tool-call preamble:
{ "choices": [ { "delta": { "role": "assistant", "content": null } } ] }The OpenAI/Workers AI contract permits
content: nullwhen an assistant turnhas no text (for example, a tool-call-only turn). Responses with other runtime
values, such as an object or array in
delta.content, are malformed.Expected behavior
content: null(and an omitted content field) as no text delta andcontinue processing tool calls.
silently dropping the malformed response.
Proposed fix
Normalize the assistant delta at the binding boundary: return an absent text
delta for
null/undefined, accept strings, and throw for all other runtimetypes. A focused provider test should cover both the valid null shape and an
invalid non-string shape.
This matters because the provider parses binding responses manually rather than
using the upstream OpenAI stream parser. The current main branch
(
832ad2ee, published as 2.0.3) ignoresnull, but also silently ignoresmalformed non-string values because the TypeScript type is not a runtime guard.