manage-token-budget
Manage Token Budget
Control the cost and context footprint of agentic systems by tracking token usage per cycle, auditing what consumes context space, enforcing budget caps, pruning low-value context under pressure, and routing through metadata before loading full procedures. The core principle: every token in the context window should earn its place. Tokens that inform decisions stay; tokens that occupy space without influencing output get pruned.
Community evidence: a 37-hour autonomous session cost $13.74 from a 30-minute heartbeat interval combined with verbose system instructions and unchecked context accumulation. The fix was rewriting the heartbeat to 4-hour intervals, switching to notification-only mode, and eliminating feed browsing from the loop. This skill codifies the patterns that prevent such incidents.
When to Use
- Running long-lived agent loops (heartbeats, polling cycles, autonomous workflows) where costs compound over time
- Context windows are growing unpredictably between execution cycles
- API costs have spiked beyond expected baselines and a post-mortem is needed
- Designing a new agentic workflow and want cost guardrails built in from the start
- After a cost incident to audit what went wrong and prevent recurrence
- When system prompts, memory files, or tool schemas have grown large enough to dominate the context window
Inputs
- Required: The agentic system or workflow to budget (running or planned)
- Required: Budget ceiling (dollar amount per period, or token limit per cycle)