{"record":{"id":"7769f91b6b5b2efd","repo":"BerriAI/litellm","slug":"wxo-run-ended-with-non-success-status-status","errorCode":null,"errorMessage":"WXO run ended with non-success status '{status}': {run_data}","messagePattern":"WXO run ended with non-success status '(.+?)': (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/a2a_protocol/providers/watsonx_orchestrate/handler.py","lineNumber":167,"sourceCode":"        base_url: str,\n        auth_headers: dict[str, str],\n        client: AsyncHTTPHandler,\n    ) -> dict[str, Any]:\n        status = run_data.get(\"status\", \"\")\n        if status not in WatsonxOrchestrateTransformation.TERMINAL_STATES:\n            run_id: Final = run_data.get(\"run_id\") or run_data.get(\"id\") or \"\"\n            if not run_id:\n                raise ValueError(f\"WXO: No run_id in response: {run_data}\")\n            run_data = await WatsonxOrchestrateHandler._poll_run(\n                base_url=base_url,\n                run_id=run_id,\n                auth_headers=auth_headers,\n                client=client,\n            )\n            status = run_data.get(\"status\", \"\")\n\n        if status not in WatsonxOrchestrateTransformation.SUCCESS_STATES:\n            raise RuntimeError(f\"WXO run ended with non-success status '{status}': {run_data}\")\n\n        return run_data\n\n    @staticmethod\n    async def _accumulate_wxo_sse_text(response: Any) -> str:\n        accumulated_text = \"\"\n        async for line in response.aiter_lines():\n            if not line.startswith(\"data:\"):\n                continue\n            data_str = line[5:].strip()\n            if not data_str or data_str == \"[DONE]\":\n                continue\n            try:\n                event = json.loads(data_str)\n            except json.JSONDecodeError:\n                continue\n            chunk_text = WatsonxOrchestrateTransformation.extract_text_from_wxo_result(event)\n            if chunk_text:","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/a2a_protocol/providers/watsonx_orchestrate/handler.py#L149-L185","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Read the run_data embedded in the message — WXO usually includes an error/statusReason explaining the failure","Fix or harden the agent flow in Watsonx Orchestrate (tool config, input contract)","Catch RuntimeError and surface a 502 with the WXO status to the caller","For transient failures, retry the request with a fresh thread_id"],"exampleFix":"# before\nfinal = WatsonxOrchestrateHandler._get_successful_run_data(\n    run_data=run_data.json(), base_url=base_url,\n    auth_headers=auth_headers, client=client,\n)\n\n# after\nimport asyncio\nfor attempt in range(3):\n    try:\n        final = WatsonxOrchestrateHandler._get_successful_run_data(\n            run_data=run_data.json(), base_url=base_url,\n            auth_headers=auth_headers, client=client,\n        )\n        break\n    except RuntimeError as e:\n        if attempt == 2:\n            raise HTTPException(status_code=502, detail=str(e)) from e\n        await asyncio.sleep(2 ** attempt)\n","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    final = WatsonxOrchestrateHandler._get_successful_run_data(run_data, base_url, headers, client)\nexcept RuntimeError as e:\n    if \"non-success status\" in str(e):\n        logger.warning(\"WXO run failed, retrying once with new thread: %s\", e)\n        raise HTTPException(502, detail=str(e)) from e\n    raise\n","preventionTips":["Include WXO run status in dashboards to spot failing flows early","Surface statusReason from run_data in error reports for faster triage","Retry with backoff and a fresh thread_id for transient flow failures"],"tags":["watsonx-orchestrate","run-status","upstream-failure","polling"],"backgroundTag":"background-task-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}