๐ Beyond Chatbots: Building a Multi-Agent AI System for Smarter Debugging
๐ค What if AI could do more than explain an error? What if it could investigate the problem, challenge its own assumptions, and validate the evidence before recommending a root cause?
That's the idea behind my AI-Incident-Root-Cause-Analyzer project.
๐ Explore the project: AI-Incident-Root-Cause-Analyzer on GitHub
Most AI debugging demos start with a clean error message and end with a confident answer.
Real-world incidents? Not so simple. ๐
You have a deployment pipeline where everything passes until the final step. Logs show an HTTP 403. A JSON parser complains about an unexpected character. Several possible causes seem plausible.
Is it authentication? A gateway issue? An artifact problem? Environment-specific configuration?
The real challenge isn't finding an explanation. It's figuring out which explanation the evidence actually supports.
Let's break down how a three-stage multi-agent architecture can approach this problem.
๐ง The Architecture: Three Agents, Three Responsibilities
Instead of asking one LLM to diagnose everything in a single shot, we separate the investigation into three stages.
๐ Raw Logs + Incident Context
|
โผ
๐ LOG PARSER
Extract the facts
|
โผ
๐ง HYPOTHESIS GENERATOR
Explore possible causes
|
โผ
๐ก๏ธ EVIDENCE VALIDATOR
Test the hypotheses
|
โผ
๐ ROOT CAUSE REPORT
Evidence + Confidence + Next Steps
Each stage has one clear responsibility:
- ๐ Parser: What do we know?
- ๐ง Generator: What could explain it?
- ๐ก๏ธ Validator: What does the evidence support?
Let's put the approach to work.
๐จ The Incident: Everything Greenโฆ Until the Final Step
Imagine a deployment automation workflow that successfully completes authentication, resource creation, configuration association, and backend readiness checks.
Then, at the final step, it fails to retrieve an installer download URL.
Here's a simplified, anonymized error:
Fetching installer information...
Request failed: HTTP 403 Forbidden
Error: Unable to retrieve the download URL.
The response could not be parsed as valid JSON.
Unexpected character '<' at the beginning of the response.
At first glance, this looks like a JSON parsing issue.
But there's a clue hiding in plain sight. ๐
The response starts with <, which often indicates that the client received HTML when it expected JSON.
That HTML could be an access-denied page, a gateway response, a proxy error, or another upstream response.
๐ก Key takeaway: The parsing exception may be a symptom of the failureโnot its root cause.
Now let's investigate systematically.
๐ Agent 1: Log Parser โ Turn Noise Into Facts
The first agent doesn't diagnose. It extracts.
Its job is to transform unstructured logs into a structured incident summary without introducing assumptions.
For our example:
| Signal | Observation |
|---|---|
| HTTP status | 403 Forbidden |
| Expected response | JSON |
| Observed response | Content beginning with <
|
| Failing operation | Retrieving an artifact download URL |
| Failure point | Final deployment stage |
| Initial scope | A particular environment and artifact request |
Notice what's missing: a premature conclusion.
The parser doesn't say, "Authentication is broken." It records what the logs actually show.
Why does this matter?
Because once an early stage labels a problem as an authentication failure, subsequent analysis can become biased toward that explanation.
Separating extraction from diagnosis helps keep the investigation grounded in observable facts.
Output: A normalized incident summary containing error signals, context, and scope.
๐ง Agent 2: Hypothesis Generator โ Think in Possibilities
Now the second agent takes those structured facts and generates competing explanations.
Rather than locking onto the first plausible answer, it explores several hypotheses.
๐ Hypothesis #1: Authentication or authorization failure
Perhaps a token expired, credentials are invalid, or the request lacks the required permissions.
This is plausible because the request returned a 403.
However, the status code alone doesn't tell us which component rejected the request or why.
๐ Hypothesis #2: Gateway, proxy, or intermediary interference
A reverse proxy, gateway, CDN, or security layer may have intercepted the request and returned its own HTML error page.
This could explain both the 403 and the unexpected response format.
It's a strong candidateโbut still a hypothesis until corroborating evidence is available.
๐ฆ Hypothesis #3: Artifact availability or configuration issue
The artifact might be unavailable, incorrectly configured, or inaccessible through the selected download path.
Even though the failure occurs while retrieving the download URL, artifact metadata and environment-specific configuration remain worth checking.
๐ฏ How should the agent rank them?
The goal isn't to pick the most familiar explanation. It's to identify which hypothesis best fits the available evidence and what additional checks could distinguish the alternatives.
Useful evidence might include:
- Response headers and the HTML error body.
- Gateway or proxy logs.
- Authentication and authorization traces.
- Comparisons with successful requests from other environments.
Output: Ranked hypotheses, supporting and contradicting evidence, and the next checks needed.
๐ก๏ธ Agent 3: Evidence Validator โ Trust Evidence, Not Confidence Alone
This is where the investigation gets interesting.
A plausible explanation isn't necessarily a correct explanation. The third agent checks whether the leading hypothesis holds up against independent observations.
โ Check 1: Reproduce the failure outside automation
Repeat the same request through an independent path, using the same environment and equivalent authorization context.
If the failure reproduces, that suggests the issue isn't limited to the automation code path.
It doesn't establish the underlying cause by itself, but it helps narrow the investigation.
๐ Check 2: Compare environments
Try retrieving the same artifact, version, and platform in other environments.
If it succeeds elsewhere but fails in one environment, investigate differences in:
- Environment-specific permissions.
- Gateway or security policies.
- Routing and proxy configuration.
- Credentials and access-control settings.
This helps narrow the scope without assuming the root cause prematurely.
๐ต๏ธ Check 3: Correlate with recent changes
Review relevant configuration changes, credential updates, routing modifications, and gateway logs around the time the failure started.
The absence of an application code change is useful contextโbut it doesn't prove that the application or its dependencies are uninvolved.
The objective is to connect the observed behavior to specific evidence.
๐ What happens next?
If independent reproduction, environment comparisons, and gateway logs all support the same explanation, confidence in that hypothesis increases.
If critical evidence is missing, the report should say so.
No evidence? No pretending the root cause is confirmed.
That's an important design principle: an AI system should be able to communicate uncertainty instead of manufacturing certainty.
Output: A validation report containing evidence, unresolved questions, confidence assessment, and recommended next steps.
โก The Full Workflow at a Glance
Here's the complete investigation lifecycle:
๐ฅ INCIDENT
Raw logs + context
|
โผ
๐ PARSE
Extract observable facts
|
โผ
๐ง HYPOTHESIZE
Generate competing explanations
|
โผ
๐ก๏ธ VALIDATE
Check hypotheses against evidence
|
โผ
๐ REPORT
Findings + confidence + next actions
The benefit is traceability.
When an RCA is incorrect, engineers can inspect the investigation and determine whether the issue came from incomplete extraction, a weak hypothesis, or insufficient validation.
Instead of receiving only an answer, they get a structured trail showing how the investigation progressed.
๐ค Why Not Just Use One LLM Call?
Fair question.
A single LLM call can be perfectly adequate for summarizing logs or diagnosing straightforward errors.
But for complex incidents, separating responsibilities can make the process easier to inspect, test, and improve.
| Single-pass AI | Multi-stage RCA |
|---|---|
| Generates an immediate diagnosis | Separates facts from hypotheses |
| Can anchor on an early guess | Compares competing explanations |
| May mix observations with assumptions | Tracks evidence explicitly |
| Can sound certain without sufficient support | Exposes uncertainty and missing evidence |
| Often returns a flat summary | Builds a structured investigation trail |
๐ฅ The real innovation isn't adding more agents. It's introducing clear boundaries between observation, reasoning, and verification.
One important caveat: multiple agents don't automatically make a system more accurate. They can share the same mistaken assumptions, and an LLM-generated confidence score isn't necessarily a calibrated probability.
The value comes from grounding conclusions in independent evidence and making uncertainty visible.
๐ Where Can This Go Next?
This architecture isn't limited to HTTP 403 errors.
The same approach can be applied to:
- ๐ CI/CD pipeline failures.
- โธ๏ธ Kubernetes startup and readiness issues.
- ๐ API authentication and authorization problems.
- โ๏ธ Configuration drift across environments.
- ๐ Dependency failures and intermittent service errors.
- ๐งช Automated test failures and regressions.
There's also an opportunity to learn from historical incidents, identify recurring failure patterns, and recommend targeted diagnostic checks.
The principle remains the same: use historical patterns to generate leads, not to replace verification.
๐ Final Thoughts
Building AI-powered debugging systems isn't just about asking an LLM to explain a stack trace.
It's about creating a repeatable investigation process that:
๐ Extracts facts without jumping to conclusions.
๐ง Explores multiple possible explanations.
๐ก๏ธ Validates hypotheses against evidence.
๐ Communicates confidence, uncertainty, and next steps.
For me, the most valuable part of a multi-agent RCA pipeline isn't simply the final answer.
It's the evidence trail that explains why the answer deserves to be trustedโand what still needs to be checked.
That's the direction I'm exploring with my AI-Incident-Root-Cause-Analyzer project on GitHub.
๐ฌ Let's Talk AI Engineering
I'm curious how other developers, QA engineers, DevOps engineers, and SREs are approaching this problem.
What's your approach to AI-powered debugging?
- ๐ค A single diagnostic agent?
- ๐ง A multi-agent investigation workflow?
- โ๏ธ AI combined with deterministic checks and human approval?
Share your thoughts, approaches, or lessons learned in the comments. I'd love to hear what's working in real engineering workflows.
Top comments (1)
tr.ee/dev-to