How erabot works
erabot analyses your AI-generated code for cost inefficiencies — across LLM calls, agent loops, tool use, and skills — and writes the fixes. It runs in your own environment under your own model keys, so erabot never sees your source.
Analyze
erabot parses your codebase and finds every LLM call — and the agentic patterns around them: agent loops and runners, tool and skill use, memory, and multi-agent workflows, where cost compounds fastest. Across OpenAI, Anthropic, Gemini, and frameworks like LangChain, LlamaIndex, CrewAI, and LangGraph. Static analysis, so it works on any repo without running it.
Estimate cost
Each call site is priced with real token counts and current per-model prices — including how many times a call fires inside an agent loop — so you see what it costs per month. Connect Helicone, Langfuse, or OpenTelemetry and the estimates become measured from your actual traffic.
Fix
For each inefficiency, erabot writes an apply-ready patch with the dollar savings. You get a report.pdf, a report.md, an agent-instructions.md your coding agent applies directly, and the raw diffs.
Measure & monitor
Every model-downgrade is replayed and quality-checked before it ships (below), and structural fixes pass a build/test gate. Re-run in CI to catch new waste before it reaches your invoice.
What erabot optimizes
The ways LLM and agent spend leaks — and the fix erabot writes for each.
Right-size the model
A task running on a bigger, pricier model than it needs — switched to a cheaper one, verified safe (see below).
Cache stable prompts
System prompts, schemas, and reference docs re-sent every call — moved into a cached prefix.
Trim context
Whole files or full history sent on every request — cut to what the task actually needs.
Batch requests
Per-item calls in a loop — collapsed into one batched request (up to ~50% cheaper for bulk work).
Skip redundant work
The same input re-processed every run — guarded so it only runs when something changed.
Cap output
No max_tokens or verbose-by-default output — capped and tightened.
Agent-loop overhead
For agentic apps: re-sent context and memory, per-turn model choice, bloated tool output, and a judge/guardrail call on every step — usually the single biggest lever.
Safe model switching
The riskiest optimization is telling you to use a cheaper model — get it wrong and you ship a quality regression. erabot never recommends a downgrade on a guess. Before it does, a shadow harness runs:
- 1It writes representative sample inputs for that exact call site.
- 2It replays them through both the current model and the cheaper one.
- 3A judge checks whether the cheaper model still meets the task’s success criteria.
Only swaps that hold up are recommended and shipped as apply-ready patches. Ones that don’t are shown with their measured quality — so you see the trade-off — but never applied automatically. It’s why erabot can safely recommend downgrades that runtime tools can’t: it proves the cheaper model works for your task before you change a line.