microsoft/autogen · error · ValueError
No messages received from assistant
Error message
No messages received from assistant
What it means
After a run completes, OpenAIAssistantAgent lists the thread's messages (order=desc, limit=1) and expects at least one assistant message. An empty result — the thread has no messages at all — raises this. It typically means the message-create call before the run failed silently, the run completed without producing output, or the wrong thread was queried.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py:505
)
)
)
continue
if run.status == "completed":
break
await asyncio.sleep(0.5)
# Get messages after run completion
assistant_messages: AsyncCursorPage[Message] = await cancellation_token.link_future(
asyncio.ensure_future(
self._client.beta.threads.messages.list(thread_id=self._thread_id, order="desc", limit=1) # type: ignore[reportDeprecated]
)
)
if not assistant_messages.data:
raise ValueError("No messages received from assistant")
# Get the last message's content
last_message = assistant_messages.data[0]
if not last_message.content:
raise ValueError(f"No content in the last message: {last_message}")
# Extract text content
text_content = [content for content in last_message.content if content.type == "text"]
if not text_content:
raise ValueError(f"Expected text content in the last message: {last_message.content}")
# Return the assistant's response as a Response with inner messages
chat_message = TextMessage(source=self.name, content=text_content[0].text.value)
yield Response(chat_message=chat_message, inner_messages=inner_messages)
async def handle_incoming_message(self, message: BaseChatMessage, cancellation_token: CancellationToken) -> None:
"""Handle regular text messages by adding them to the thread."""
content: str | List[MessageContentPartParam] | None = NoneView on GitHub (pinned to 027ecf0a37)
Solutions
- Retry the call — transient empty responses from the messages endpoint usually resolve on a second attempt.
- Verify the thread: list messages yourself with client.beta.threads.messages.list(thread_id=...) and confirm the thread contains the user message and run output.
- If the thread was deleted/reset, start a fresh conversation (new thread) instead of reusing the stale thread_id.
Example fix
# before
resp = await agent.on_messages([msg], ct) # raises: No messages received
# after
for attempt in range(3):
try:
resp = await agent.on_messages([msg], ct)
break
except ValueError as e:
if "No messages received" not in str(e) or attempt == 2:
raise
await asyncio.sleep(2) Defensive patterns
Strategy: retry
Validate before calling
msgs_page = await agent.messages.list(thread_id=agent._thread_id, limit=5)
if not msgs_page.data:
raise RuntimeError("thread is empty; start a new conversation") Try / catch
for attempt in range(3):
try:
resp = await agent.on_messages(msgs, ct)
break
except ValueError as e:
if "No messages received" not in str(e) or attempt == 2:
raise
await asyncio.sleep(2) Prevention
- Don't reuse thread_ids from deleted/reset threads.
- Retry once on empty message pages — often transient.
- Verify the user message landed in the thread before starting a run.
When it happens
Trigger: Run lifecycle completes (status not failed/requires_action) but the thread contains no messages; thread_id pointing at an empty/newly created thread; messages created but later deleted; API replication lag returning an empty page.
Common situations: Reusing a thread_id from another workspace/deleted thread; on_reset deleting messages and a subsequent run misbehaving; transient API issues dropping the user message create.
Related errors
- Incorrect client passed to OpenAIAssistantAgent. Please use
- Unsupported tool type: {type(tool)}
- Assistant not initialized
- No tools are available.
- The tool '{tool_call.name}' is not available.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/6f79d9e06b930dd1.
Report an issue: GitHub.