How everyone else lost at context engineering
Large language models do not fail at code generation for lack of capacity - they fail because the context they are handed is wrong. Feed the model your whole repository and it drowns: the window overflows, cost scales linearly, and accuracy actually drops as relevant tokens get buried in noise.1 Feed it too little and it hallucinates APIs and breaks the contracts between files. The job of an AI app builder is to compress your project down to the minimal, correct slice for the task at hand. This is a compression problem, and we think the rest of the field got it wrong.
1.The problem is context, not intelligence
A model gets a prompt and some context, and writes code. The writing is no longer the hard part - the models got good. The hard part is deciding which slice of a growing project to put in front of the model for this specific change. There are two failure modes, and the engine’s entire job is to live on the frontier between them.
2.Why everyone else loses
Frontend-only generators (Bolt, Lovable, v0) mostly dump files or feed whole context. They drift across iterations - the single most common complaint is “it rewrote my whole app / lost my design.”
Embedding-similarity RAG - the default everywhere - treats code relevance as a fuzzy similarity cloud.2 But code relevance is a graph: what imports what, what calls what, what a file exports. Cosine similarity rewards surface co-occurrence and misses exact structural edges. Ask for “dark mode” and similarity finds whatever file contains the word “dark” - not the theme provider that has neither word but is the thing you must edit. A graph finds it every time.
| Bolt / Lovable / v0 | Cursor / Replit | PromptFloe | |
|---|---|---|---|
| Relevance model | dump files / naive | embedding similarity | dependency graph + symbol |
| Cross-iteration memory | weak → drifts | chat history | locked design + decision log |
| Context selection | mostly all-in | top-k vectors | tiered + token-budgeted |
| Error grounding | manual retry | partial | local-fix-first repair loop |
3.Our approach: compression-first, structure-first
We architect the engine as a pipeline with a persistent memory at its center. Structural retrieval walks a real dependency graph; project memory locks the design system and prior decisions so the app never drifts; a compressor reduces each non-edited file to its contract; and a verification loop feeds build errors back as fix-context.
The key idea is the contract. A model editing one file rarely needs the implementation of its dependencies; it needs their contracts - what to call and with what types. Keeping a function’s signature and dropping its body is high-information-per-token compression in the precise, Shannon sense,3 and it directly prevents the “imported a symbol that doesn’t exist” failure class.
4.Proof of concept
We measured the engine end-to-end on a real 641-file codebase, for a single-file edit. These are benchmark results, not illustrations, reproducible via the contextCompressor and projectCompression benchmarks.
5.Limitations and what's next
We are not going to pretend this is solved. Doing all of it server-authoritatively - so the graph and contract memory are the source of truth rather than something reconstructed per request - is hard, and we are still hardening it. The piece we want next is a persistent, versioned contract memory so an edit can never silently break a caller. We are building toward it; we are not claiming we are there. If a tool tells you context is a finished problem, it is selling you something.
6.The takeaway
Every AI builder generates code. That is table stakes, and it stopped being a moat the day the models got good. The winners will be the ones that solve context - that hand the model the precise, minimal, correct slice of your project for the task at hand. Cheaper tokens and higher accuracy don’t come from a bigger model. They come from compressing context intelligently. That is the bet we are making.
References
- [1] N. F. Liu et al., Lost in the Middle: How Language Models Use Long Contexts, 2023.
- [2] P. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, 2020.
- [3] C. E. Shannon, A Mathematical Theory of Communication, 1948.