run-llama/llama_index · error · ValueError
Got empty streaming response
Error message
Got empty streaming response
What it means
In AgentWorkflow's streaming path (_call_llm with streaming), the loop over chat deltas is expected to produce at least one ChatResponse chunk. If the loop finishes with last_response still None — zero chunks yielded — the workflow raises ValueError('Got empty streaming response') rather than proceeding with nothing.
Source
Thrown at llama-index-core/llama_index/core/agent/workflow/multi_agent_workflow.py:343
raw = (
last_response.raw.model_dump()
if isinstance(last_response.raw, BaseModel)
else last_response.raw
)
if ctx.is_running:
ctx.write_event_to_stream(
AgentStream(
delta=last_response.delta or "",
response=last_response.message.content or "",
raw=raw,
current_agent_name=agent.name,
thinking_delta=last_response.additional_kwargs.get(
"thinking_delta", None
),
)
)
if last_response is None:
raise ValueError("Got empty streaming response")
return last_response
else:
return await agent.llm.achat(llm_input)
async def _call_tool(
self,
ctx: Context,
tool: AsyncBaseTool,
tool_input: dict,
) -> ToolOutput:
"""Call the given tool with the given input."""
try:
if (
isinstance(tool, FunctionTool)
and tool.requires_context
and tool.ctx_param_name is not None
):
new_tool_input = {**tool_input}View on GitHub (pinned to afd0fef371)
Solutions
- Retry the run — empty streams from hosted LLMs are frequently transient.
- Verify streaming works outside AgentWorkflow: `async for c in llm.astream_chat(...)` should yield at least one chunk.
- If the endpoint/proxy doesn't support streaming, run without streaming or use a non-streaming-compatible integration.
- For test doubles, make the mock astream_chat yield at least one ChatResponse with delta content.
Example fix
# before (mock yields nothing -> ValueError)
async def astream_chat(self, messages, **kwargs):
return
yield
# after
async def astream_chat(self, messages, **kwargs):
yield ChatResponse(message=ChatMessage(role="assistant", content="ok"), delta="ok") Defensive patterns
Strategy: retry
Validate before calling
async def probe_stream(llm, prompt="ping"):
n = 0
async for _ in llm.astream_chat([ChatMessage(role="user", content=prompt)]):
n += 1
return n > 0 # false -> streaming will raise 'Got empty streaming response' Try / catch
from llama_index.core.workflow.errors import WorkflowRuntimeError
for attempt in range(3):
try:
handler = wf.run(user_msg=q, stream=True)
async for ev in handler.stream_events():
...
result = await handler
break
except ValueError as e:
if "empty streaming response" not in str(e) or attempt == 2:
raise
continue Prevention
- Health-check astream_chat on new provider/proxy configurations before wiring into the agent.
- Ensure test mocks yield at least one chunk.
- Treat a single empty stream as transient; back off and retry before escalating.
When it happens
Trigger: Running the agent with stream=True against an LLM that returns an empty SSE stream, closes the connection before the first chunk, or whose streaming mode is misconfigured (e.g. stream mode not actually enabled server-side). Also seen with mock/fake LLMs that yield no chunks.
Common situations: Switching a provider integration to streaming when the endpoint doesn't support it; a transient network drop right after headers; OpenAI-compatible proxies that return 200 but an empty body; unit tests with stub LLMs that forget to emit deltas.
Related errors
- Response generation timed out after {timeout} seconds
- All agents must have a name in a multi-agent workflow
- All agents must have a description in a multi-agent workflow
- Initial state is not supported per-agent in AgentWorkflow
- Exactly one root agent must be provided
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/1b521f3aedf31c65.
Report an issue: GitHub.