Skip to content

[BUG] use_aws with Nova model #519

@rprentyaws

Description

@rprentyaws

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.1

Python Version

3.13.3

Operating System

MacOS 15.5

Installation Method

pip

Steps to Reproduce

Use the use_aws with a very large prompt. If you DM me internally, I can send you the full app and prompt.

api_spec = 
sonnet37_eu = "eu.anthropic.claude-3-7-sonnet-20250219-v1:0"
sonnet37_us = "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
novapro_eu = "eu.amazon.nova-pro-v1:0"
novapro_us = "us.amazon.nova-pro-v1:0"

model = novapro_us 
region = "us-east-1"

boto_config = BotocoreConfig(
    read_timeout=3600,
    retries={'max_attempts': 5},
    connect_timeout=3600
)

bedrock_model = BedrockModel(
    model_id=model, 
    region_name=region,
    boto_client_config=boto_config
)

agent = Agent(model=bedrock_model, tools=[use_aws])
prompt = "<<<ping me internally for this>>>"
agent(prompt)

Expected Behavior

The use_aws tool should succeed in its operation against the respective AWS service.

If I invoke use_aws directly, it works:

result = agent.tool.use_aws(
     service_name="xxx", 
     operation_name="xxx",
     parameters={xxx},
     region="us-east-1",
     label="do xxx"
 )

However, when the agent invokes it, it does not work:

agent(agent_prompt)

Actual Behavior

Invocation logs only show this:

{
    "timestamp": "2025-07-23T08:36:01Z",
    "accountId": "xxx",
    "identity": {
        "arn": "xxx"
    },
    "region": "us-east-1",
    "requestId": "03158d6a-38ba-4177-8478-b085d741b516",
    "operation": "ConverseStream",
    "modelId": "us.amazon.nova-pro-v1:0",
    "errorCode": "ModelErrorException",
    "inferenceRegion": "us-west-2",
    "schemaType": "ModelInvocationLog",
    "schemaVersion": "1.0"
}

Error on the client from running python app.py:

Traceback (most recent call last):
  File "/Users/rprenty/Desktop/Importer/app.py", line 83, in <module>
    try:
    
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 377, in __call__
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 373, in execute
    return asyncio.run(self.invoke_async(prompt, **kwargs))
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 398, in invoke_async
    async for event in events:
        _ = event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 508, in stream_async
    async for event in events:
    ...<2 lines>...
            yield event["callback"]
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 544, in _run_loop
    async for event in events:
    ...<13 lines>...
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 583, in _execute_event_loop_cycle
    async for event in events:
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 187, in event_loop_cycle
    raise e
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 132, in event_loop_cycle
    async for event in stream_messages(agent.model, agent.system_prompt, agent.messages, tool_specs):
    ...<6 lines>...
            }
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 318, in stream_messages
    async for event in process_stream(chunks):
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 273, in process_stream
    async for chunk in chunks:
    ...<16 lines>...
            handle_redact_content(chunk["redactContent"], state)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/models/bedrock.py", line 350, in stream
    await task
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/models/bedrock.py", line 385, in _stream
    for chunk in response["stream"]:
                 ~~~~~~~~^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/botocore/eventstream.py", line 591, in __iter__
    for event in self._event_generator:
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/botocore/eventstream.py", line 598, in _create_raw_event_generator
    for chunk in self._raw_stream.stream():
                 ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1063, in stream
    yield from self.read_chunked(amt, decode_content=decode_content)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1219, in read_chunked
    self._update_chunk_length()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1149, in _update_chunk_length
    raise ProtocolError("Response ended prematurely") from None
