How to reduce LLM token usage: 5 sources of redundant tokens

Cut LLM token usage by fixing five sources of redundant spend: prompt cache misses, regenerated answers, re-fetched context, stale context, and retries.

an AI token on the left with fainter tokens extending to the right

How to reduce LLM token usage: 5 sources of redundant tokens

Cut LLM token usage by fixing five sources of redundant spend: prompt cache misses, regenerated answers, re-fetched context, stale context, and retries.

an AI token on the left with fainter tokens extending to the right
Chapters

Why LLMs and AI agents use more tokens than they need

Beyond the model you choose and its token prices, the way your AI application handles prompts, context, answers, and retries can leave you paying for the same work more than once.

Fortunately, much of this redundant spend can be avoided with a few practical changes. In this article, we’ll cover five common sources of redundant LLM tokens and how to address them, so you can reduce waste to get more out of your AI tools.

Source of redundant tokens What’s happening First fix
Prompt cache misses Repeated instructions, tools, and history get reprocessed at full price Enable caching, keep stable content first, and verify cache reads in usage data
Regenerated answers The same question gets a freshly generated answer each time Cache responses for stable, shared questions (exact-match first, then semantic)
Re-fetched context Agents reread files and rerun searches they’ve already done Use precise tools, scope tasks tightly, and maintain a project briefing file
Stale context Old tool output rides along in every later request Trim large outputs at the source and clear or compact at natural breakpoints
Retried requests and re-run pipelines Timeouts, retry loops, and full reruns repeat completed work Coordinate retries with request IDs and save stage outputs for reuse
Five common sources of redundant token consumption and how to address them to reduce LLM costs

Prompt cache misses

Prompt caching stores previously processed input so it can be reused on later requests at a lower cost.

AI applications resend system instructions, tool definitions, and conversation history with every request. Without caching, the model reprocesses (and re-bills) those identical tokens each time. With caching enabled, a support bot using a 4,000-token system prompt reuses the cached instructions and only processes the user’s new question.

Four common issues can block those savings: caching isn’t configured, changes to the prompt break the cache match, the cache expires or the workflow switches models, or a self-hosted request reaches an instance without the cached input.

Caching isn’t configured

If caching isn’t enabled or configured correctly, the model processes the same instructions and tool definitions again on each call.

Setup differs across providers:

  • OpenAI: Prompt caching is automatic for eligible requests. Check the minimum cacheable length for your model.
  • Anthropic: Enable automatic caching with cache_control, or place an explicit marker after the content you want cached.
  • Gemini: Implicit caching is automatic on supported models. Explicit caching is also available for supported models when you want to manage cached content directly.

Prompts must meet a minimum length to be cached, and that minimum depends on the model. If the content you want to reuse is too short, it won’t qualify.

To confirm caching is working, check the usage data in your API responses: cache_read_input_tokens on Anthropic, cached_tokens on OpenAI, or cached_content_token_count on Gemini. When you send repeated requests with the same eligible content, you should see cache reads after the initial request.

Also check that content written to the cache is actually read later. Some providers charge extra for cache writes—the initial storing of processed input—so repeatedly writing content that never gets reused can add to your bill.

Changes to the prompt break the cache match

Next, caching can be configured correctly and still get missed because the beginning of the prompt keeps changing.

The shared beginning of a prompt is called its prefix. The provider matches that prefix against previously cached input. If something changes, the content after that point can’t reuse the old cached prefix and must be processed again. The unchanged portion before the change can still be reused if it was cached.

Imagine a system prompt that opens with the current date and time. If the timestamp changes with every request, the instructions that follow it no longer match the cached prefix. Caching may be enabled, but the application keeps paying to process or write those instructions again.

To keep the shared prefix consistent:

  • Put stable content first. Keep shared instructions, tool definitions, and reference material ahead of content that changes from request to request.
  • Put dynamic values later. Add timestamps, request IDs, and user-specific details after the shared content. If the model needs the date, include it in a later message.
  • Keep structure consistent. Load tools in the same order and serialize JSON with consistent key order and formatting. Even a whitespace change can break a match.
  • Group non-urgent prompt edits. Editing shared instructions can prevent reuse of the cached content that follows them. Grouping changes avoids repeatedly rebuilding the cache.
  • Compare prompts if cache reads stay low. Put two consecutive prompts side by side and look for the first difference. That’s where to start investigating why the cached prefix isn’t being reused.

