File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 4545
4646T = TypeVar ("T" , bound = BaseModel )
4747
48+ DEFAULT_READ_TIMEOUT = 120
4849
4950class BedrockModel (Model ):
5051 """AWS Bedrock model provider implementation.
@@ -147,7 +148,7 @@ def __init__(
147148
148149 client_config = boto_client_config .merge (BotocoreConfig (user_agent_extra = new_user_agent ))
149150 else :
150- client_config = BotocoreConfig (user_agent_extra = "strands-agents" )
151+ client_config = BotocoreConfig (user_agent_extra = "strands-agents" , read_timeout = DEFAULT_READ_TIMEOUT )
151152
152153 resolved_region = region_name or session .region_name or os .environ .get ("AWS_REGION" ) or DEFAULT_BEDROCK_REGION
153154
Original file line number Diff line number Diff line change 1111
1212import strands
1313from strands .models import BedrockModel
14- from strands .models .bedrock import DEFAULT_BEDROCK_MODEL_ID , DEFAULT_BEDROCK_REGION
14+ from strands .models .bedrock import DEFAULT_BEDROCK_MODEL_ID , DEFAULT_BEDROCK_REGION , DEFAULT_READ_TIMEOUT
1515from strands .types .exceptions import ModelThrottledException
1616from strands .types .tools import ToolSpec
1717
@@ -216,6 +216,20 @@ def test__init__default_user_agent(bedrock_client):
216216 assert kwargs ["service_name" ] == "bedrock-runtime"
217217 assert isinstance (kwargs ["config" ], BotocoreConfig )
218218 assert kwargs ["config" ].user_agent_extra == "strands-agents"
219+ assert kwargs ["config" ].read_timeout == DEFAULT_READ_TIMEOUT
220+
221+
222+ def test__init__default_read_timeout (bedrock_client ):
223+ """Set default read timeout when no boto_client_config is provided."""
224+ with unittest .mock .patch ("strands.models.bedrock.boto3.Session" ) as mock_session_cls :
225+ mock_session = mock_session_cls .return_value
226+ _ = BedrockModel ()
227+
228+ # Verify the client was created with the correct read timeout
229+ mock_session .client .assert_called_once ()
230+ args , kwargs = mock_session .client .call_args
231+ assert isinstance (kwargs ["config" ], BotocoreConfig )
232+ assert kwargs ["config" ].read_timeout == DEFAULT_READ_TIMEOUT
219233
220234
221235def test__init__with_custom_boto_client_config_no_user_agent (bedrock_client ):
You can’t perform that action at this time.
0 commit comments