Get 2,500 events tracked for freeSign up now

Diagnostics

Cost defects

A cost defect is a pattern in code that makes an LLM workload cost more than the same behaviour would cost written differently. Nothing fails and nothing warns — the program is correct, the bill is just bigger — which is why these survive code review and never appear on a provider dashboard.

They are also the norm, not the exception: in our July 2026 scan of 133 public agent repositories, 76% of the 51 making direct LLM calls had at least one of the four below.

  • Broken prompt caching

    A system prompt assembled with an f-string changes on every call, so the provider's prefix cache never matches and tokens you have sent a thousand times are billed at full price. Found at 347 call sites across 39 of the 51 LLM-active repos in our July 2026 scan.

    Mechanism, detection, and the fix
  • Context regrowth

    LLM APIs are stateless, so every turn re-sends the whole conversation. Costs grow with the square of the session length — turn twenty re-sends the previous nineteen — and agent tool loops add turns nobody reads.

    Mechanism, detection, and the fix
  • Tool result bloat

    A large tool payload enters the context once and is re-sent with every turn after it, so its true cost is its size times the remaining session length. The fix belongs at the tool boundary, not in the prompt.

    Mechanism, detection, and the fix
  • Premium models in tests

    CI runs on every commit, and a test asserting a function returns a string doesn't need a frontier model. One in ten scanned repos had opus- or gpt-4o-class literals in test files — including an LLM observability company.

    Mechanism, detection, and the fix

Capsera detects these from structural metadata — cache-read ratios, tool-result token counts, conversation depth, system-prompt hashes — without ever storing prompt content. The definitions behind the vocabulary live in the glossary.