Skip to content

Commit c6c2681

Browse files
committed
new: allow to set --max-steps and --max-cost to 0 in order to disable those limits
1 parent f83c152 commit c6c2681

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

nerve/cli/run.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ def run(
5959
] = False,
6060
max_steps: t.Annotated[
6161
int,
62-
typer.Option("--max-steps", "-s", help="Maximum number of steps"),
62+
typer.Option("--max-steps", "-s", help="Maximum number of steps. Set to 0 to disable."),
6363
] = DEFAULT_MAX_STEPS,
6464
max_cost: t.Annotated[
6565
float,
6666
typer.Option(
67-
"--max-cost", help="If cost information is available, stop when the cost exceeds this value in USD."
67+
"--max-cost",
68+
help="If cost information is available, stop when the cost exceeds this value in USD. Set to 0 to disable.",
6869
),
6970
] = DEFAULT_MAX_COST,
7071
timeout: t.Annotated[

nerve/runtime/flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ def done(self) -> bool:
135135
if self.curr_actor_idx >= len(self.actors):
136136
return True
137137

138-
if self.max_steps is not None and self.curr_step > self.max_steps:
138+
if self.max_steps > 0 and self.curr_step > self.max_steps:
139139
state.on_max_steps_reached()
140140
return True
141141

142142
usage = state.get_usage()
143-
if self.max_cost is not None and usage.cost is not None and usage.cost > self.max_cost:
143+
if self.max_cost > 0 and usage.cost is not None and usage.cost > self.max_cost:
144144
state.on_max_cost_reached()
145145
return True
146146

nerve/runtime/logging.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,16 @@ def log_event_to_terminal(event: Event) -> None:
6868
data["flow"] = DictWrapper(data["flow"])
6969

7070
max_steps = data["flow"].max_steps
71+
steps = f"max steps: {max_steps}" if max_steps > 0 else "unlimited steps"
72+
7173
max_cost = data["flow"].max_cost
74+
cost = f"max cost: {max_cost:.2f}$" if max_cost > 0 else "no cost limit"
75+
7276
timeout = data["flow"].timeout
7377
timeout = f"{timeout}s timeout" if timeout else "no timeout"
78+
7479
conv_window_strategy = data["flow"].actors[0].conv_window_strategy
75-
logger.info(f"🚀 max steps: {max_steps} | max cost: {max_cost:.2f}$ | {timeout} | {conv_window_strategy}")
80+
logger.info(f"🚀 {steps} | {cost} | {timeout} | {conv_window_strategy}")
7681

7782
elif event.name == "agent_created":
7883
if isinstance(data["agent"], dict):

0 commit comments

Comments
 (0)