The cache expires or the workflow switches models

Even when a prompt stays the same, the next request may not be able to reuse its cached input. The cache may expire during a pause, or the workflow may switch to a different model.

Expiry. Providers keep cached prompts for a limited time, known as the time-to-live (TTL). Anthropic’s default is five minutes. If a developer steps away or an agent waits on a long-running test, the cache can expire before the next request. The provider then has to process and write that input again.

If long pauses regularly interrupt a workflow, consider a longer TTL. Anthropic offers a one-hour option that costs more to write but can save money when cached content is reused across longer gaps. Compare the extra write cost with what you’re spending to rebuild the cache.

Model switching. When a session moves to a different model, the new model can’t use the previous model’s cached state. It has to process the context it receives. Routing a step to a cheaper model can still save money, but the lower token price may be offset by the cost of processing a long conversation again.

To reduce unnecessary reprocessing:

  • Switch models between tasks. Keep one model for the length of a task, then choose a different model when the next task starts.
  • Assign a model per session. Configure your router to send related requests to the same model when that fits the workflow.
  • Give subtasks only the context they need. If a cheaper model handles one step, send it the relevant files, instructions, or excerpt rather than the entire conversation.
  • Price the full task. Compare the expected cost of staying on the current model with the cost of switching, including reprocessing context, cache charges, input, output, and any additional calls needed to finish the work.

Self-hosted requests reach an instance without the cached input

When you self-host models, you may run several instances, each with its own cache. A standard load balancer can send a conversation’s first request to instance A and its next request to instance B. If instance B doesn’t have the cached prefix, it has to process that input again.

Hosted providers manage cache routing for you. When you self-host, your team may need to configure routing so requests reach the instance holding their cached prefix.

To improve reuse:

  • Enable prefix caching in your inference engine. Both vLLM and SGLang support it.
  • Route requests to their cache. A prefix-aware router directs requests to an instance holding the matching prefix. Sticky sessions offer a simpler way to keep a conversation on the same instance.
  • Track cache hit rates by instance. Low or uneven rates can help you identify routing or cache-capacity problems.

The benefit shows up as less repeated computation, faster processing, and potentially lower infrastructure costs.

Regenerated answers (response cache miss)

Response caching stores finished answers and returns them for matching requests without generating a new response. For comparison, prompt caching (described above) stores the processed input, while response caching stores the final output.

Normally, when users ask the same question repeatedly, an AI application generates a fresh answer from scratch—forcing you to pay for both the input and output tokens every time. Response caching eliminates that redundant work, making it ideal for high-repetition use cases like support bots, internal Q&A tools, and FAQ assistants.

Imagine one employee asks, “How do I reset my VPN password?” Then an hour later, another asks, “How can I reset my VPN password?” A response cache can return the first answer without generating it again.

There are two ways to make that match:

  • Exact-match caching returns a stored answer when the same request appears again.
  • Semantic caching looks for questions that mean the same thing, even when they use different words—as in the VPN example.

Semantic caching catches more repeat questions, but it also introduces a trade-off: two questions can sound similar while needing different answers. In an AWS benchmark, one semantic caching configuration reduced costs by 86%, with 91% accuracy for cached answers. The right balance depends on how much an incorrect answer matters in your application.

To add response caching to reduce token usage:

  • Choose questions with reusable answers. Start with stable, shared information, such as IT setup instructions or product FAQs. Avoid caching answers that depend on live data, individual circumstances, or actions the assistant needs to perform.
  • Start with exact-match caching. Store requests and their answers in a key-value store such as Redis. Include relevant context—such as the user’s organization, product, or region—so the same question doesn’t return an answer meant for someone else.
  • Add semantic caching for similar questions. Convert questions into embeddings—numeric representations of their meaning—and compare them with stored questions. If a new question is close enough to a cached one, return the stored answer. Redis, GPTCache, and some AI gateways offer tools for this.
  • Tune the similarity threshold on real questions. Too loose, and users get answers to different questions; too strict, and the cache rarely hits. Test with examples where you know which questions should and shouldn’t share an answer.
  • Expire answers when the source changes. Set time limits and clear affected answers when underlying information, such as a policy document, is updated.
  • Track savings and answer quality. Monitor cache hits, compare the cost of lookups and embeddings with the LLM calls avoided, and spot-check cached answers for accuracy.

