Replies: 1 comment 2 replies
-
|
The issue isn’t actually with your MCP tool. Bedrock throws this error because the full base64 image data is getting inserted into the model’s context, and Bedrock models have a strict limit on how much binary or base64 data can be included in a prompt. Even if you convert the base64 into a content block or try returning the image as raw bytes, Strands still ends up passing that entire image into the model context, which quickly exceeds the window size and causes the overflow error. The solution is to avoid sending the actual image data to the model. Instead of returning the base64 or the bytes, upload the image somewhere externally and return only a URL pointing to it. Strands can work with image URLs without embedding the image itself into the prompt, so the model stays within the context limits. This is the approach most MCP users take, and it avoids the overflow problem entirely. If the image must be passed directly, it would need to be extremely small, but for anything of normal size, returning a URL is the only reliable fix. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ive followed the instruction of setting up mcp tools. One of my mcp tool returns an base64 encoded image binary. ive setup a formatter tool which converts base64 to strands contentblock for image name
base64_image_reader. but the agent fail right after it recieves the output from the mcp tool. sayingstrands.models.bedrock - WARNING - bedrock threw context window overflow errorthe mcp tool return in this format:
edit:
ive even tried returning in
Beta Was this translation helpful? Give feedback.
All reactions