microsoft/autogen · error · ValueError
No TaskResult or Response was processed.
Error message
No TaskResult or Response was processed.
What it means
The console UI helper raises ValueError when a stream completes without any TaskResult or Response object being processed — the loop iterated only over events/other message types (or nothing at all). This indicates the run ended abnormally early or the stream source produced no terminal result.
Source
Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/ui/_console.py:202
streaming_chunks.clear()
# Chunked messages are already printed, so we just print a newline.
await aprint("", end="\n", flush=True)
elif isinstance(message, MultiModalMessage):
await aprint(message.to_text(iterm=render_image_iterm), end="\n", flush=True)
else:
await aprint(message.to_text(), end="\n", flush=True)
if message.models_usage:
if output_stats:
await aprint(
f"[Prompt tokens: {message.models_usage.prompt_tokens}, Completion tokens: {message.models_usage.completion_tokens}]",
end="\n",
flush=True,
)
total_usage.completion_tokens += message.models_usage.completion_tokens
total_usage.prompt_tokens += message.models_usage.prompt_tokens
if last_processed is None:
raise ValueError("No TaskResult or Response was processed.")
return last_processed
View on GitHub (pinned to 027ecf0a37)
Solutions
- Ensure the underlying run_stream always yields a final TaskResult (use the built-in team/agent run_stream implementations).
- If the run was cancelled or errored, handle that path separately instead of relying on console() to return a value.
- For custom task runners, yield TaskResult(messages=[...]) as the last item of the stream.
Example fix
# before
async for _ in team.run_stream(task="x"): # if cancelled, no TaskResult
...
result = await console(run_stream) # ValueError
# after
stream = team.run_stream(task="x")
result = await console(stream) # rely on built-in teams which always emit TaskResult; catch cancellation upstream Defensive patterns
Strategy: try-catch
Try / catch
try:
result = await console(stream, output_stats=True)
except ValueError as e:
if "No TaskResult" in str(e):
# stream ended without a TaskResult: cancelled or errored run
raise RuntimeError("Run produced no TaskResult; inspect cancellation/errors upstream") from e
raise Prevention
- Ensure the consumed run_stream is a built-in team/agent stream that always ends with TaskResult.
- Handle cancellation tokens and internal exceptions before wrapping a stream with console().
When it happens
Trigger: Calling the console(...) helper over a run_stream that yields only BaseAgentEvent items or nothing before finishing; a team whose stream was cancelled or errored such that the final TaskResult never arrived.
Common situations: Consuming console output of a team run that raised internally, was cancelled via CancellationToken, or a custom task runner that yields messages but never a TaskResult.
Related errors
- Please set OPENAI_API_KEY environment variable.
- Failed to deserialize response
- Value was null.
- Role mismatch
- From mismatch
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/3641caff192e15fb.
Report an issue: GitHub.