We earn a reward if you sign up to SayGM through our links. Your price is the same.
LessPerToken

Blog › Token saving, part 5

We audited nanobot: Claude on Bedrock is never cached, and the default is a legacy Opus

nanobot caches Claude prompts carefully on the Anthropic API and OpenRouter, more carefully than most agents we've read. On AWS Bedrock it never asks for caching at all, so every step of every task pays full price for the system prompt, the tools and the whole conversation. Its default model is also a legacy Opus that costs more than the current one.

Part 5 of a series on spending less per token. Part 4 audited mem0, part 3 browser-use, and part 1 explains caching if you're new to it.

The project and how we checked it

nanobot is a lightweight, self-hosted personal AI agent from HKUDS, the lab behind LightRAG, with about 46,000 stars on GitHub. It answers you on Telegram, WeChat, the web and other channels, runs tools in a loop, keeps long-term memory, and can wake itself up on a schedule. An agent like that sends the same large prefix to the model many times a day, so caching decides most of the bill.

We ran our free LLM cost audit skill on commit 02e04a6 (version 0.4.2, 1 December 2026 China time), then read every flagged file and every provider by hand. We didn't run nanobot; the numbers below are estimates, and we say what they rest on.

What it already does well

  • Four cache breakpoints on every Claude request through the Anthropic API or OpenRouter: the end of the system prompt, the boundary between built-in and MCP tools, the last tool, and the previous message. That's the most Anthropic allows, and it covers both the fixed prefix and the growing conversation.
  • Changing data stays out of the cached part. The time and other runtime details go into the newest user message, not the system prompt, so they don't break the cache.
  • MCP tools are loaded on demand. With MCP servers connected, the model sees a search tool instead of every MCP tool definition.
  • Background jobs only run when there's work. The heartbeat only fires when HEARTBEAT.md has tasks, and memory consolidation only runs when there's new history.
  • Sensible limits: 8,192 output tokens and tool results capped at 16,000 characters. Our scanner flagged some calls for having no output limit; that was wrong, because the limit comes from the shared config.

So the structure is right. The leaks are a missing route, a stale default and a missing setting.

1. Claude on Bedrock is never cached

Claude only caches when the request marks what to cache. On the Anthropic API that marker is cache_control; on Bedrock it's a cachePoint block. nanobot adds the first on its Anthropic and OpenRouter routes. Its Bedrock provider builds the system prompt, messages and tools without a single cachePoint. The only mention in the file keeps cache points that are already there; nothing ever adds one.

How you run Claude in nanobotPrompt cached?
Anthropic API (provider: anthropic)Yes
OpenRouterYes
AWS BedrockNo
A LiteLLM proxy or other gateway via customNo

In an agent that matters a lot. Each message you send can take several model calls as nanobot uses tools, up to 200 by default, and each call resends everything before it. Uncached, you pay the full input price for that prefix every time.

The fix (providers/bedrock_provider.py)

_CACHE_POINT = {"cachePoint": {"type": "default"}}

def _apply_cache_points(model_id, system, messages, tool_config):
    if "anthropic.claude" not in model_id:
        return system, messages, tool_config
    if system:
        system = [*system, _CACHE_POINT]
    if tool_config and tool_config.get("tools"):
        tool_config = {**tool_config, "tools": [*tool_config["tools"], _CACHE_POINT]}
    if len(messages) >= 3:
        prev = messages[-2]
        messages = [*messages[:-2],
                    {**prev, "content": [*prev["content"], _CACHE_POINT]},
                    messages[-1]]
    return system, messages, tool_config

It mirrors what nanobot already does for the Anthropic API, and nanobot already reads Bedrock's cache counters, so hits would show up in its usage log straight away. We opened issue #6849 with this fix.

2. The default model is a legacy Opus

If you don't choose a model, nanobot uses Claude Opus 4.5, and its docs use Opus 4.5 in their examples. Anthropic now lists Opus 4.5 as a legacy model at $5 input and $25 output per million tokens, with cache reads at $0.50. Opus 5.5 is $4 and $20, with cache reads at $0.20. Sonnet 5.5 is $2 and $10.

Pick the model in your nanobot config

