Your AI Can't Fix What It Can't See: Why Context Beats Models in Production Debugging

Pasting a stack trace into ChatGPT or Claude gets you a guess, not a root cause. Here's why AI debugging fails without production context, what that context actually is, and how to give it to the model you already use.

By Hiren Patel, Founder & CEO · · 6 min read

Every engineering team has tried it by now. Production throws an error, someone copies the stack trace, pastes it into ChatGPT, Claude, or Copilot, and asks: “What’s wrong?”

Sometimes the answer is right. Often it’s a confident, well-written guess that sends you in the wrong direction for an hour.

So teams reach a reasonable conclusion: “We already have AI. We can solve errors ourselves.”

They’re half right. The model is good enough, and has been for a while. What’s missing is everything the model never got to see.

The experiment you’ve probably already run

Here’s a real-looking production error:

TypeError: Cannot read properties of undefined (reading 'price')
    at calculateTotal (cart.ts:48:31)
    at CheckoutPage (page.tsx:22:18)

Paste that into any good model and you’ll get a sensible answer: “An item in the cart is undefined. Add a null check before reading price.”

That answer is technically correct and practically useless. It treats the symptom. The questions that actually matter are:

  • Why was an item undefined, when it works for thousands of other users?
  • Which users hit it, and what did they do first?
  • When did it start, and what changed at that moment?
  • Is the bad data coming from the frontend, the API, or the database?

The model can’t answer any of these, because none of the answers are in a stack trace. A null check ships, the error goes quiet, and the real bug (say, a pricing API that started returning items without a price for one region after yesterday’s deploy) is still there.

What “context” actually means in production

When an experienced engineer debugs that error, they don’t just read the stack trace. They pull together five or six other things:

Context The question it answers
Stack trace Where did the code fail?
Distributed trace Which services did this request pass through, and which call returned bad data?
Logs around the error What was the system doing just before? Any warnings, retries, timeouts?
Session replay What did the user actually do in the 30 seconds before?
Error history When did this start? How many users? Only one browser, region or plan?
Git and deploy metadata What changed in this code path, and when was it deployed?

The root cause is almost never in one of these alone. It’s in the connections between them: this error started right after that deploy, only for users in this region, because that upstream call began returning a different shape.

A model given all six, already lined up by time and request, can find that connection in seconds. A model given one of them can only guess.

Why “just give the AI access to everything” doesn’t work either

The natural next step is to hand an AI agent access to all your tools and let it fetch what it needs. In practice, this runs into three problems.

1. The data doesn’t line up. If errors are in one tool, logs in another, traces in a third and replays in a fourth, each uses different IDs, different timestamps and different sampling. Connecting them is exactly the hard, slow part of debugging, and the AI has to do it by guesswork too. (We wrote about the cost of this in the four-tool tax.)

2. The context window fills with noise. Production generates far more data than any model can read. Dumping an hour of logs into a prompt buries the three relevant lines under thousands of irrelevant ones, and answers get worse, not better. The skill is selecting the right context, not supplying the most.

3. It creates a data problem. Sending raw logs, traces and source code to a model often means sending customer data and your codebase to a third party, sometimes through several hops. We covered the questions to ask in where your data goes when you turn on an AI SRE agent.

Context is the real work. The model is the easy part.

This flips how teams should think about “AI for debugging”:

  • The model is a commodity. Several providers offer models that are excellent at reading code and reasoning about failures. You probably already pay for one.
  • The context is the hard part: collecting the right signals, connecting them by request and time, picking the relevant slice, and doing it without leaking data.

That’s a data engineering problem, not an AI problem. And it’s the part most teams don’t have time to build.

How to give your AI better context today

You can improve AI-assisted debugging this week, whatever tools you use.

Put a trace ID on everything. Every log line, every error report and every outgoing request should carry the same trace_id. It’s the single field that lets you (and an AI) join signals together. Our OpenTelemetry setup guide shows how.

Tag every build with a version. Set service.version to the Git SHA. Then “did a deploy cause this?” becomes a lookup instead of a Slack thread.

Capture the user’s path. Session replay is best. If you don’t have it, at least log the route, the app version and active feature flags with every error.

Build a “context pack” before you prompt. When you ask a model about an incident, give it a structured bundle instead of a lone stack trace:

ERROR: TypeError: Cannot read properties of undefined (reading 'price')
STACK: cart.ts:48 → page.tsx:22
FIRST SEEN: 2026-11-30 14:12 UTC  |  USERS AFFECTED: 214  |  REGION: eu-west only
DEPLOY BEFORE FIRST SEEN: pricing-api v2.31.0 at 14:05 UTC (commit a3f9c21)
TRACE: GET /api/cart → pricing-api /v2/prices (200, 38ms) → items[3].price missing
LOGS (pricing-api, 14:05–14:15): WARN "currency fallback: EUR rate not found"
DIFF (a3f9c21, pricing.ts): changed currency lookup to new rates table

Given that, almost any good model will tell you the new rates table is missing EUR, and that the null check is the wrong fix. Same model, completely different answer.

Scrub before you send. Remove emails, tokens and customer identifiers before any of this reaches a model, ideally in your OpenTelemetry Collector so it never gets stored anywhere.

Where Modulis fits

Building that context pack by hand for every error is exactly the work engineers don’t have time for at 2 a.m. That’s the job Modulis does.

Modulis runs inside your own cloud and collects your logs, traces, metrics, errors, session replays and GitHub metadata. It connects them by request, user and time, then builds the context for each error: what failed, the trace it came from, the logs around it, what the user did, and the commit that changed that code path.

Then your own AI model does the solving, using your own LLM key with OpenAI, Anthropic, AWS Bedrock or Azure OpenAI. Your code and telemetry never leave your environment, and you keep the model you already trust.

You don’t have to choose between “we have AI” and “we need a tool.” Your AI is the brain. Modulis gives it eyes, so your team is covered when something breaks.


See what your model can do with real context. Start free on one application, or book a 20-minute walkthrough.

Give your AI the context it's missing

Modulis collects and connects your errors, traces, logs, sessions and commits inside your own cloud, then your own AI model does the solving. Start free.

Related posts