Cost-aware workflow
Estimate, optimize context, and cap spend before agent execution.
Cost-aware workflow
This page operationalizes spec-doc §11.4: every flag and configuration key referenced here exists in AgentFlow builds. The sections walk through estimating spend, tightening context packs, enforcing budgets, and preferring local execution when routing policy allows—each step spelled out below with verbatim commands instead of abbreviated prose.
1. Per-task estimate
agentflow estimate billing-v2 --task task-003 --dry-runShows heuristic input/output tokens and estimated cost from your pricing sheet.
2. Context optimization
agentflow context billing-v2 --task task-003 --optimizeBuilds a reduced context pack before large agent prompts. Disable reduction with agentflow work ... --no-context-reduction.
3. Run with budget
agentflow work "develop billing-v2" --budget 0.50 --estimate-only
agentflow work "develop billing-v2" --budget 0.50Config budgets (budgets.per_run.max_estimated_cost) apply when CLI --budget is zero. Over-budget runs block unless:
- confirmation prompt accepted, or
--yesafterBudgetPendingConfirmError, or--allow-over-budgetwhenbudgets.policies.allow_override_with_flagis true
4. Local preference
agentflow work "develop billing-v2" --prefer-local --no-cloud--allow-cloud explicitly permits cloud routing when policies would otherwise restrict.
Explainability
work and estimate print step summaries (routing choice, context bytes, budget checks). See Token estimation.