{"record":{"id":"6f79d9e06b930dd1","repo":"microsoft/autogen","slug":"no-messages-received-from-assistant-6f79d9","errorCode":null,"errorMessage":"No messages received from assistant","messagePattern":"No messages received from assistant","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py","lineNumber":505,"sourceCode":"                        )\n                    )\n                )\n                continue\n\n            if run.status == \"completed\":\n                break\n\n            await asyncio.sleep(0.5)\n\n        # Get messages after run completion\n        assistant_messages: AsyncCursorPage[Message] = await cancellation_token.link_future(\n            asyncio.ensure_future(\n                self._client.beta.threads.messages.list(thread_id=self._thread_id, order=\"desc\", limit=1)  # type: ignore[reportDeprecated]\n            )\n        )\n\n        if not assistant_messages.data:\n            raise ValueError(\"No messages received from assistant\")\n\n        # Get the last message's content\n        last_message = assistant_messages.data[0]\n        if not last_message.content:\n            raise ValueError(f\"No content in the last message: {last_message}\")\n\n        # Extract text content\n        text_content = [content for content in last_message.content if content.type == \"text\"]\n        if not text_content:\n            raise ValueError(f\"Expected text content in the last message: {last_message.content}\")\n\n        # Return the assistant's response as a Response with inner messages\n        chat_message = TextMessage(source=self.name, content=text_content[0].text.value)\n        yield Response(chat_message=chat_message, inner_messages=inner_messages)\n\n    async def handle_incoming_message(self, message: BaseChatMessage, cancellation_token: CancellationToken) -> None:\n        \"\"\"Handle regular text messages by adding them to the thread.\"\"\"\n        content: str | List[MessageContentPartParam] | None = None","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py#L487-L523","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nresp = await agent.on_messages([msg], ct)  # raises: No messages received\n\n# after\nfor attempt in range(3):\n    try:\n        resp = await agent.on_messages([msg], ct)\n        break\n    except ValueError as e:\n        if \"No messages received\" not in str(e) or attempt == 2:\n            raise\n        await asyncio.sleep(2)","handlingStrategy":"retry","validationCode":"msgs_page = await agent.messages.list(thread_id=agent._thread_id, limit=5)\nif not msgs_page.data:\n    raise RuntimeError(\"thread is empty; start a new conversation\")","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        resp = await agent.on_messages(msgs, ct)\n        break\n    except ValueError as e:\n        if \"No messages received\" not in str(e) or attempt == 2:\n            raise\n        await asyncio.sleep(2)","preventionTips":["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."],"tags":["openai","assistants-api","threads","transient"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}