{"record":{"id":"44e27d9c139088fc","repo":"BerriAI/litellm","slug":"error-processing-response-e-44e27d","errorCode":null,"errorMessage":"Error processing response: {e}","messagePattern":"Error processing response: (.+?)","errorType":"exception","errorClass":"LangGraphError","httpStatus":null,"severity":"error","filePath":"litellm/llms/langgraph/chat/transformation.py","lineNumber":460,"sourceCode":"\n                prompt_tokens: Final = token_counter(model=\"gpt-3.5-turbo\", messages=messages)\n                completion_tokens = token_counter(model=\"gpt-3.5-turbo\", text=content, count_response_tokens=True)\n                total_tokens: Final = prompt_tokens + completion_tokens\n\n                usage: Final = Usage(\n                    prompt_tokens=prompt_tokens,\n                    completion_tokens=completion_tokens,\n                    total_tokens=total_tokens,\n                )\n                setattr(model_response, \"usage\", usage)\n            except Exception as e:\n                verbose_logger.warning(\"Failed to calculate token usage: %s\", e)\n\n            return model_response\n\n        except Exception as e:\n            verbose_logger.error(\"Error processing LangGraph response: %s\", e)\n            raise LangGraphError(\n                message=f\"Error processing response: {e}\",\n                status_code=raw_response.status_code,\n            )\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        api_key: str | None = None,\n        api_base: str | None = None,\n    ) -> dict:\n        \"\"\"\n        Validate and set up environment for LangGraph requests.\n        \"\"\"\n        headers[\"Content-Type\"] = \"application/json\"","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/langgraph/chat/transformation.py#L442-L478","documentation":"While transforming a (non-streaming) LangGraph response into a ModelResponse, any unexpected exception — malformed JSON structure, missing expected fields, type errors during usage calculation fallbacks — is caught, logged, and re-raised as LangGraphError with the original exception text and the raw response's status code. This is a generic wrapper: the real cause is the embedded exception message.","triggerScenarios":"LangGraph returns 200 but with a body shape LiteLLM does not expect (e.g. error field inside a 200 response, changed event/result envelope after a server version bump, or HTML body from an intermediary); a graph run that fails mid-execution but still yields a 200.","commonSituations":"LangGraph Platform/server version drift changing the response schema; a graph raising internally so the result payload lacks expected keys; proxies or middleware mutating the response body.","solutions":["Read the wrapped exception text in the message — it names the actual field/parse failure","Reproduce with a direct curl to {api_base}/runs/wait and inspect the JSON envelope","Pin/align the LangGraph server version with what this LiteLLM release supports","Ensure the graph completes successfully in the LangGraph playground before routing through LiteLLM","Upgrade LiteLLM if a newer release adapted to the new response schema"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = await litellm.acompletion(model=\"langgraph/agent\", messages=msgs)\nexcept LangGraphError as e:\n    if \"Error processing response\" in str(e):\n        # inspect embedded cause; log raw body via verbose logging to classify schema drift vs. run failure\n        log.error(\"LangGraph transform failed: %s (status=%s)\", e, getattr(e, \"status_code\", None))\n        raise","preventionTips":["Pin both LiteLLM and LangGraph server versions; re-run integration tests on any upgrade","Keep a golden-file test of the expected /runs/wait response envelope to catch schema drift early","Ensure graphs raise cleanly instead of returning 200 bodies with embedded error payloads"],"tags":["langgraph","response-parsing","compatibility"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}