AI & Agents

How to Track and Manage Token Usage in OpenClaw

Most OpenClaw users discover that the bulk of their token spend comes from context accumulation and background processes, not the prompts they actually type. OpenClaw ships with built-in monitoring commands and tunable configuration limits that can cut costs by 50 to 80% without changing how you work. This guide walks through the full monitoring-to-optimization workflow with concrete configuration values.

Fastio Editorial Team 11 min read
AI audit and monitoring interface showing usage metrics

Where Your Tokens Actually Go

One developer traced every API call across a week of OpenClaw sessions and found that 90% of the total spend had nothing to do with the work they actually requested. The real costs came from context accumulation, background heartbeats, and tool outputs that inflated token counts silently on every turn.

This pattern is not unusual. OpenClaw conversations accumulate context because each model call resends the entire conversation history. By the tenth turn, you are paying to reprocess everything from turns one through nine. Actual token consumption grows closer to a quadratic curve than a linear one, which explains why daily costs routinely run 5 to 10 times higher than back-of-envelope estimates.

Breaking down a typical session's token spend reveals consistent patterns:

  • Context accumulation accounts for 40 to 50% of total spend. Every message, tool result, and system prompt fragment gets resent with each new model call.
  • Tool output storage adds 20 to 30%. When an agent reads a file or runs a command, the full result enters the context window and stays there for the rest of the session.
  • System prompt overhead contributes 10 to 15%. OpenClaw injects tool definitions, skill metadata, bootstrap files, and provider-specific headers into every request.
  • Multi-round reasoning chains consume 10 to 15% when thinking mode is enabled, generating internal reasoning tokens that count toward your bill but never appear in the response.

The practical impact varies by usage intensity. Light users running around 10 queries per day typically spend $5 to $30 monthly with optimization, but $100 or more on default settings. Heavy users have reported bills exceeding $5,000 in a single month. The gap between optimized and default configuration is where the savings live, and most of it comes down to visibility. You cannot fix what you do not measure.

How to Monitor Token Usage with Built-in Commands

OpenClaw ships with three command families for tracking token consumption in real time. No plugins, no external dashboards. These work in any session.

/status

Displays your current session model, context window usage as a percentage, input and output tokens from the last response, and estimated cost. This is the fast health check available. Run it at the start of a session to establish a baseline and periodically during long tasks to catch unexpected spikes before they compound.

/usage modes

Controls a persistent per-response footer that tracks consumption as you work:

  • /usage tokens shows input and output token counts after every response
  • /usage full adds both token counts and estimated dollar cost
  • /usage off disables the footer entirely
  • /usage cost prints a cumulative cost summary from your local session logs

Once enabled, the footer persists for the entire session. For ongoing cost awareness without visual clutter, /usage tokens is the practical default for most developers. Switch to /usage full when you are actively debugging a cost spike.

/context views

  • /context list gives a quick breakdown of what is consuming your context window right now
  • /context detail shows the full picture with token counts per file, per tool, per skill, and for the system prompt itself

/context detail is the diagnostic tool you reach for when costs spike unexpectedly. It tells you exactly which files or tools are eating your context budget, so you can target specific reductions instead of guessing. If a single tool result is consuming 30% of your window, you know where to start.

Authentication affects cost visibility

Your authentication method determines whether dollar estimates appear in monitoring output. Token counts are always visible, but cost calculations depend on having access to your provider's pricing data. Check the token use documentation for details on how cost estimation pulls from your model pricing configuration.

Audit log showing detailed token consumption breakdown

How to Reduce Context and Bootstrap Overhead

Every OpenClaw session starts by loading project context: skill descriptions, tool definitions, and bootstrap files all enter the context window before you type anything. This startup payload gets resent on every model call, so its size directly affects your per-turn cost for the entire session.

OpenClaw provides configurable limits to control how much context gets loaded and how it grows. The default bootstrap caps are 12,000 characters per file and 60,000 characters total across all bootstrap files. If your project loads 20 files at startup, that is roughly 15,000 tokens prepended to every single model call. Lowering these caps or excluding irrelevant files makes a measurable per-turn difference that compounds across a session.

