{"record":{"id":"d9d5fa7f7259789c","repo":"microsoft/autogen","slug":"str-message-error","errorCode":null,"errorMessage":"str(message.error)","messagePattern":"str\\(message\\.error\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py","lineNumber":554,"sourceCode":"                recipient=AgentId(type=self._group_chat_manager_topic_type, key=self._team_id),\n                cancellation_token=cancellation_token,\n            )\n            # Collect the output messages in order.\n            output_messages: List[BaseAgentEvent | BaseChatMessage] = []\n            stop_reason: str | None = None\n\n            # Yield the messages until the queue is empty.\n            while True:\n                message_future = asyncio.ensure_future(self._output_message_queue.get())\n                if cancellation_token is not None:\n                    cancellation_token.link_future(message_future)\n                # Wait for the next message, this will raise an exception if the task is cancelled.\n                message = await message_future\n                if isinstance(message, GroupChatTermination):\n                    # If the message contains an error, we need to raise it here.\n                    # This will stop the team and propagate the error.\n                    if message.error is not None:\n                        raise RuntimeError(str(message.error))\n                    stop_reason = message.message.content\n                    break\n                yield message\n                if isinstance(message, ModelClientStreamingChunkEvent):\n                    # Skip the model client streaming chunk events.\n                    continue\n                output_messages.append(message)\n\n            # Yield the final result.\n            yield TaskResult(messages=output_messages, stop_reason=stop_reason)\n\n        finally:\n            try:\n                if shutdown_task is not None:\n                    # Wait for the shutdown task to finish.\n                    # This will propagate any exceptions raised.\n                    await shutdown_task\n            finally:","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py#L536-L572","documentation":"Not a distinct validation error: this is the propagation point where a GroupChatTermination message carrying an error from any participant or the group chat manager is re-raised as RuntimeError in the consuming coroutine. The original exception (model client failure, agent crash, runtime error) is stringified into message.error, so str(e) shows the underlying cause.","triggerScenarios":"Any exception inside a participant agent (e.g. OpenAIChatCompletionClient receiving an invalid API key, rate limit exhaustion, or an agent's on_messages raising) during run()/run_stream(). The error travels through the runtime as GroupChatTermination(error=...) and surfaces here.","commonSituations":"Invalid or expired LLM API key, network outage to the model provider, token/context-length exceeded, custom agent code raising inside on_messages, or a model client misconfigured (wrong model name).","solutions":["Read the string inside the RuntimeError — it names the real underlying failure; fix that (API key, model name, network).","Wrap runs in try/except RuntimeError and retry transient provider errors (rate limits) with backoff.","Validate the model client and run one small smoke-test task before long unattended runs."],"exampleFix":"# before\nresult = await team.run(task=\"write a poem\")  # RuntimeError: [UnderlyingError ...]\n\n# after\ntry:\n    result = await team.run(task=\"write a poem\")\nexcept RuntimeError as e:\n    logger.error(\"team run failed: %s\", e)  # inspect underlying cause in e.args[0]\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await team.run_stream(task=task)\n    async for msg in result:\n        handle(msg)\nexcept RuntimeError as e:\n    logger.exception(\"team run failed\")\n    if is_transient(str(e)):  # rate limit / network heuristics\n        await asyncio.sleep(backoff())\n        retry = True","preventionTips":["Smoke-test model clients with one small call before long runs.","Log the full RuntimeError text — it embeds the real participant/manager failure.","Wrap unattended runs with retry + backoff for transient provider errors.","Validate API keys and model names at startup."],"tags":["python","autogen","error-propagation","model-client","runtime"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}