{ "agents": { "defaults": { "model": "claude-sonnet-5-5", "provider": "anthropic" } } }

Use Opus 5.5 if you want to stay on the top model; it's cheaper than 4.5 at every rate. Sonnet 5.5 is enough for many personal-assistant tasks, but test it on your own work first.

3. Background jobs run on the main model

nanobot does useful work while you're away, and all of it uses your main model unless you say otherwise:

  • Dream consolidates memory every 2 hours when there's new history.
  • Idle compaction summarises any conversation that's been quiet for 15 minutes.
  • Heartbeat runs your HEARTBEAT.md tasks every 30 minutes, then makes a second call to decide whether to message you.

Summarising and a yes-or-no "should I notify?" don't need Opus. Dream already has a setting for its own model; it's just off by default:

Run Dream on a cheaper model

{ "modelPresets": { "background": { "provider": "anthropic", "model": "claude-sonnet-5-5" } },
  "agents": { "defaults": { "dream": { "modelOverride": "background" } } } }

Idle compaction and the notify check would need a small code change to use the same preset. We can't put a dollar figure on this one without real usage, since it depends on how much you chat and how many heartbeat tasks you have.

What it's worth

Our estimate for one active user, at list prices:

SetupPer month
Bedrock, Sonnet 4.5 (the docs' example), no cache$121 to $365
Bedrock, Sonnet 4.5, with the fix$41 to $122 −67%
Anthropic API, default Opus 4.5 (cached)$68 to $203
Anthropic API, Opus 5.5 (cached)$48 to $144 −29%
Anthropic API, Sonnet 5.5 (cached)$24 to $72 −64%

How we got these numbers: 10 to 30 messages a day, about 5 model calls per message, about 25,000 input tokens per call (system prompt, tools and history) and 400 output tokens, so 37.5M to 112.5M input and 0.6M to 1.8M output tokens a month. Cached rows assume 80% of input is read from cache and bill the rest at the normal input price; cache writes cost a little more, so real cached figures run slightly higher. List prices: Sonnet 4.5 $3 input, $0.30 cached, $15 output per million; Opus 4.5 $5, $0.50, $25; Opus 5.5 $4, $0.20, $20; Sonnet 5.5 $2, $0.10, $10. Bedrock regional endpoints can cost about 10% more. nanobot logs input and cache tokens per call, so you can swap in your own numbers.

Where the tokens are bought

Caching and the model choice are the big levers here; the price per token is the third. SayGM lists Claude Opus 5.5 at $2.06 input and $10.30 output per million tokens, and Sonnet 5.5 at $1.03 and $5.15, against $4.00 / $20.00 and $2.00 / $10.00 from Anthropic. nanobot's Anthropic provider accepts an apiBase, so pointing it at SayGM's Anthropic-compatible endpoint keeps caching switched on. The usual caveat applies: on Claude, Anthropic still processes the prompt whichever gateway you use, so keep secrets and client data on direct routes.

Disclosure: we earn a reward if you sign up to SayGM through our links. Your price is the same.

Summary

#FindingFixEffort
1Claude on Bedrock is never cachedAdd cachePoint blocks for Claude models (#6849)~25 lines
2Default model is legacy Opus 4.5Set model to Opus 5.5 or Sonnet 5.5One line
3Dream, idle compaction and the notify check run on the main modelSet dream.modelOverride; a shared background preset for the restSmall
4Claude through a LiteLLM proxy or other custom gateway isn't cachedA per-provider caching switchSmall

Check your own agent for the same thing

  • List every route your app can reach Claude by, not just the one in the README. Each needs its own cache marker.
  • Check cache_read_input_tokens (or cacheReadInputTokens on Bedrock). Zero in an agent loop means every step pays full price.
  • Check which model runs your background jobs.

Or let an agent do it: the LLM cost audit skill is free and runs locally.

Sources: nanobot on GitHub (commit 02e04a6), nanobot issue #6849, Anthropic prompt caching docs, Anthropic pricing, SayGM prices. We didn't run nanobot; token counts are estimates.

Cache the prompt, then pay less for what's left

One URL change. Keep OpenRouter as your backup.

Try SayGM