BerriAI/litellm · error · RuntimeError

WXO run ended with non-success status

Error message

WXO run ended with non-success status '{status}': {run_data}

What it means

Once a WXO run reaches a terminal state, _get_successful_run_data checks it against SUCCESS_STATES; anything else (failed, cancelled, error) raises RuntimeError with the status and full run payload. This is the upstream agent run failing or being canceled — LiteLLM is only reporting the terminal status it observed while polling.

Solutions

  1. Read the run_data embedded in the message — WXO usually includes an error/statusReason explaining the failure
  2. Fix or harden the agent flow in Watsonx Orchestrate (tool config, input contract)
  3. Catch RuntimeError and surface a 502 with the WXO status to the caller
  4. For transient failures, retry the request with a fresh thread_id

Example fix

# before
final = WatsonxOrchestrateHandler._get_successful_run_data(
    run_data=run_data.json(), base_url=base_url,
    auth_headers=auth_headers, client=client,
)

# after
import asyncio
for attempt in range(3):
    try:
        final = WatsonxOrchestrateHandler._get_successful_run_data(
            run_data=run_data.json(), base_url=base_url,
            auth_headers=auth_headers, client=client,
        )
        break
    except RuntimeError as e:
        if attempt == 2:
            raise HTTPException(status_code=502, detail=str(e)) from e
        await asyncio.sleep(2 ** attempt)
Defensive patterns

Strategy: retry

Try / catch

try:
    final = WatsonxOrchestrateHandler._get_successful_run_data(run_data, base_url, headers, client)
except RuntimeError as e:
    if "non-success status" in str(e):
        logger.warning("WXO run failed, retrying once with new thread: %s", e)
        raise HTTPException(502, detail=str(e)) from e
    raise

Prevention

When it happens

Trigger: The WXO agent's flow errors out server-side (bad input, downstream LLM/tool failure) and the run status becomes a non-success terminal value; a run cancelled in the WXO console mid-poll; transient WXO internal errors terminating the run.

Common situations: Agent flows with failing tools or exhausted LLM quotas inside Watsonx Orchestrate; input messages the flow cannot route; cancelled long-running runs; environment differences (staging flow works, production flow fails).

Related errors


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

Appendix: source

Thrown at litellm/a2a_protocol/providers/watsonx_orchestrate/handler.py:167

        base_url: str,
        auth_headers: dict[str, str],
        client: AsyncHTTPHandler,
    ) -> dict[str, Any]:
        status = run_data.get("status", "")
        if status not in WatsonxOrchestrateTransformation.TERMINAL_STATES:
            run_id: Final = run_data.get("run_id") or run_data.get("id") or ""
            if not run_id:
                raise ValueError(f"WXO: No run_id in response: {run_data}")
            run_data = await WatsonxOrchestrateHandler._poll_run(
                base_url=base_url,
                run_id=run_id,
                auth_headers=auth_headers,
                client=client,
            )
            status = run_data.get("status", "")

        if status not in WatsonxOrchestrateTransformation.SUCCESS_STATES:
            raise RuntimeError(f"WXO run ended with non-success status '{status}': {run_data}")

        return run_data

    @staticmethod
    async def _accumulate_wxo_sse_text(response: Any) -> str:
        accumulated_text = ""
        async for line in response.aiter_lines():
            if not line.startswith("data:"):
                continue
            data_str = line[5:].strip()
            if not data_str or data_str == "[DONE]":
                continue
            try:
                event = json.loads(data_str)
            except json.JSONDecodeError:
                continue
            chunk_text = WatsonxOrchestrateTransformation.extract_text_from_wxo_result(event)
            if chunk_text:

View on GitHub (pinned to 77b7c6c40c)