You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
createAI: numeric stream deltas from Workers AI are dropped #2627
Workers AI sometimes streams a numeric-looking token as a JSON number instead of a string, e.g. {"choices":[{"delta":{"content":0.005}}]}. createAI drops it silently, so $0.005 comes out as $ and [1] as [].
constai=createAI({binding: env.AI});const{ text }=streamText({model: ai("@cf/meta/llama-3.3-70b-instruct-fp8-fast"), prompt });// stream chunks: "Costs $", 0.005, " each" -> text is "Costs $ each"
normalizeDelta in packages/agents/src/models/core/chat-completions/stream.ts passes a numeric content through unchanged, and the wires then read it with typeof === "string" (text() in ai-sdk/wires/shared.ts, pushText in pi-ai/wires/chat-completions.ts). Numeric reasoning / reasoning_content and a numeric native response are dropped the same way. Coercing numbers to strings in the normalizer fixes all of them; the non-streaming path already does this (contentText in response.ts).
Activity