Runtime limits control how context grows during active work, capping things like tool output size and memory retrieval payloads so a single large file read does not flood the window. OpenClaw also supports per-agent context limits, so you can assign different budgets to different workflow roles. A research agent might need generous limits to ingest long documents, while a formatting agent can run leaner. See the context limits reference for available settings.

For image-heavy sessions, vision tokens scale with resolution. Reducing the maximum image dimension for screenshot-heavy debugging workflows cuts vision costs without losing useful detail for most tasks.

Using /compact between tasks

The /compact command summarizes your conversation history into a condensed form. This is the single most impactful mid-session action for reducing accumulated context. Run it between distinct tasks or whenever /context list shows your window filling up. The trade-off is that earlier conversation detail becomes a summary rather than verbatim history, so run it at natural task boundaries rather than mid-analysis.

Excluding files from context loading

Configuring your project to skip irrelevant files prevents OpenClaw from auto-loading build artifacts, dependency directories, and lock files into the bootstrap context. The savings are proportional to project size, typically thousands of tokens per session that compound across dozens of model calls.

Fastio features

Stop paying to regenerate lost agent outputs

Fastio gives OpenClaw agents 50GB of persistent storage, free. Save outputs once, retrieve them across sessions through the MCP server. No credit card, no trial expiration.

Model Routing and Cache Strategy

Your default model determines baseline cost per token. Choosing different models for different task types is the fast path to lower bills without sacrificing quality where it matters.

How the major models compare for OpenClaw usage

  • Gemini 2.5 Flash-Lite: $0.10 input, $0.40 output per million tokens. Best for background heartbeats and keep-alive pings. Not reliable enough for complex tool-calling workflows.
  • Claude Haiku 4.5: $1 input, $5 output per million tokens. Reliable for sub-agent tasks, simple lookups, and routine file operations where speed matters more than deep reasoning.
  • Claude Sonnet 4.6: $3 input, $15 output per million tokens. The general-purpose workhorse for multi-step coding, analysis, and tool use at a third of Opus pricing.
  • Claude Opus 4.5: $5 input, $25 output per million tokens. Reserved for tasks requiring the strongest reasoning. Expensive for anything routine.

Switching models mid-session lets you match cost to complexity. Start a debugging session on Sonnet, then drop to Haiku for repetitive file operations. No context is lost during the switch, so you can move between tiers freely within a single conversation.

Heartbeat isolation

Heartbeats keep your prompt cache warm by pinging the model at regular intervals, typically every 55 minutes for providers with a one-hour cache TTL. By default, heartbeats use your active model, which can mean burning around 100,000 tokens at premium rates on background pings that do no useful work.

Routing heartbeats to a cheap model and isolating them reduces per-heartbeat cost from roughly 100,000 tokens at Opus rates to 2,000 to 5,000 tokens at Flash-Lite pricing. This is one of the highest-ROI changes available because it runs continuously in the background.

Prompt cache behavior

Anthropic's prompt caching means repeated context (system prompts, long conversation history) costs less on cache reads than on fresh input. Cache writes cost more than standard input, but subsequent cache reads compound the savings across every turn in the session. OpenClaw's heartbeat system exists specifically to keep that cache warm within the TTL window.

The practical implication: keeping sessions focused matters. Clearing history between unrelated tasks resets the cache but also resets accumulated context, which usually yields net savings. Short, targeted sessions with cache-warm heartbeats cost less than marathon conversations where context grows unchecked.

What tiered routing achieves

  • Sonnet primary with Haiku for sub-agents: 50 to 65% cost reduction
  • Three-tier routing adding Flash-Lite heartbeats: 70 to 80% reduction
  • Full optimization stack (routing plus context pruning plus cache management): 80 to 90% reduction

One documented case study showed daily spend dropping from $47 to single digits after applying all three tiers. The largest single gain came from heartbeat isolation, followed by model selection for sub-agents.

