{"record":{"id":"e85cbffcf480c424","repo":"microsoft/semantic-kernel","slug":"run-failed-with-status-response-status-for-ag-e85cbf","errorCode":null,"errorMessage":"Run failed with status: `{response.status}` for agent `{agent.name}` with error: {error_message} or incomplete details: {incomplete_details}","messagePattern":"Run failed with status: `(.+?)` for agent `(.+?)` with error: (.+?) or incomplete details: (.+?)","errorType":"exception","errorClass":"AgentInvokeException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py","lineNumber":208,"sourceCode":"                tools=tools,\n                response_options=response_options,\n            )\n            if not isinstance(response, Response):\n                raise AgentInvokeException(\"Response is not of type Response\")\n\n            if store_enabled:\n                thread.response_id = response.id\n                # Chain subsequent requests to this response so tool outputs are associated correctly\n                previous_response_id = response.id\n\n            if response.status in cls.error_message_states:\n                error_message = \"\"\n                if response.error and response.error.message:\n                    error_message = response.error.message\n                incomplete_details = \"\"\n                if response.incomplete_details:\n                    incomplete_details = str(response.incomplete_details.reason)\n                raise AgentInvokeException(\n                    f\"Run failed with status: `{response.status}` for agent `{agent.name}` \"\n                    f\"with error: {error_message} or incomplete details: {incomplete_details}\"\n                )\n\n            try:\n                response = await asyncio.wait_for(\n                    cls._poll_until_completed(agent, response, polling_options or agent.polling_options),\n                    timeout=agent.polling_options.run_polling_timeout.total_seconds(),\n                )\n            except asyncio.TimeoutError:\n                raise AgentInvokeException(\"Polling timed out before completion.\")\n\n            # Type narrowing for subsequent usage\n            assert isinstance(response, Response)  # nosec\n\n            # Extract reasoning content and yield as intermediate message (not visible to user)\n            reasoning_items = cls._get_reasoning_items_from_output(response.output)  # type: ignore\n            if reasoning_items:","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py#L190-L226","documentation":"Raised as an AgentInvokeException when the OpenAI Responses API returns a run whose status is one of the terminal failure states (\"failed\" or \"incomplete\", per the class-level error_message_states). Semantic Kernel surfaces both the API's native error.message (when present) and the incomplete_details.reason so you can see why the backend aborted. This is a hard, non-retryable failure of the underlying response run itself, distinct from HTTP transport errors.","triggerScenarios":"The invoke loop calls _get_response -> agent.client.responses.create, then checks response.status in [\"failed\", \"incomplete\"]. Triggered when the model run is marked failed (e.g. server-side error, model internal failure) or incomplete (e.g. max_output_tokens hit, content policy, max tool-call iterations reached without resolution). Occurs during OpenAIResponsesAgent.invoke / invoke_stream with store enabled or disabled.","commonSituations":"Output truncated due to max_output_tokens being too small (yields \"incomplete\" with reason like max_output_tokens); backend model errors; overly aggressive function_choice_behavior.maximum_auto_invoke_attempts exhausting tool rounds; prompts that trigger incomplete generation; hitting model-side rate/capacity issues that surface as a failed run rather than an HTTP error.","solutions":["If status is 'incomplete' with reason max_output_tokens, increase max_output_tokens in the agent's response_options / prompt_execution_settings.","Inspect response.error.message and response.incomplete_details.reason in the exception text to identify the exact cause.","If function-call loops never resolve, raise function_choice_behavior.maximum_auto_invoke_attempts or fix the plugin so the model can converge.","Retry with a different model or after a delay if the error_message indicates a transient backend failure.","Simplify the prompt / reduce context size if the run fails due to input size or policy."],"exampleFix":"// before\nagent = OpenAIResponsesAgent(\n    ai_model_id=\"gpt-4o\",\n    client=client,\n    instructions=\"...\",\n)\n# after - set a larger output budget via response_options\nagent = OpenAIResponsesAgent(\n    ai_model_id=\"gpt-4o\",\n    client=client,\n    instructions=\"...\",\n    response_options={\"max_output_tokens\": 4096},\n)","handlingStrategy":"try-catch","validationCode":"# Before invoking, sanity-check likely causes of 'incomplete':\nsettings = agent.prompt_execution_settings\nmax_tokens = getattr(settings, \"max_output_tokens\", None)\nif max_tokens is not None and max_tokens < 512:\n    raise ValueError(\"max_output_tokens is very low; the run may come back 'incomplete'.\")","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import AgentInvokeException\ntry:\n    async for is_final, msg in agent.invoke(thread=thread):\n        ...\nexcept AgentInvokeException as ex:\n    if \"incomplete\" in str(ex):\n        # raise token budget or simplify prompt\n        ...\n    elif \"failed\" in str(ex):\n        # log and surface backend failure\n        ...","preventionTips":["Set max_output_tokens generously relative to expected output length.","Cap function_choice_behavior.maximum_auto_invoke_attempts at a value the run can actually resolve.","Log response.error / incomplete_details from the exception text for diagnostics."],"tags":["openai-responses","agent","api-failure","model-limit"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}