The problem
Agentic loops compound costs in ways that aren't
obvious until the bill arrives.
Iteration 1: $0.19. Iteration 30: $2.48. Same
agent, same task — the model re-reads full context
on every turn. By iteration 20 you're paying for
the same context 20 times over.
What I built
LoopLens is a pre-run cost simulator. Configure
your loop before you run it and get a full
per-iteration breakdown.
What it models:
- 4 context accumulation strategies (full, sliding window, summarization, stateless)
- Tool call overhead (web search, code execution, RAG, browser, external API)
- Multi-agent fan-out (orchestrator + N subagents)
- Prompt caching break-even analysis
- 13 models across Anthropic, OpenAI, Google, DeepSeek — compared side by side
Real numbers from a test configuration
30 iterations · Claude Sonnet 4.6 · 4 parallel
subagents · web search + code execution:
- Total: $39.96
- Same loop on DeepSeek V4 Flash: $1.85 (95% less)
- Caching break-even: 1 run, $23.33/month saved
- Sliding window vs full accumulation: 85% savings
Architecture
Pure deterministic math — zero API calls, works
completely offline. Prices pulled live from the
LiteLLM community pricing JSON on page load,
session-cached 6 hours, hardcoded fallback updated
weekly via GitHub Actions. Status badge shows
which layer is active.
The gap: every other cost tool (Langfuse, Helicone,
Braintrust, Bifrost, W&B) is post-hoc observability.
LoopLens is the only pre-run simulator I'm aware of.
Links
Live: looplens-project.vercel.app
Source: github.com/Virerra/looplens
License: MIT






Top comments (0)