Persisting Agent Outputs to Avoid Regeneration

Token optimization only pays off if the outputs survive the session. Every report, analysis, or generated file costs tokens to produce. Losing those outputs between sessions means paying to regenerate them from scratch, which is the most wasteful form of token spend.

Local file systems work for solo development but break down when agents hand work to humans or coordinate with other agents. S3 requires infrastructure setup and IAM configuration. Google Drive and Dropbox lack the indexing and permission granularity that agent workflows need for structured handoffs.

Fastio provides persistent workspaces purpose-built for this problem. The Business Trial includes 50GB of storage, included credits, and 5 workspaces with no credit card or trial expiration. For OpenClaw users, the practical workflow looks like this:

  • Agent produces a report or analysis during a session
  • Output is saved to a Fastio workspace through the MCP server
  • Files are automatically indexed for semantic search when Intelligence Mode is enabled
  • Humans access the same workspace through the web UI with full audit trails
  • Future sessions retrieve prior outputs instead of regenerating them

Retrieval costs tokens too, but far fewer than re-running the analysis that created the output. For teams running multiple agents, the audit trail provides a file-level record of what each agent produced and when, complementing OpenClaw's session-level logs with a persistent workspace view.

Fastio exposes Streamable HTTP at /mcp and legacy SSE at /sse for agent access. The platform supports file locks for multi-agent coordination, webhooks for reactive workflows, and ownership transfer that lets an agent build a workspace and hand it to a human client. See the MCP skill documentation for the full tool surface, or start with the agent onboarding guide for a quick setup path.

For teams already tracking OpenClaw costs, adding persistent storage closes the loop: you optimize token spend inside OpenClaw, and you preserve every output outside it so those tokens are never wasted twice.

Frequently Asked Questions

How do I check token usage in OpenClaw?

Run `/status` for a quick snapshot of your session model, context usage, and last-response cost. Enable `/usage tokens` for a persistent footer showing input and output counts after every response, or `/usage full` to include dollar estimates alongside the counts. For a detailed breakdown of what is consuming your context window, use `/context detail`, which shows per-file, per-tool, and per-skill token counts.

How much does OpenClaw cost per token?

OpenClaw itself does not charge per token. Costs come from the underlying model provider. Claude Haiku 4.5 runs $1 per million input tokens and $5 per million output tokens. Sonnet 4.6 is $3/$15. Opus 4.5 is $5/$25. Gemini Flash-Lite is $0.10/$0.40. You configure pricing in your model settings using USD per million tokens for input, output, cache reads, and cache writes.

How do I reduce token usage in OpenClaw?

Start by running `/context detail` to identify the largest context consumers. Lower the bootstrap character limits if your project loads many files at startup. Use `/compact` between distinct tasks to summarize accumulated history. Route heartbeats to a cheap model like Gemini Flash-Lite. Switch to Haiku for routine sub-agent work. Exclude build artifacts and lock files from auto-loading. These changes combined typically reduce monthly costs by 50 to 80%.

Does OpenClaw have token limits?

OpenClaw does not impose a hard token cap separate from the underlying model's context window. It provides configurable limits that act as practical ceilings, with defaults of 12,000 characters per file and 60,000 characters total for bootstrap context. Runtime limits cap tool output size and post-compaction context. You can override these per-agent, so different workflow roles operate within different budgets. See the official token use documentation for the full list of available settings.

What is the difference between /usage tokens and /usage full?

`/usage tokens` shows input and output token counts after each response. `/usage full` adds estimated dollar cost alongside the counts. Cost estimates depend on having pricing data available from your model configuration. If cost figures do not appear, check that your setup includes the per-model pricing rates described in the token use documentation.

Related Resources

Fastio features

Stop paying to regenerate lost agent outputs

Fastio gives OpenClaw agents 50GB of persistent storage, free. Save outputs once, retrieve them across sessions through the MCP server. No credit card, no trial expiration.