microsoft/semantic-kernel · error · AgentInvokeException
Run failed with status: `{response.status}` for agent `{agen
Error message
Run failed with status: `{response.status}` for agent `{agent.name}` with error: {error_message} or incomplete details: {incomplete_details} What it means
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.
Source
Thrown at python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py:208
tools=tools,
response_options=response_options,
)
if not isinstance(response, Response):
raise AgentInvokeException("Response is not of type Response")
if store_enabled:
thread.response_id = response.id
# Chain subsequent requests to this response so tool outputs are associated correctly
previous_response_id = response.id
if response.status in cls.error_message_states:
error_message = ""
if response.error and response.error.message:
error_message = response.error.message
incomplete_details = ""
if response.incomplete_details:
incomplete_details = str(response.incomplete_details.reason)
raise AgentInvokeException(
f"Run failed with status: `{response.status}` for agent `{agent.name}` "
f"with error: {error_message} or incomplete details: {incomplete_details}"
)
try:
response = await asyncio.wait_for(
cls._poll_until_completed(agent, response, polling_options or agent.polling_options),
timeout=agent.polling_options.run_polling_timeout.total_seconds(),
)
except asyncio.TimeoutError:
raise AgentInvokeException("Polling timed out before completion.")
# Type narrowing for subsequent usage
assert isinstance(response, Response) # nosec
# Extract reasoning content and yield as intermediate message (not visible to user)
reasoning_items = cls._get_reasoning_items_from_output(response.output) # type: ignore
if reasoning_items:View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
agent = OpenAIResponsesAgent(
ai_model_id="gpt-4o",
client=client,
instructions="...",
)
# after - set a larger output budget via response_options
agent = OpenAIResponsesAgent(
ai_model_id="gpt-4o",
client=client,
instructions="...",
response_options={"max_output_tokens": 4096},
) Defensive patterns
Strategy: try-catch
Validate before calling
# Before invoking, sanity-check likely causes of 'incomplete':
settings = agent.prompt_execution_settings
max_tokens = getattr(settings, "max_output_tokens", None)
if max_tokens is not None and max_tokens < 512:
raise ValueError("max_output_tokens is very low; the run may come back 'incomplete'.") Try / catch
from semantic_kernel.exceptions import AgentInvokeException
try:
async for is_final, msg in agent.invoke(thread=thread):
...
except AgentInvokeException as ex:
if "incomplete" in str(ex):
# raise token budget or simplify prompt
...
elif "failed" in str(ex):
# log and surface backend failure
... Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Polling timed out before completion.
- Unable to create agent
- No file found in the response.
- AzureAI project client not found.
- The Bedrock agent requires a message to be invoked.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/e85cbffcf480c424.
Report an issue: GitHub.