Directo a los números

← Todos los artículos

Coding Agent Memory Files: Show Me the Receipt

A memory file looks free: a few project rules, a test command, perhaps yesterday’s debugging lesson. But the useful question is not how many bytes it occupies. It is how much you pay to keep presenting those instructions, maintain them, and correct mistakes they cause—or prevent. Let’s price that decision like a receipt.

01 / The Item You Are Actually Buying: Repeated Context

Claude Code loads project instructions from CLAUDE.md into context, while Codex recognizes AGENTS.md as persistent repository guidance. These files supply instructions; they are not model training or a guarantee of compliance. Their loading rules differ, so inspect your actual client rather than assuming every Markdown file is always included. ([code.claude.com](https://code.claude.com/docs/en/memory))

Anthropic explicitly treats memory instructions as context rather than enforced configuration. For a rule such as “never deploy without approval,” keep an independent permission boundary instead of trusting a sentence in a file. ([code.claude.com](https://code.claude.com/docs/en/memory))

02 / Receipt One: A 2,000-Token File Across 100 Sessions

Here is an illustrative budget, not a benchmark or a CheapRelay price quote. Assume a 2,000-token memory file remains present in 20 API requests per session, across 100 sessions. Use hypothetical rates of $2 per million ordinary input tokens, $2.50 per million cache-write tokens, $0.20 per million cache-read tokens, and $8 per million output tokens.

  • ■ Memory presented: 2,000 × 20 × 100 = 4,000,000 tokens.
  • ■ Without caching: 4,000,000 ÷ 1,000,000 × $2 = $8.00.
  • ■ With one cache write per session: 200,000 tokens × $2.50 per million = $0.50.
  • ■ Remaining cached reads: 3,800,000 tokens × $0.20 per million = $0.76.
  • ■ Cached memory subtotal: $1.26.

This isolates the memory file’s marginal input cost. Task prompts, source files, tool results, and generated answers are excluded. It also assumes every designated cache read actually hits; it does not charge the same tokens as both ordinary input and cached input.

03 / The Cache Discount Has Conditions

Prompt caching reuses matching prompt prefixes. Anthropic documents cache lifetimes and minimum cacheable prompt lengths; changing earlier content or missing the applicable lifetime can prevent the expected reuse. A short memory file alone does not guarantee eligibility. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching))

Therefore, “loaded once” does not mean “billed once.” Check reported usage categories rather than multiplying file size by chat messages and declaring victory. Anthropic distinguishes ordinary input, cache creation, and cache reads in its caching documentation. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching))

04 / Receipt Two: Trim the File to 800 Tokens

Keep the same hypothetical workload and rates, but remove duplicated documentation and temporary notes. At 800 tokens, the uncached bill becomes $3.20. Under the same successful-cache assumptions, writes cost $0.20 and reads cost $0.304: $0.504 total. That saves approximately $0.76 against the larger cached file, or $4.80 without caching.

Now add maintenance. Suppose one cleanup consumes 20,000 ordinary input tokens and generates 5,000 output tokens: $0.04 + $0.04 = $0.08. Ten minutes of your time at an assumed $60 hourly opportunity cost adds $10. Neither is a measured average. The point is that editing time can dwarf token savings.

05 / The Break-Even Test: Does Memory Prevent Rework?

Suppose an avoidable extra agent pass uses 12,000 ordinary input tokens and 2,000 output tokens. At our illustrative rates, that costs $0.04. The larger file’s $1.26 cached subtotal breaks even if it prevents 32 such passes across 100 sessions. Human review time is excluded.

My editing rule: retain exact test commands, non-obvious architectural constraints, and recurring corrections. Move task diaries elsewhere. Test lean and expanded versions on comparable work, recording total spend, successful completion, retries, and review minutes—not just memory size.

06 / Keep the Receipt Beside Your Relay Bill

CheapRelay’s pay-as-you-go setup bills real tokens, including cache reads and writes, without a monthly fee or subscription. That makes the categories in this receipt relevant; substitute the actual rates for your chosen route rather than treating these examples as advertised pricing.

Sign up for CheapRelay to track your own agent workload against this budget. Keep memory when it prevents more expense than it creates. Delete the rest—not because shorter is automatically smarter, but because every permanent instruction should earn its place.

Registrarse Prueba los precios. Incluye crédito de registro.

Más lecturas

FechaPasilloIdiomaTítulo
2026-10-25Agentes de código baratosENCoding Assistant Habits That Double Your Bill
A receipt-style breakdown shows how oversized prompts and verbose answers turn a $0.60 coding session into $1.20, before retries.
2026-10-25Agentes de código baratosENThree AI CLIs, One Desktop, a $30 Budget
A receipt-style plan for running Claude Code, Codex and Gemini CLI together, with a $30 usage budget and no invented token prices.
2026-10-25Agentes de código baratosENCoding Agents in CI: A $0.50 Pipeline Budget
Build a receipt for every coding-agent run, reserve spend before requests, and stop retries before they turn a small fix into a large bill.
2026-10-25Agentes de código baratosENClaude Code on Windows: A PowerShell Cost Receipt
Configure Claude Code with PowerShell environment variables, then audit a four-line token receipt without confusing example rates with real prices.
2026-10-25Agentes de código baratosENGemini CLI vs Claude Code: The Shell Chore Receipt
A concrete token-cost comparison for shell chores, with itemized receipts, retry math, cache caveats, and practical spending controls.
2026-10-25Agentes de código baratosENCheap First, Escalate Later: A Coding Cost Receipt
A worked token receipt shows how cheaper-first pair programming can cut API spending, with clear rules for escalating without wasting developer time.