@@ -108,6 +108,8 @@ def __init__(
108
108
self .max_budget_per_task = max_budget_per_task
109
109
self .agent_to_llm_config = agent_to_llm_config if agent_to_llm_config else {}
110
110
self .agent_configs = agent_configs if agent_configs else {}
111
+ self ._initial_max_iterations = max_iterations
112
+ self ._initial_max_budget_per_task = max_budget_per_task
111
113
112
114
# stuck helper
113
115
self ._stuck_detector = StuckDetector (self .state )
@@ -245,6 +247,21 @@ async def set_agent_state_to(self, new_state: AgentState):
245
247
):
246
248
# user intends to interrupt traffic control and let the task resume temporarily
247
249
self .state .traffic_control_state = TrafficControlState .PAUSED
250
+ # User has chosen to deliberately continue - lets double the max iterations
251
+ if (
252
+ self .state .iteration is not None
253
+ and self .state .max_iterations is not None
254
+ and self ._initial_max_iterations is not None
255
+ ):
256
+ if self .state .iteration >= self .state .max_iterations :
257
+ self .state .max_iterations += self ._initial_max_iterations
258
+ if (
259
+ self .state .metrics .accumulated_cost is not None
260
+ and self .max_budget_per_task is not None
261
+ and self ._initial_max_budget_per_task is not None
262
+ ):
263
+ if self .state .metrics .accumulated_cost >= self .max_budget_per_task :
264
+ self .max_budget_per_task += self ._initial_max_budget_per_task
248
265
249
266
self .state .agent_state = new_state
250
267
if new_state == AgentState .STOPPED or new_state == AgentState .ERROR :
0 commit comments