LLenny's Podcast
← All frameworks
Productivity

Root-Cause Context Engineering for AI Coding

Don't just fix the AI's bad code — root-cause the missing context so it's right next time.

Difficulty
Advanced
Time to result
~weeks to results
Steps
4
Confidence
90%

A method for actually capturing productivity gains from AI coding tools instead of waiting for models to 'magically' improve. Rather than patching each incorrect output, you treat bad code as a signal of missing context, root-cause what the model lacked, and feed that context (via MCP) so the system produces correct code going forward. It's paired with layering AI-supervises-AI review to compound reliability.

Origin

Bret Taylor's philosophy at Sierra, where a dedicated engineer owns the MCP server feeding their Cursor instance; he frames it as the reason applied-AI companies exist.

Core principles

  • 01A good model making a poor decision almost always signals missing context, not model weakness
  • 02Reviewing and fixing others' (or AI's) code is harder than writing your own — so reduce the need to
  • 03Stacking a 90%-accurate generator with a 90%-accurate reviewer approaches ~99% reliability
  • 04Don't wait for models to improve; do the systems work to get gains now

How to run it

  1. 1

    Stop one-off fixing bad output

    When the coding agent produces incorrect code, resist just editing it. Treat each bad output as a diagnostic signal rather than an isolated defect.

    Watch out Fixing subtle logical errors in AI-generated code is harder and more cognitively costly than editing your own — one-off fixing can erase the productivity gain entirely.

  2. 2

    Root-cause the missing context

    Ask what context the model lacked that would have been necessary to produce the right outcome — the intersection of your specific product and codebase with what the coding agent had available.

    Pro tip Almost always, a good model's poor decision is a lack of context, not a lack of capability.

  3. 3

    Feed the context back through the system

    Provide the missing context to the coding agent (Taylor's team does this via an MCP server every request runs through) so that next time the agent produces the correct code by default.

    Pro tip Dedicate ownership — Sierra has an engineer focused exclusively on the MCP server feeding their Cursor instance.

  4. 4

    Layer AI supervising AI

    Add a second AI agent to catch the errors the first one makes. A 90%-accurate generator plus a 90%-accurate reviewer compounds toward ~99% reliability; keep layering cognition/self-reflection for robustness.

    Pro tip Use compute as cognitive capacity — stack generation, review, and self-reflection layers.

In the wild

Sierra's MCP root-cause loop

Instead of fixing each incorrect Cursor output, Sierra's philosophy is to root-cause why the wrong code was generated — what context was missing — and update the MCP server so the next generation is correct. An engineer owns this exclusively.

A virtuous cycle where the coding system improves at the root; framed as how a team realizes AI productivity gains 'now' rather than waiting on model upgrades.

Common mistakes

Waiting for the models to magically get better

Teams that expect model upgrades to deliver productivity leave the gains on the table today; the work of context engineering and system design is what unlocks them now.

Shipping unreviewed AI code to chase feature velocity

Because reviewing others' code and finding subtle logic errors is very hard, mass-producing features can 'gunk up the machine' and create customer issues that net to negative productivity.

Is it for you?

Best for

Engineering teams adopting AI coding agents (Cursor, Codex, Claude) who want real gains, not just autocomplete

Not ideal for

Throwaway prototypes or vibe-coding where robustness and maintainability don't matter

From the transcript

rather than just fixing it try to root cause it um try to get it so like the next time cursor will produce the correct…

1:11:30

almost always when you have a model making a poor decision, if it's a good model, it's lack of context

1:13:30

how hard would it be to make another AI agent to find the errors the other 10% of the time

1:11:00

people are sort of like waiting for the models to just magically get better. And I'm like, well, that will happen eventually. But if you…

1:12:30

From the episode

He saved OpenAI, invented the “Like” button, and built Google Maps: Bret Taylor on the future of careers, coding, agents, and more