From cabadf1f8860481d85e659b623573769a4f9a5a4 Mon Sep 17 00:00:00 2001 From: Nicholas Clegg Date: Tue, 3 Feb 2026 15:07:51 -0500 Subject: [PATCH 1/2] Fix openai test --- tests_integ/models/test_model_openai.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests_integ/models/test_model_openai.py b/tests_integ/models/test_model_openai.py index 99ac49148..742c70899 100644 --- a/tests_integ/models/test_model_openai.py +++ b/tests_integ/models/test_model_openai.py @@ -1,11 +1,11 @@ import os -import unittest.mock import pydantic import pytest import strands from strands import Agent, tool +from strands.event_loop._retry import ModelRetryStrategy from strands.models.openai import OpenAIModel from strands.types.exceptions import ContextWindowOverflowException, ModelThrottledException from tests_integ.models import providers @@ -206,20 +206,19 @@ def test_rate_limit_throttling_integration_no_retries(model): to avoid waiting for the exponential backoff during testing. """ # Patch the event loop constants to disable retries for this test - with unittest.mock.patch("strands.event_loop.event_loop.MAX_ATTEMPTS", 1): - agent = Agent(model=model) + agent = Agent(model=model, retry_strategy=ModelRetryStrategy(max_attempts=1)) - # Create a message that's very long to trigger token-per-minute rate limits - # This should be large enough to exceed TPM limits immediately - very_long_text = "Really long text " * 20000 + # Create a message that's very long to trigger token-per-minute rate limits + # This should be large enough to exceed TPM limits immediately + very_long_text = "Really long text " * 20000 - # This should raise ModelThrottledException without retries - with pytest.raises(ModelThrottledException) as exc_info: - agent(very_long_text) + # This should raise ModelThrottledException without retries + with pytest.raises(ModelThrottledException) as exc_info: + agent(very_long_text) - # Verify it's a rate limit error - error_message = str(exc_info.value).lower() - assert "rate limit" in error_message or "tokens per min" in error_message + # Verify it's a rate limit error + error_message = str(exc_info.value).lower() + assert "insufficient_quota" in error_message def test_content_blocks_handling(model): From b9f47cabb4c348aa5b3e2680055f00f44d770cc1 Mon Sep 17 00:00:00 2001 From: Nicholas Clegg Date: Wed, 4 Feb 2026 12:34:03 -0500 Subject: [PATCH 2/2] Update test context length due to limit increase in openai --- tests_integ/models/test_model_openai.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests_integ/models/test_model_openai.py b/tests_integ/models/test_model_openai.py index 742c70899..d31ef3333 100644 --- a/tests_integ/models/test_model_openai.py +++ b/tests_integ/models/test_model_openai.py @@ -210,7 +210,7 @@ def test_rate_limit_throttling_integration_no_retries(model): # Create a message that's very long to trigger token-per-minute rate limits # This should be large enough to exceed TPM limits immediately - very_long_text = "Really long text " * 20000 + very_long_text = "Really long text " * 600000 # This should raise ModelThrottledException without retries with pytest.raises(ModelThrottledException) as exc_info: @@ -218,7 +218,7 @@ def test_rate_limit_throttling_integration_no_retries(model): # Verify it's a rate limit error error_message = str(exc_info.value).lower() - assert "insufficient_quota" in error_message + assert "rate_limit_exceeded" in error_message def test_content_blocks_handling(model):