{"record":{"id":"88627320296f74bf","repo":"BerriAI/litellm","slug":"agentcore-failed-to-read-parse-json-response-body","errorCode":null,"errorMessage":"AgentCore: Failed to read/parse JSON response body: {e}","messagePattern":"AgentCore: Failed to read/parse JSON response body: (.+?)","errorType":"exception","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/agentcore/transformation.py","lineNumber":687,"sourceCode":"        # LOGGING\n        logging_obj.post_call(\n            input=messages,\n            api_key=\"\",\n            original_response=\"first stream response received\",\n            additional_args={\"complete_input_dict\": data},\n        )\n\n        # Check if response is JSON (agent used sync return) instead of SSE\n        content_type: Final = response.headers.get(\"content-type\", \"\").lower()\n        if \"application/json\" in content_type:\n            verbose_logger.debug(\n                \"AgentCore streaming: received JSON response instead of SSE, converting to single-chunk stream\"\n            )\n            try:\n                body: Final = response.read()\n                response_json: Final = json.loads(body)\n            except (json.JSONDecodeError, Exception) as e:\n                raise BedrockError(\n                    status_code=response.status_code,\n                    message=f\"AgentCore: Failed to read/parse JSON response body: {e}\",\n                )\n            parsed: Final = self._parse_json_response(response_json)\n\n            def _json_as_sync_stream():\n                # Content chunk\n                content_chunk: Final = ModelResponseStream(\n                    id=f\"chatcmpl-{uuid.uuid4()}\",\n                    created=0,\n                    model=model,\n                    object=\"chat.completion.chunk\",\n                )\n                content_chunk.choices = [\n                    StreamingChoices(\n                        finish_reason=None,\n                        index=0,\n                        delta=Delta(content=parsed[\"content\"], role=\"assistant\"),","sourceCodeStart":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/chat/agentcore/transformation.py#L669-L705","documentation":"Error \"AgentCore: Failed to read/parse JSON response body: {e}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/bedrock/chat/agentcore/transformation.py:687 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The AgentCore response body was not valid JSON; check the agent runtime output."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}