27
27
T = TypeVar ('T' )
28
28
29
29
30
- def build_run_context (deps : T ) -> RunContext [T ]:
30
+ def build_run_context (deps : T , run_step : int = 0 ) -> RunContext [T ]:
31
31
return RunContext (
32
32
deps = deps ,
33
33
model = TestModel (),
34
34
usage = Usage (),
35
35
prompt = None ,
36
36
messages = [],
37
- run_step = 0 ,
37
+ run_step = run_step ,
38
38
)
39
39
40
40
@@ -542,7 +542,7 @@ def other_tool(x: int) -> int:
542
542
assert call_count ['other_tool' ] == 1
543
543
544
544
# Test for_run_step - should create new tool manager with updated retry counts
545
- new_context = build_run_context (TestDeps ())
545
+ new_context = build_run_context (TestDeps (), run_step = 1 )
546
546
new_tool_manager = await tool_manager .for_run_step (new_context )
547
547
548
548
# The new tool manager should have retry count for the failed tool
@@ -565,7 +565,7 @@ def other_tool(x: int) -> int:
565
565
assert call_count ['failing_tool' ] == 4
566
566
567
567
# Create another run step
568
- another_context = build_run_context (TestDeps ())
568
+ another_context = build_run_context (TestDeps (), run_step = 2 )
569
569
another_tool_manager = await new_tool_manager .for_run_step (another_context )
570
570
571
571
# Should now have retry count of 2 for failing_tool
@@ -621,7 +621,7 @@ def tool_c(x: int) -> int:
621
621
assert tool_manager .failed_tools == {'tool_a' , 'tool_b' } # unchanged
622
622
623
623
# Create next run step - should have retry counts for both failed tools
624
- new_context = build_run_context (TestDeps ())
624
+ new_context = build_run_context (TestDeps (), run_step = 1 )
625
625
new_tool_manager = await tool_manager .for_run_step (new_context )
626
626
627
627
assert new_tool_manager .ctx .retries == {'tool_a' : 1 , 'tool_b' : 1 }
0 commit comments