Skip to content

Commit b40a2cd

Browse files
committed
refactor: add usage limits in retry test
1 parent 6018ae1 commit b40a2cd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tests/test_usage_limits.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ async def regular_tool(x: str) -> str:
325325

326326

327327
async def test_failed_tool_calls_not_counted() -> None:
328-
"""Test that failed tool calls (raising ModelRetry) are not counted."""
328+
"""Test that failed tool calls (raising ModelRetry) are not counted in usage or against limits."""
329329
test_agent = Agent(TestModel())
330330

331331
call_count = 0
@@ -338,8 +338,7 @@ async def flaky_tool(x: str) -> str:
338338
raise ModelRetry('Temporary failure, please retry')
339339
return f'{x}-success'
340340

341-
result = await test_agent.run('test')
342-
# The tool was called twice (1 failure + 1 success), but only the successful call should be counted
341+
result = await test_agent.run('test', usage_limits=UsageLimits(tool_calls_limit=1))
343342
assert call_count == 2
344343
assert result.usage() == snapshot(RunUsage(requests=3, input_tokens=176, output_tokens=29, tool_calls=1))
345344

0 commit comments

Comments
 (0)