Re-fetched context

Re-fetched context refers to when an AI agent retrieves and processes the same information multiple times (and this often coincides with pulling in far more data than the task actually requires).

Coding agents can spend a large share of their token budget exploring and re-reading a codebase. In a preliminary analysis of Mini SWE Agent using Claude Sonnet 4.5 on SWE-Bench Verified, researchers found that read-type operations, such as inspecting files and directories, accounted for 76.1% of total tokens consumed.

Every unnecessary read inflates the token count for the current request, and if those results remain in the conversation history, they compound the input carried into every subsequent turn. 

Re-fetching can happen within a session, across sessions, and across subagents.

Within a session. As a session grows, an agent may reread files it has already inspected. One reason is compaction: when the conversation is summarized to fit the context window, details from earlier reads may be left out. The agent then has to retrieve those details again.

Agents also need to re-check files when they may have changed. That’s useful verification. The waste comes from repeatedly reading unchanged material or loading a whole file when a smaller section would answer the question.

To reduce unnecessary reads:

  • Use precise tools. Code search, symbol lookup, and language-server tools can help the agent find a function or definition without loading an entire file.
  • Give the agent a focused starting point. When you know the relevant files or directories, include them in the task.
  • Scope tasks tightly. Breaking a large assignment into coherent tasks can keep sessions manageable and reduce the need to compact and rediscover context.

Across sessions. A new session may not have the working context from an earlier one. That means the agent can spend time rediscovering the repository layout, key files, and conventions.

To reduce that rediscovery:

  • Maintain a concise project briefing file, such as CLAUDE.md or AGENTS.md, with the repository structure, key files, conventions, and common commands. Point to detailed documentation where needed, and update the briefing as the codebase changes.
  • Carry forward task-specific findings. For work that spans sessions, leave a short handoff with what was completed, relevant files, and the next steps.

Across subagents. Subagents work with their own context. If several receive the same broad assignment, they may independently open the same files and run the same searches.

To limit overlap:

  • Give each subagent a distinct assignment. Split work by directory, module, or question so agents know what they own.
  • Pass along context you already have. Include relevant file paths and findings in each assignment. If several subagents need the same information, gather it once and share it.
  • Reserve parallel subagents for work that splits cleanly. For a small or tightly connected task, the coordination and duplicate context may outweigh the benefit of parallel work.

Across all three scopes, review agent transcripts for repeated reads and searches. If an agent keeps reopening an unchanged file or rediscovering the same repository details, investigate whether a clearer task, a project briefing, or a more targeted tool would help.

Stale context

Stale context is information that remains in an AI agent’s conversation history after it’s no longer useful or has become outdated. This can include tool outputs like file reads, command logs, and search results.

Unlike re-fetched context, where the agent repeatedly pulls the same information, stale context keeps getting carried into later requests after the agent has moved on. The presence of this context increases token usage.

For example, an agent runs a test suite that produces 20,000 tokens of logs, finds the failure, and fixes the bug. If those logs remain in the context for 30 more model calls, they contribute 600,000 additional input tokens—even though the agent no longer needs the full output.

Prompt caching can reduce the cost of those repeated tokens, but cached input still carries a charge. The logs also take up space in the context window and can make it harder for the model to focus on the information that matters.

To keep stale context from riding along:

  • Limit large outputs at the source. Configure tools to return the useful portion of a result—for example, failing tests and their surrounding error messages instead of every passing test. Save the full output to a file and give the agent the path so it can inspect more if needed.
  • Clear or summarize completed work. Some APIs and agent frameworks can remove old tool results or compact earlier conversation into a summary. Preserve details the agent still needs, such as decisions, changed files, and unresolved errors.
  • Clean up at useful breakpoints. Clearing or compacting history can reduce prompt-cache reuse because the conversation has changed. Remove a meaningful amount of obsolete context at a natural break, such as after completing a subtask, rather than repeatedly clearing small pieces.
  • Start a fresh session for a new task. A new session prevents unrelated logs and earlier work from following the agent into the next assignment. Carry forward a short handoff if the new task depends on previous findings.

Retried requests and re-run pipelines

Duplicate spend can also come from an application retrying a request, an agent repeating a failed tool call, or a pipeline rerunning work it has already completed.

Retried API requests. When an application times out, the provider may still be processing the original request. Send it again too quickly, and both attempts can run and incur charges. Multiple retry layers—or a user clicking “submit” twice—can create the same problem.

