Skip to content

[BUG] TypeError: can only concatenate str (not "int") to str on Bedrock AgentCore #488

@cyrusniu08

Description

@cyrusniu08

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.0.0

Python Version

3.11

Operating System

N/A. Using Bedrock agent-core

Installation Method

pip

Steps to Reproduce

Any agent that uses bedrock agent and contains a tool that requires some input in the form of a long numeric string. Like "12345678912357@gmail.com". Deploy it to Bedrock agent-core, run it, will see the problem.

Expected Behavior

Not throw an error.

Actual Behavior

Threw an error at

File "/app/strands/event_loop/streaming.py", line 130, in handle_content_block_delta
state["current_tool_use"]["input"] += delta_content["toolUse"]["input"]
TypeError: can only concatenate str (not "int") to str

Additional Context

The problem is that when in bedrock streaming mode, bedrock outputs json that contains integers. In non streaming mode bedrock.py manually constructs a streaming mode event by using json.dumps, but such string conversion doesn't exist in streaming mode.

Possible Solution

The fix is pretty simple, just surround delta_content["toolUse"]["input"] with str(). I have pulled the sdk package locally and added this fix, which then works with my agent perfectly.

Related Issues

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions