Cap total LLM calls
from splinter import Splinter s = Splinter( openai_key="sk-...", max_steps=20, # Stop at 20 LLM calls ) result = await s.run("helper", "Do something") print(f"Steps used: {s.steps}")
from splinter import Gateway, ExecutionLimits gateway = Gateway(limits=ExecutionLimits( max_steps=100, # 100 calls max )) # Check current steps metrics = gateway.get_metrics() print(f"Total steps: {metrics['total_steps']}")
from splinter import ExecutionLimits limits = ExecutionLimits( max_steps=100, # Workflow max per_agent_max_steps=20, # Each agent max )
from splinter.exceptions import StepLimitExceededError try: result = await workflow.run() except StepLimitExceededError as e: print(f"Step limit exceeded: {e.current} >= {e.limit}")