Repository navigation
Replies: 1 comment
|
The chart never lands on your machine, so file_read and file_write cannot see it. AgentCoreCodeInterpreter.execute_code calls the Bedrock session invoke with executeCode, and read_files calls invoke with readFiles on that same remote session. The file_read and file_write tools from strands_tools operate on the local filesystem. A path printed by the sandbox is not a local path. There is a second cut in _create_tool_result in agent_core_code_interpreter.py. It keeps only str(result.get("content")) as one text block. Binary image parts in the Bedrock result are not passed through as image content, and they are not written to disk. Ask the model to call the code interpreter read_files action on the sandbox path (list_files first if the path is unknown). Saving a PNG still has to be your own code around the tool result, because that helper stringifies the payload. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm struggling to get the AgentCoreCodeInterpreter tool to work with a Strands agent in what I expect would be a fairly common use case. I have an agent that, among other things, I'd like to be able to call the code interpreter in order to produce graphs/visualizations of data and to perform more complex analysis. I can get the agent to call the code interpreter, and it appears to generate images, but the agent cannot successfully do anything with the files that are produced.
I've stripped down my code to be as simple as possible.
Code:
When I run this code the agent struggles to retrieve the image file data from the sandbox, flailing with various attempts to retrieve base64-encoded data, deal with JSON formatting, etc. I almost always see an error that says
bedrock threw context window overflow error.Output:
Is there somewhere I can find an example of how to get an agent to call an AgentCoreCodeInterpreter tool properly?
All reactions