urllib3.exceptions.ProtocolError: Response ended prematurely
2025-07-23 09:39:08,905 | ERROR | root | Full stack trace:
  File "/Users/rprenty/Desktop/Importer/app.py", line 83, in <module>
    try:
    
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 377, in __call__
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 373, in execute
    return asyncio.run(self.invoke_async(prompt, **kwargs))
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 398, in invoke_async
    async for event in events:
        _ = event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 508, in stream_async
    async for event in events:
    ...<2 lines>...
            yield event["callback"]
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 544, in _run_loop
    async for event in events:
    ...<13 lines>...
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 583, in _execute_event_loop_cycle
    async for event in events:
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 187, in event_loop_cycle
    raise e
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 132, in event_loop_cycle
    async for event in stream_messages(agent.model, agent.system_prompt, agent.messages, tool_specs):
    ...<6 lines>...
            }
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 318, in stream_messages
    async for event in process_stream(chunks):
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 273, in process_stream
    async for chunk in chunks:
    ...<16 lines>...
            handle_redact_content(chunk["redactContent"], state)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/models/bedrock.py", line 350, in stream
    await task
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/models/bedrock.py", line 385, in _stream
    for chunk in response["stream"]:
                 ~~~~~~~~^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/botocore/eventstream.py", line 591, in __iter__
    for event in self._event_generator:
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/botocore/eventstream.py", line 598, in _create_raw_event_generator
    for chunk in self._raw_stream.stream():
                 ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1063, in stream
    yield from self.read_chunked(amt, decode_content=decode_content)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1219, in read_chunked
    self._update_chunk_length()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1149, in _update_chunk_length
    raise ProtocolError("Response ended prematurely") from None

<thinking> xxx. I will use the use_aws tool to make this call.Traceback (most recent call last):
  File "/Users/rprenty/Desktop/Importer/app.py", line 83, in <module>
    try:
    
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 377, in __call__
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 373, in execute
    return asyncio.run(self.invoke_async(prompt, **kwargs))
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 719, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 398, in invoke_async
    async for event in events:
        _ = event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 508, in stream_async
    async for event in events:
    ...<2 lines>...
            yield event["callback"]
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 544, in _run_loop
    async for event in events:
    ...<13 lines>...
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/agent/agent.py", line 583, in _execute_event_loop_cycle
    async for event in events:
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 187, in event_loop_cycle
    raise e
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/event_loop.py", line 132, in event_loop_cycle
    async for event in stream_messages(agent.model, agent.system_prompt, agent.messages, tool_specs):
    ...<6 lines>...
            }
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 318, in stream_messages
    async for event in process_stream(chunks):
        yield event
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/event_loop/streaming.py", line 273, in process_stream
    async for chunk in chunks:
    ...<16 lines>...
            handle_redact_content(chunk["redactContent"], state)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/models/bedrock.py", line 350, in stream
    await task
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/threads.py", line 25, in to_thread
    return await loop.run_in_executor(None, func_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/opentelemetry/instrumentation/threading/__init__.py", line 171, in wrapped_func
    return original_func(*func_args, **func_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/strands/models/bedrock.py", line 385, in _stream
    for chunk in response["stream"]:
                 ~~~~~~~~^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/botocore/eventstream.py", line 591, in __iter__
    for event in self._event_generator:
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/botocore/eventstream.py", line 598, in _create_raw_event_generator
    for chunk in self._raw_stream.stream():
                 ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1063, in stream
    yield from self.read_chunked(amt, decode_content=decode_content)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1219, in read_chunked
    self._update_chunk_length()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/urllib3/response.py", line 1149, in _update_chunk_length
    raise ProtocolError("Response ended prematurely") from None
urllib3.exceptions.ProtocolError: Response ended prematurely

Additional Context

Like I mentioned, if I invoke use_aws directly, it works. If I lean on the agent itself, it doesn't.

If I reduce the size of my input file, the API operation works when leaning on the agent which leads me to believe this issue is related to max_tokens.

If I use Claude models, the error is more helpful on the invocation logging which includes:

...
            "stopReason": "max_tokens"
...

Possible Solution

No response

Related Issues

No response


Internal tracking id: D277187567

Metadata

Metadata

Assignees

No one assigned

    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