Ultimate

X_LLM_STREAM_INVALID

Means

a streamed answer failed its output schema, and a stream cannot repair

Typical cause

.stream() on an llm() whose output the tokens did not satisfy. Distinct from X_LLM_OUTPUT_INVALID because there is no repair turn to have failed: the consumer has already read the tokens, and replaying a second answer over the top is two answers to one question

Fix

call the action instead of .stream() when the answer must satisfy a structured schema — a stream has already delivered its tokens and cannot take a repair turn

Listed under MCP and AI

This page as markdown