{"record":{"id":"824b575b12d76af3","repo":"microsoft/semantic-kernel","slug":"run-failed-with-status-run-status-for-agent","errorCode":null,"errorMessage":"Run failed with status: `{run.status}` for agent `{agent.name}` and thread `{thread_id}` with error: {error_message} and incomplete details reason: {incomplete_details_reason}","messagePattern":"Run failed with status: `(.+?)` for agent `(.+?)` and thread `(.+?)` with error: (.+?) and incomplete details reason: (.+?)","errorType":"exception","errorClass":"AgentInvokeException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/agent_thread_actions.py","lineNumber":226,"sourceCode":"            **run_options,\n        )\n\n        processed_step_ids = set()\n        function_steps: dict[str, \"FunctionCallContent\"] = {}\n\n        while run.status != \"completed\":\n            run = await cls._poll_run_status(\n                agent=agent, run=run, thread_id=thread_id, polling_options=polling_options or agent.polling_options\n            )\n\n            if run.status in cls.error_message_states:\n                error_message = \"None\"\n                if run.last_error and run.last_error.message:\n                    error_message = run.last_error.message\n                incomplete_details_reason = \"None\"\n                if run.incomplete_details and run.incomplete_details.reason:\n                    incomplete_details_reason = run.incomplete_details.reason\n                raise AgentInvokeException(\n                    f\"Run failed with status: `{run.status}` for agent `{agent.name}` and thread `{thread_id}` \"\n                    f\"with error: {error_message} and incomplete details reason: {incomplete_details_reason}\"\n                )\n\n            # Check if function calling is required\n            if run.status == \"requires_action\":\n                if isinstance(run.required_action, SubmitToolOutputsAction):\n                    logger.debug(\n                        f\"Run [{run.id}] requires tool action for agent `{agent.name}` and thread `{thread_id}`\"\n                    )\n                    fccs = get_function_call_contents(run, function_steps)\n                    if fccs:\n                        logger.debug(\n                            f\"Yielding generate_function_call_content for agent `{agent.name}` and \"\n                            f\"thread `{thread_id}`, visibility False\"\n                        )\n                        yield False, generate_function_call_content(agent_name=agent.name, fccs=fccs)\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/agent_thread_actions.py#L208-L244","documentation":"Thrown by AgentThreadActions (non-streaming invoke loop) when a polled ThreadRun enters one of the error_message_states (e.g. 'failed', 'cancelled', 'expired'). It bundles the run status, agent name, thread id, the run's last_error message (or 'None') and the incomplete_details reason (or 'None') so the caller knows exactly why the Azure AI run terminated unsuccessfully.","triggerScenarios":"An AzureAIAgent.invoke run whose status becomes 'failed' (rate limit, content filter, tool error), 'cancelled', or 'expired' during polling; the model/endpoint misconfigured so the run errors server-side.","commonSituations":"Rate limiting or quota exhaustion on the Azure AI endpoint; content-policy filtering; a required tool/function step that errored; invalid model/deployment id; transient Azure service issues.","solutions":["Read the embedded error_message and incomplete_details_reason to identify the server-side cause and address it (e.g. raise quota, fix the function, change content).","Retry with backoff for transient failures (rate limits, 5xx-equivalent run errors).","Verify the deployment/model id and that the agent's tools are correctly wired.","Wrap invoke in try/except AgentInvokeException and surface run.last_error to the user."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def run_is_terminal_failed(run) -> bool:\n    return getattr(run, 'status', None) in {'failed', 'cancelled', 'expired', 'incomplete'}","tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentInvokeException\nimport time\nfor attempt in range(3):\n    try:\n        async for r in agent.invoke(thread=thread):\n            ...\n        break\n    except AgentInvokeException as e:\n        if 'Run failed' in str(e) and attempt < 2:\n            time.sleep(2 ** attempt)\n            continue\n        raise","preventionTips":["Inspect run.last_error and incomplete_details in logs to classify failures.","Apply retry-with-backoff only for transient run errors (rate limits, transient server).","Validate deployment/model ids and tool wiring before invoking."],"tags":["azure-ai","run-status","polling","retry","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}