To reduce duplicate requests:

  • Set timeouts that fit the workload. For temporary errors, retry with increasing delays and a limit on attempts.
  • Coordinate retries across the SDK, application, and gateway. Otherwise, each layer can independently retry the same failure.
  • Track submissions with a request ID (idempotency key). Check whether the request is already in progress or completed before sending it again.

Repeated agent tool calls. An agent might try to read a nonexistent file, get an error, and then make the same call again. The loop wastes time and adds each failed attempt to the conversation.

Clear error messages help the agent understand what went wrong. Instruct it to change its approach after a persistent failure, and stop or flag repeated identical calls. Temporary errors can still warrant another try after a delay.

Re-run pipelines and evals. Say you change the classification prompt in a workflow that extracts, summarizes, and then classifies information. If you rerun the whole pipeline, you pay for extraction and summarization again, even though neither step changed.

Save stage outputs alongside their inputs and configuration so you can reuse them when they’re still valid. For evals, run the relevant tests while iterating and the full suite before release. Batch APIs can also lower the cost of full runs that don’t need immediate results.

Where to start with reducing LLM token usage

Redundant tokens build up across caching, answers, context, and retries. Start where your data points: check cache read rates in your API usage, review agent transcripts for repeated reads, and scan logs for retries and reruns. Fix the largest source first, then work down the list.

Faros shows where token spend goes across your tools, models, and workflows, so you can find redundant usage before it reaches your bill. Book a demo to learn more.

FAQs

Why isn’t prompt caching working?

The most common causes are caching not being enabled, content below the model’s minimum cacheable length, or a prompt prefix that changes between requests (such as a timestamp at the top). An expired cache or a switch to a different model can also force the input to be processed again.

How do I know if prompt caching is working?

Check the usage data in your API responses: cache_read_input_tokens on Anthropic, cached_tokens on OpenAI, or cached_content_token_count on Gemini. After the first request, repeated requests with the same eligible content should show cache reads.

Does switching models break prompt caching?

Yes. A new model can’t use the previous model’s cached state, so it has to process the full context again. To limit the cost, switch models between tasks and send cheaper models only the context they need.

How long does Anthropic’s prompt cache last?

The default time-to-live is five minutes. Anthropic also offers a one-hour option that costs more to write but can save money when cached content is reused across longer pauses.

What’s the difference between prompt caching and response caching?

Prompt caching stores processed input so later requests can reuse it at a lower price. Response caching stores finished answers and returns them for matching requests, skipping generation entirely.

Is semantic caching accurate enough for production?

It depends on how much a wrong answer costs. In an AWS benchmark, one configuration cut costs by 86% with 91% accuracy on cached answers. Start with stable, shared questions and tune the similarity threshold on real examples.

Why do AI coding agents reread the same files?

Compaction can drop details from earlier reads, new sessions lack prior context, and parallel subagents may explore the same files independently. Precise search tools, a project briefing file like CLAUDE.md, and distinct subagent assignments reduce repeat reads.

How do I prevent duplicate charges from LLM API retries?

Set timeouts that fit the workload, retry with increasing delays, and cap attempts. Coordinate retries across the SDK, application, and gateway, and track submissions with a request ID so the same request isn’t sent twice.

Neely Dunlap

Neely Dunlap

Neely Dunlap is a Content Marketing Manager at Faros who writes about AI and software engineering.

Graduation cap with a tassel over a dark gradient background.
AI ENGINEERING REPORT 2026
The Acceleration 
Whiplash
The definitive data on AI's engineering impact. What's working, what's breaking, and what leaders need to do next.
  • Engineering throughput is up
  • Bugs, incidents, and rework are rising faster
  • Two years of data from 22,000 developers across 4,000 teams
AI Industry
7
MIN READ

How to evaluate coding agents on your own codebase

Learn how to build a benchmark from your own engineering tasks, compare models and harnesses, and find the setup that fits your stack and standards.

AI Industry
10
MIN READ

Best AI gateways for enterprise software development

Compare 8 AI gateways for enterprise software teams, including Faros, Kong, and Cloudflare, plus five questions to help you choose one.

AI Industry
8
MIN READ

What is an AI gateway? Functions, limitations, and use cases

An AI gateway centralizes access, reliability, cost, and security controls for AI models. Learn how it works, when you need one, and what it can’t solve.