Firstly,
Skyrocketing API bills is not a natural consequence of smarter models.
Okay?
It’s actually
Your backend just dumping unoptimized garbage into the agent’s context window, and you are paying the model to read it over and over again.
If you recently upgraded your Claude Code environment from Sonnet 4.5 to 4.6 or 4.6 to 4.7, you likely noticed an uncomfortable anomaly:
the model got smarter, but your token usage spiked massively.
The immediate assumption is that the new model simply “thinks” more.
But a recent brilliant benchmark experiment I read on a lot of blogs revealed the actual failure.
The token bloat has almost nothing to do with the model’s intelligence. It has entirely to do with how your backend infrastructure exposes information to the agent.
When an LLM lacks precise context, what does it do?
- No, it does not just skip the gap.
- It spends thousands of tokens reasoning about the gap, running discovery queries, and guessing.
When you give an agent a highly capable, generic MCP server (like Supabase), you are essentially forcing a blindfolded engineer to navigate a maze by bumping into the walls.
Here, I let you know why standard backend MCP servers are a massive token sink, what true “backend context engineering” looks like, and the exact architecture required to cut your session costs by 2 to 3x.
First of all,
The Documentation Dump (The Unoptimized Fetch)
Most developers assume that when Claude uses a search_docs tool, it retrieves a surgical, optimized snippet. It does not.
When Claude attempts to set up Google OAuth through the standard Supabase MCP server, the tool returns the entire GraphQL schema metadata ;-;
The agent asks for OAuth instructions, and the server dumps the entire authentication manual into the context window (including magic links, SAML, phone auth, and SSO)
This happens on every single tool call.
Database queries, storage configurations, edge functions, each request drags 5x to 10x more tokens into the context window than necessary.
Across a standard deployment session, this single flaw wastes hundreds of thousands of tokens.
Dashboard Blindness (The Discovery Tax)
When a human developer uses a backend-as-a-service, they open a visual dashboard.
You can instantly see your active tables, RLS policies, and deployed functions in one glance.
An agent cannot see the dashboard. It must query the state programmatically.
Because standard MCP servers do not have a single get_full_topology endpoint, the agent has to run fragmented discovery commands (list_tables, execute_sql).
It pieces the backend state together like a puzzle. This fragmented discovery requires multiple sequential API calls, bleeding tokens at every step.
The Compounding Error Loop (This is the silent killer)
When an agent hits a generic backend error (like a 403 or 500), it lacks the human intuition to cross-reference the logs. It guesses the root cause, writes a fix, and retries.
Here is the reality of an LLM:
Every single retry re-sends the entire conversation history.
In the experiment, the agent encountered a 401 Unauthorized error during document upload.
The agent spent 8 full rounds trying to rewrite the frontend code, redeploying the function, and checking logs.
The actual error was upstream (the platform’s security gate was rejecting the token before the code even ran)
Because the logs did not specify where the rejection happened, the agent guessed 8 times -.-
With every guess, the context window grew larger, and the cost of the next guess became exponentially more expensive.
Understanding how this error looping mathematically destroys your API budget is critical before you deploy any autonomous agent.
So, what is the fix?
Andrej Karpathy defines context engineering as the delicate art of filling the context window with just the right information for the next step.
We do this for prompts, but we completely ignore it for backends.
The fix is not to yell at Claude to “be more concise.”
The fix is to restructure the architecture. (I personally love InsForge)
An open-source tool called InsForge successfully implements this by splitting the context into three distinct, highly constrained layers:
1. Skills (Static Knowledge):
Instead of using MCP to fetch massive documentation schemas mid-flight, you load atomic, highly specific Skills at the start of the session.
InsForge utilizes progressive disclosure which means only loading the metadata initially (about 100 tokens).
The full implementation patterns only load into the context window when the agent explicitly confirms it is working on that specific domain (e.g., insforge-debug only loads when a crash happens).
2. CLI (Direct Execution):
Stop using chat to run complex deployments. You must provide the agent with a local CLI that outputs structured JSON.
By piping npx @insforge/cli commands through the terminal, the agent receives semantic exit codes.
It does not have to read a massive raw error log, it gets a clean JSON response indicating an exact permission failure, stopping the endless retry loop immediately.
3. MCP (Strictly Live State):
MCP should not be used for documentation.
It should be strictly reserved for live state inspection.
InsForge provides a single get_backend_metadata tool that returns the entire backend topology (tables, auth, storage, models) in a single, 500-token JSON payload.
One call. Zero discovery tax.
Let’s do a quick comparison actually!
In side-by-side production benchmarks, an agent building a full RAG application on standard Supabase consumed 10.4 Million tokens ($9.21) and required constant human intervention to escape error loops.The exact same prompt using the highly constrained InsForge architecture consumed 3.7 Million tokens ($2.81) and executed flawlessly.
So,
Stop paying the AI to guess how your infrastructure works!
If you want senior-level autonomous engineering, you have to provide a senior-level, structured context window :)
In case we are meeting for the first time, come over here, it’ll be worth the roller coaster of articles that are gonna come up in the next few weeks.
And If you need help for analyzing UFC fights, please check out BoutPredict :)
Comments
Loading comments…