microsoft/semantic-kernel · error · AgentInvokeException

Run failed with status: `{run.status}` for agent `{agent.nam

Error message

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}

What it means

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.

Source

Thrown at python/semantic_kernel/agents/azure_ai/agent_thread_actions.py:226

            **run_options,
        )

        processed_step_ids = set()
        function_steps: dict[str, "FunctionCallContent"] = {}

        while run.status != "completed":
            run = await cls._poll_run_status(
                agent=agent, run=run, thread_id=thread_id, polling_options=polling_options or agent.polling_options
            )

            if run.status in cls.error_message_states:
                error_message = "None"
                if run.last_error and run.last_error.message:
                    error_message = run.last_error.message
                incomplete_details_reason = "None"
                if run.incomplete_details and run.incomplete_details.reason:
                    incomplete_details_reason = run.incomplete_details.reason
                raise AgentInvokeException(
                    f"Run failed with status: `{run.status}` for agent `{agent.name}` and thread `{thread_id}` "
                    f"with error: {error_message} and incomplete details reason: {incomplete_details_reason}"
                )

            # Check if function calling is required
            if run.status == "requires_action":
                if isinstance(run.required_action, SubmitToolOutputsAction):
                    logger.debug(
                        f"Run [{run.id}] requires tool action for agent `{agent.name}` and thread `{thread_id}`"
                    )
                    fccs = get_function_call_contents(run, function_steps)
                    if fccs:
                        logger.debug(
                            f"Yielding generate_function_call_content for agent `{agent.name}` and "
                            f"thread `{thread_id}`, visibility False"
                        )
                        yield False, generate_function_call_content(agent_name=agent.name, fccs=fccs)

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. 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).
  2. Retry with backoff for transient failures (rate limits, 5xx-equivalent run errors).
  3. Verify the deployment/model id and that the agent's tools are correctly wired.
  4. Wrap invoke in try/except AgentInvokeException and surface run.last_error to the user.
Defensive patterns

Strategy: try-catch

Type guard

def run_is_terminal_failed(run) -> bool:
    return getattr(run, 'status', None) in {'failed', 'cancelled', 'expired', 'incomplete'}

Try / catch

from semantic_kernel.exceptions.agent_exceptions import AgentInvokeException
import time
for attempt in range(3):
    try:
        async for r in agent.invoke(thread=thread):
            ...
        break
    except AgentInvokeException as e:
        if 'Run failed' in str(e) and attempt < 2:
            time.sleep(2 ** attempt)
            continue
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/824b575b12d76af3. Report an issue: GitHub.