{"record":{"id":"ed691af8acdb065c","repo":"BerriAI/litellm","slug":"boto3-botocore-is-required-for-aws-event-stream-pa","errorCode":null,"errorMessage":"boto3/botocore is required for AWS event stream parsing","messagePattern":"boto3/botocore is required for AWS event stream parsing","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_agent/transformation.py","lineNumber":172,"sourceCode":"    ) -> dict:\n        # use the last message content as the query\n        query: Final[str] = convert_content_list_to_str(messages[-1])\n        return {\n            \"inputText\": query,\n            \"enableTrace\": True,\n            **optional_params,\n        }\n\n    def _parse_aws_event_stream(self, raw_content: bytes) -> InvokeAgentEventList:\n        \"\"\"\n        Parse AWS event stream format using boto3/botocore's built-in parser.\n        This is the same approach used in the existing AWSEventStreamDecoder.\n        \"\"\"\n        try:\n            from botocore.eventstream import EventStreamBuffer\n            from botocore.parsers import EventStreamJSONParser\n        except ImportError:\n            raise ImportError(\"boto3/botocore is required for AWS event stream parsing\")\n\n        events: Final[InvokeAgentEventList] = []\n        parser: Final = EventStreamJSONParser()\n        event_stream_buffer: Final = EventStreamBuffer()\n\n        # Add the entire response to the buffer\n        event_stream_buffer.add_data(raw_content)\n\n        # Process all events in the buffer\n        for event in event_stream_buffer:\n            try:\n                headers = self._extract_headers_from_event(event)\n\n                event_type = headers.get(\"event_type\", \"\")\n\n                if event_type == \"chunk\":\n                    # Handle chunk events specially - they contain decoded content, not JSON\n                    message = self._parse_message_from_event(event, parser)","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_agent/transformation.py#L154-L190","documentation":"Parsing the AWS event-stream for Bedrock InvokeAgent relies on botocore's EventStreamBuffer and EventStreamJSONParser. If neither boto3 nor botocore is importable, this ImportError is raised at response-parse time — the HTTP request may already have been sent and paid for before the failure.","triggerScenarios":"Any streaming invoke-agent call on an environment where boto3/botocore was never installed: slim Docker images, Lambda layers without the AWS SDK, CI images that prune 'unused' deps, or litellm installed without the bedrock extra.","commonSituations":"Teams that previously used only OpenAI-style providers adopting the agent/agentcore paths; minimized containers; dependency resolvers that drop optional boto3 when nothing else pins it.","solutions":["Install the SDK: pip install boto3 (botocore ships with it)","Or install LiteLLM with the extra: pip install 'litellm[bedrock]'","Add boto3 explicitly to your deployment image/requirements so it is never pruned","Add a startup health check importing botocore.eventstream to fail fast before traffic"],"exampleFix":"// before\n# only litellm installed → ImportError at stream-parse time\n\n// after\npip install 'litellm[bedrock]'   # or: pip install boto3","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"botocore\") is None:\n    raise RuntimeError(\"boto3/botocore is required for invoke-agent streaming — pip install 'litellm[bedrock]'\")\n\nresp = litellm.completion(model=\"agent/ID/ALIAS\", messages=msgs, stream=True)","typeGuard":"def invoke_agent_dependencies_available() -> bool:\n    \"\"\"True when botocore's event-stream parser is importable.\"\"\"\n    return importlib.util.find_spec(\"botocore\") is not None","tryCatchPattern":"try:\n    resp = litellm.completion(model=\"agent/ID/ALIAS\", messages=msgs, stream=True)\nexcept ImportError as e:\n    raise RuntimeError(\"Install AWS SDK: pip install boto3\") from e","preventionTips":["Install litellm with the bedrock extra in any image that touches Bedrock","Add a startup dependency check that imports botocore.eventstream","Pin boto3 in requirements so optimizers cannot prune it"],"tags":["bedrock","invoke-agent","boto3","import-error","dependencies"],"backgroundTag":"missing-dependency","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}