Customer Success

Public

How CoreStory Cuts LLM Costs by 70% While Improving Output Quality

AI agents charge per token, and large codebases generate enormous token bills through repeated context re-ingestion. CoreStory's Code Intelligence Model reduced Claude Code input tokens by 73%, cut costs by 67%, and improved output quality in a real customer evaluation.

TL;DR LLMs charge per token, and large codebases generate enormous token bills — especially when AI agents re-ingest the same context repeatedly. CoreStory transforms your codebase into a persistent Code Intelligence Model (CIM), giving AI agents structured, targeted context instead of raw code. In a real-world evaluation, Claude Code paired with CoreStory used 73% fewer input tokens, ran in half the time, and cost 67% less — while delivering better results. This post explains why that happens and how to replicate it. The Token Bill Nobody Talks About A 10-engineer team running Claude Code against a 500,000-token codebase can burn $15,000–$40,000 per month in context re-ingestion alone before writing a single line of net-new logic. That's not a projection. That's what happens when AI agents are given raw code instead of structured intelligence. Here's the math. Each developer session re-sends the same modules, schemas, and helper functions the model saw yesterday. A single prompt involving a non-trivial subsystem easily runs 20,000–50,000 input tokens. Multiply by 10 engineers, 20 working days, and 3–5 sessions per day, and you're looking at a substantial monthly token bill just for context, before accounting for the model's output. Output tokens compound the problem. Most AI providers charge 3–5x more for output tokens than input tokens. When the model lacks proper context, it produces longer, more hedged responses and requires more correction rounds. Each round re-ingests the context, generates more output, and adds to the bill. The real cost of poor context isn't just the tokens you send, it's the tokens you generate trying to fix the results. In a real customer evaluation: Claude Code + CoreStory MCP used 73% fewer input tokens, ran in half the time, and cost 67% less with better output quality. Table 1: Real-world cost comparison for adding a complex feature to a large enterprise codebase Metrics Claude Code Claude Code + CoreStory % Reduction Processing Time ~92 min ~47 min 50% faster Input Tokens ~1,320,000 ~357,500 73% less Output Tokens ~87,000 ~43,000 50% less Cost (USD) ~$5.29 ~$1.74 67% less Why LLMs Have a Context Problem With Large Codebases LLMs don't retain memory between sessions. Every interaction starts from zero. When a developer asks an AI agent to refactor a module, the model needs not just that file, it needs the schemas it depends on, the helper functions it calls, the data flow it participates in, and enough architectural context to avoid introducing regressions. That's tens of thousands of tokens per request, for context the model already processed yesterday. This creates a pattern of escalating repeated spending. Teams working on production systems often send 1.5–5 million tokens per month simply to keep the model oriented before counting any of the actual work tokens. And this is the base model cost. Many AI coding agents (Devin, Factory, and others built on top of foundation models) charge a premium per token and burn more per session through agentic loops. It's important to note that coding agents like Claude Code do support persistent configuration files (like CLAUDE.md, skill files and custom instructions) that carry context across sessions and can be shared across a team. But there's a meaningful difference between agent configuration ("here's how to work on this codebase") and code intelligence ("here are the critical architectures, business rules, and interdependencies, pre-mapped and queryable"). The former tells the agent how to behave. The latter gives it something to actually know. Configuration files are also rarely centrally governed, they drift, they vary by developer, and they don't scale with codebase complexity. Why Agentic Loops Are Especially Expensive A standard developer prompt re-ingests context once. An AI agent running a multi-step loop — plan, execute, reflect, error-correct, retry — re-ingests that context at every step. A 10-step agentic loop on raw code isn't 10x the token cost of a single prompt. It can be 30–50x, because each reflection and error-correction cycle starts with a full context re-ingestion. This is where the CoreStory ROI is most dramatic. Providing an agent with a structured Code Intelligence Model instead of raw files doesn't just reduce the initial context, it reduces every downstream step, every correction round, and every output generation in the loop. What a Code Intelligence Model Actually Is (And Why RAG Doesn't Solve This) CoreStory ingests your entire codebase once and produces a Code Intelligence Model, a hierarchical specification organized by domain, module, and behavior contract. CoreStory's pipeline performs static analysis, call graph extraction, data flow tracing, and business logic summarization to produce structured output that captures what the software does, not just what it says. This is meaningfully different from a flat embedding index or a retrieval-augmented generation (RAG) approach. RAG sounds appealing: chunk the codebase, embed it, retrieve relevant chunks at query time. In practice, it fails for code in four specific ways: - Poor chunking boundaries: code modules don't chunk cleanly at semantic boundaries. A stored procedure and the schema it depends on rarely land in the same chunk - Loss of cross-module dependencies: chunked embeddings lose the call graph, which is exactly what the model needs to avoid introducing integration errors - No business logic layer: RAG retrieves code text; it doesn't extract the invariants, edge cases, and behavior contracts the CIM explicitly captures - No invariant preservation: the CIM maintains consistent structural relationships; retrieval results vary by query phrasing, producing non-deterministic behavior in agentic loops The result of using a CIM instead of raw code or RAG: the model receives a concise, high-signal specification rather than thousands of tokens of implementation detail , which is why token consumption drops by 70%+ in practice. - - - -