@smithy/eventstream-codec
Error: "Reported message length does not match received message length" when decoding converseStream
API response in node
#6682
Unanswered
stephmilovic
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description:
I'm working with LangChain + Bedrock and trying to switch from the Invoke APIs to the Converse APIs. I am hitting the Bedrock APIs directly with axios and handing the result back to LangChain's
NodeHttpHandler
andBedrockRuntimeClient
to handle the results.The issue I'm having is in is a different spot in my app where I need to decode the raw stream from the API in order to get the usage object. When using the
InvokeWithResponseStream
API, I'm able to use the@smithy/eventstream-codec
to decode the final response chunk to get the usage object. However, with theConverseStream
API an issue occurs intermittently, with some chunks decoding successfully and others failing with the error:The same decoding logic works reliably with the
InvokeWithResponseStream
API, so the issue appears specific toConverseStream
. I suspect there may be special encoding applied toConverseStream
, but I could not find documentation about how to handle or decode these streams properly.Environment:
v20.15.1
3.1.9
anthropic.claude-3-5-sonnet-20240620-v1:0
Steps to Reproduce:
converseStream
API in AWS Bedrock to receive a streaming response.Observed Behavior:
Successful Decoding:
Failed Decoding:
Troubleshooting Steps Taken:
Uint8Array
to ensure message continuity.TextDecoder
to verify structure. Can see in the failed decoded chunks, the usage object exists but I cannot parse it out of these strings which appear to be a mix of binary data and JSON-like structures.invokeStream
, suggesting the issue is specific toconverseStream
.Questions:
converseStream
API that differs frominvokeStream
?converseStream
API response using@smithy/eventstream-codec
?converseStream
API?Request:
Please provide guidance on decoding the
converseStream
API response or clarify if there are specific differences in encoding for this API. Let me know if additional logs, raw data, or debugging information is needed.Beta Was this translation helpful? Give feedback.
All reactions