BerriAI/litellm · error · BedrockError

AgentCore: Failed to read/parse JSON response body: {e}

Error message

AgentCore: Failed to read/parse JSON response body: {e}

What it means

Error "AgentCore: Failed to read/parse JSON response body: {e}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/bedrock/chat/agentcore/transformation.py:687

        # LOGGING
        logging_obj.post_call(
            input=messages,
            api_key="",
            original_response="first stream response received",
            additional_args={"complete_input_dict": data},
        )

        # Check if response is JSON (agent used sync return) instead of SSE
        content_type: Final = response.headers.get("content-type", "").lower()
        if "application/json" in content_type:
            verbose_logger.debug(
                "AgentCore streaming: received JSON response instead of SSE, converting to single-chunk stream"
            )
            try:
                body: Final = response.read()
                response_json: Final = json.loads(body)
            except (json.JSONDecodeError, Exception) as e:
                raise BedrockError(
                    status_code=response.status_code,
                    message=f"AgentCore: Failed to read/parse JSON response body: {e}",
                )
            parsed: Final = self._parse_json_response(response_json)

            def _json_as_sync_stream():
                # Content chunk
                content_chunk: Final = ModelResponseStream(
                    id=f"chatcmpl-{uuid.uuid4()}",
                    created=0,
                    model=model,
                    object="chat.completion.chunk",
                )
                content_chunk.choices = [
                    StreamingChoices(
                        finish_reason=None,
                        index=0,
                        delta=Delta(content=parsed["content"], role="assistant"),

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. The AgentCore response body was not valid JSON; check the agent runtime output.

When it happens

Trigger: Thrown at litellm/llms/bedrock/chat/agentcore/transformation.py:687 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/88627320296f74bf. Report an issue: GitHub.