Skip to content

Commit 9659c9b

Browse files
committed
Apply the same cleanup to another test
1 parent d9cffce commit 9659c9b

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

tests/contrib/openai_agents/test_openai.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,9 +1333,6 @@ async def test_customer_service_workflow(client: Client, use_local_model: bool):
13331333
)
13341334

13351335

1336-
guardrail_response_index: int = 0
1337-
1338-
13391336
class InputGuardrailModel(OpenAIResponsesModel):
13401337
__test__ = False
13411338
responses: list[ModelResponse] = [
@@ -1424,11 +1421,9 @@ def __init__(
14241421
model: str,
14251422
openai_client: AsyncOpenAI,
14261423
) -> None:
1427-
global response_index
1428-
response_index = 0
1429-
global guardrail_response_index
1430-
guardrail_response_index = 0
14311424
super().__init__(model, openai_client)
1425+
self._responses = iter(self.responses)
1426+
self._guardrail_responses = iter(self.guardrail_responses)
14321427

14331428
async def get_response(
14341429
self,
@@ -1446,15 +1441,9 @@ async def get_response(
14461441
system_instructions
14471442
== "Check if the user is asking you to do their math homework."
14481443
):
1449-
global guardrail_response_index
1450-
response = self.guardrail_responses[guardrail_response_index]
1451-
guardrail_response_index += 1
1452-
return response
1444+
return next(self._guardrail_responses)
14531445
else:
1454-
global response_index
1455-
response = self.responses[response_index]
1456-
response_index += 1
1457-
return response
1446+
return next(self._responses)
14581447

14591448

14601449
### 1. An agent-based guardrail that is triggered if the user is asking to do math homework

0 commit comments

Comments
 (0)