BerriAI/litellm · error · AzureAIAgentsError

Run

Error message

Run {status}: {error_msg}

What it means

Error "Run {status}: {error_msg}" thrown in BerriAI/litellm.

Solutions

  1. Check the run status and error message; inspect the agent run in Azure AI Foundry for details.

When it happens

Trigger: Thrown at litellm/llms/azure_ai/agents/handler.py:418 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/9cfbbbacf4574567. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/azure_ai/agents/handler.py:418

        run_id: Final = run_data["id"]
        verbose_logger.debug("Created run: %s", run_id)

        # Step 4: Poll for completion
        status_url: Final = self._build_run_status_url(api_base, thread_id, run_id, api_version)
        for _ in range(self.config.MAX_POLL_ATTEMPTS):
            response = make_request("GET", status_url)
            self._check_response(response, [200], "Failed to get run status")

            status_data: _RunStatus = response.json()
            status = status_data.get("status")
            verbose_logger.debug("Run status: %s", status)

            if status == "completed":
                break
            elif status in ["failed", "cancelled", "expired"]:
                error_data: _RunStatus = response.json()
                error_msg = error_data.get("last_error", {}).get("message", "Unknown error")
                raise AzureAIAgentsError(status_code=500, message=f"Run {status}: {error_msg}")

            time.sleep(self.config.POLL_INTERVAL_SECONDS)
        else:
            raise AzureAIAgentsError(status_code=408, message="Run timed out waiting for completion")

        # Step 5: Get messages
        response = make_request("GET", self._build_list_messages_url(api_base, thread_id, api_version))
        self._check_response(response, [200], "Failed to get messages")

        messages_data: Final[_AzureMessagesData] = response.json()
        content, annotations = self._extract_content_from_messages(messages_data)
        return thread_id, content, annotations

    # -------------------------------------------------------------------------
    # Async Completion
    # -------------------------------------------------------------------------
    async def acompletion(
        self,

View on GitHub (pinned to 77b7c6c40c)