Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/strands/models/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

T = TypeVar("T", bound=BaseModel)

DEFAULT_READ_TIMEOUT = 120

class BedrockModel(Model):
"""AWS Bedrock model provider implementation.
Expand Down Expand Up @@ -147,7 +148,7 @@ def __init__(

client_config = boto_client_config.merge(BotocoreConfig(user_agent_extra=new_user_agent))
else:
client_config = BotocoreConfig(user_agent_extra="strands-agents")
client_config = BotocoreConfig(user_agent_extra="strands-agents", read_timeout=DEFAULT_READ_TIMEOUT)

resolved_region = region_name or session.region_name or os.environ.get("AWS_REGION") or DEFAULT_BEDROCK_REGION

Expand Down
16 changes: 15 additions & 1 deletion tests/strands/models/test_bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import strands
from strands.models import BedrockModel
from strands.models.bedrock import DEFAULT_BEDROCK_MODEL_ID, DEFAULT_BEDROCK_REGION
from strands.models.bedrock import DEFAULT_BEDROCK_MODEL_ID, DEFAULT_BEDROCK_REGION, DEFAULT_READ_TIMEOUT
from strands.types.exceptions import ModelThrottledException
from strands.types.tools import ToolSpec

Expand Down Expand Up @@ -216,6 +216,20 @@ def test__init__default_user_agent(bedrock_client):
assert kwargs["service_name"] == "bedrock-runtime"
assert isinstance(kwargs["config"], BotocoreConfig)
assert kwargs["config"].user_agent_extra == "strands-agents"
assert kwargs["config"].read_timeout == DEFAULT_READ_TIMEOUT


def test__init__default_read_timeout(bedrock_client):
"""Set default read timeout when no boto_client_config is provided."""
with unittest.mock.patch("strands.models.bedrock.boto3.Session") as mock_session_cls:
mock_session = mock_session_cls.return_value
_ = BedrockModel()

# Verify the client was created with the correct read timeout
mock_session.client.assert_called_once()
args, kwargs = mock_session.client.call_args
assert isinstance(kwargs["config"], BotocoreConfig)
assert kwargs["config"].read_timeout == DEFAULT_READ_TIMEOUT


def test__init__with_custom_boto_client_config_no_user_agent(bedrock_client):
Expand Down
Loading