Quick Wins
1. Terminate Sessions Explicitly
SetterminateOnCompletion: true on your final task, or call terminate explicitly. This alone reduces costs by 50% if you’re currently letting sessions timeout.
2. Write Concise Task Descriptions
Shorter descriptions = fewer input tokens. Be specific, not verbose. ❌ Verbose (150 tokens):3. Set startingPoint When Known
Skip navigation by providing the starting URL directly.
Additional Optimizations
Set Appropriate maxDuration
Limit task duration to prevent runaway costs:
- Simple searches: 30,000ms (30s)
- Form filling: 60,000ms (1 min)
- Multi-step workflows: 120,000ms (2 min)
Batch Related Tasks in Single Sessions
Reuse sessions for related tasks instead of creating new ones. ❌ Expensive:Limit Token Usage
For simple tasks, reduce token limits:Use avoidDomains to Prevent Detours
Block unnecessary domains to prevent wasted navigation:
Monitoring Costs
Real-time: Checkusage.cost in every API response.
usage object updates in real-time as tasks execute.
Cost Optimization Checklist
- Use
/start/run-taskfor single tasks (auto-terminates) - Set
terminateOnCompletion: trueon final tasks in multi-task workflows - Write concise, specific task descriptions
- Provide
startingPointwhen the starting point is known - Set appropriate
maxDurationbased on task complexity - Batch related tasks into single sessions
- Limit
maxInputTokensandmaxOutputTokensfor simple tasks - Use
avoidDomainsto prevent accidental navigation - Monitor
usage.costin responses to track spending