- AI Engineering
- Posts
- [Hands-On] Build an Offline Troubleshooting Agent
[Hands-On] Build an Offline Troubleshooting Agent
... PLUS: Cut LLM-as-a-Judge Costs by 59%
In today’s newsletter:
[Hands-On] Build an Offline Troubleshooting Agent
Cut LLM-as-a-Judge Costs by 59%
Reading time: 5 minutes.
Let's say you're building a maintenance agent for a machine on a factory floor. When a fault fires, the technician wants to know what caused it last time and what fixed it.
Two things are potential bottlenecks here:
The network on a plant floor is not guaranteed. If the model and the memory live behind an API, the agent stops remembering when someone needs it.
And if the agent can save its own diagnoses, one wrong guess gets stored as a past incident. The next investigation retrieves it and treats it as experience.
We built an Offline Troubleshooting Agent for that workflow. Ollama runs the model and the embeddings locally, Actian VectorAI DB stores the equipment manual and past incidents on the same machine, and a technician confirms every diagnosis before anything is saved.
Let's walk through the memory layer, the investigation tools, the confirmation step, and the test that proves it works with the network unplugged.
What You Need
Python 3.10 or higher
Docker Desktop
Ollama, with
qwen3:4b-instructandnomic-embed-textpulled
Everything runs on your machine.
What We Are Building
The agent watches a simulated industrial machine that can develop three faults: bearing wear, cooling failure, and pressure loss.
When a fault appears, the agent reads the current sensor values and their recent trend, searches the local equipment manual, and searches past resolved incidents for similar cases. Then it proposes a likely cause and a recommended inspection.
It never writes that proposal to memory. A technician reviews it, edits it if it's wrong, and only then saves the incident.
Set Up the Project
Clone the repository and enter the project directory:
git clone https://github.com/Sumanth077/Hands-On-AI-Engineering.git
cd Hands-On-AI-Engineering/ai_agents/offline_troubleshooting_agent
Start Actian VectorAI DB with docker compose up -d. It runs on ports 6673 to 6675, so it won't collide with another Actian project on the same machine.
Create a virtual environment, install the dependencies with pip install -r requirements.txt, and copy .env.example to .env.
Then load the manual and a few demo incidents, so the first investigation already has past cases to find:
python scripts/seed_memory.py --mode seeded
Step 1. Store the Agent's Memory in Actian VectorAI DB
Actian VectorAI DB is the agent's long-term memory. It runs as a single Docker container on the same machine as Ollama, which is why the agent keeps remembering when the network goes down. Nothing it needs to recall sits behind an API.
It holds two collections. One stores chunks of the equipment manual and troubleshooting guide. The other stores every incident a technician has confirmed.
Saving an incident looks like this:
Two details make this work as memory rather than just search.
The full incident is stored as the payload next to its vector. So a semantic search for "high vibration and high temperature" returns the whole record, not just a match score, and the same incident can also be fetched directly by its id.
And the text that gets embedded is built from the technician's confirmed cause, the fix, and the outcome. The model's original guess is kept in the record but never embedded, so future searches match on what was actually found.
The data also survives restarts. A persistence test in the repo saves an incident, restarts the Actian container, and checks it's still retrievable by id and by search.
Step 2. Give the Agent Tools That Cannot Write Memory
This is the whole tool set the model gets:
None of the six writes to Actian. save_finding only adds a note to the current session's investigation trail, and finish_investigation returns a recommendation.
The model cannot save an incident because it has no tool that does. The rule lives in the tool list, not in a prompt the model might ignore.
The past-incident search is also described to the model as evidence to weigh against the current readings, not as the answer. A similar case from last month doesn't apply if the sensors today say something different.
Step 3. Let the Technician Commit the Incident
Once the agent concludes, Gradio shows a review form pre-filled with its diagnosis. The technician can accept it, correct it, or discard the whole investigation.
Saving builds the incident like this:
Both causes are kept. If the model said cooling fan and the technician found a worn bearing, the record shows both, and it's the worn bearing that gets embedded for the next search.
Step 4. Run the Agent
Start the app with python app.py and open http://127.0.0.1:7860.
Trigger a fault from the Machine Status panel and click Start Investigation. The investigation, retrieved memory, and recommendation panels fill in as the agent works, then the review form appears.
The full code, including the tests for the simulator, memory layer, tools, and safety boundaries, is in our repository. You can run it as-is or swap in your own manual and incident history.
If you want to run the same memory layer on your own hardware, the Community Edition of Actian VectorAI DB is free and comes up with a single docker compose up.
LLM-as-a-judge has become the default way to evaluate open-ended model output. It follows a rubric, it scales, and it adapts when the rubric changes.
It also bills you every time. A reasoning judge like GPT-6 at low effort costs about $12 per 1,000 judgments, which is $12,000 per million, and that bill comes back with every new checkpoint, response set, and training corpus you evaluate.
Most of those judgments are easy. You are paying reasoning prices to confirm that a refusal was a refusal.
Swapping in a cheap judge everywhere doesn't fix it, because a cheap judge gets the hard cases wrong. What you need is a cheap judge that can tell you which cases those are.
A new paper from Carnegie Mellon tests exactly that, using Jev, TypeSafe's decision-only model, as the cheap judge. Jev returns a verdict with a probability for every label and no text. When it is confident, you keep its verdict. When it isn't, you send the item to GPT-6.
With the threshold fixed before evaluation, that cascade came out 0.9 points more accurate than GPT-6 alone at 41% of its fee.
Let's look at where a cheap judge keeps up, why its confidence falls exactly where it stops keeping up, and how to set the threshold without fooling yourself.
How Confidence Routing Works
Every item goes to the cheap judge first. Its highest label probability is the confidence score, and a single threshold decides what happens next.

As a sketch in code:

BETTER is a two-label Choice question asking which of the two responses is better, and reasoning_judge is whatever expensive judge you already use.
For pairwise comparisons, the paper runs Jev on both orders of the pair and averages the probabilities before checking the threshold.
The router itself is trivial. Everything depends on whether the cheap judge's confidence actually drops when it's wrong.
A Cheap Judge Can Read but Not Derive
The paper compares Jev with sixteen other judges across 5,172 base judgments, with blinded human adjudication on every item where Jev and GPT-6 disagree in a 990-item subset.
On its own, Jev ranks eighth of fifteen LLM judges, 1.7 points behind GPT-6. It also costs $0.044 per 1,000 judgments, about 277 times less, and answers in 0.15 seconds at the median against 1.89.
The gap isn't spread evenly. Jev keeps pace wherever the verdict can be read off the text:
Chat quality: 86.1% against GPT-6's 83.9%
Refusing harmful requests: 96.5% against 94.5%
Evidence-grounded factuality: 87.3% against 88.4%
It falls behind wherever the verdict has to be worked out:
Expert knowledge: 7.0 points behind
Code: 12.9 points behind
Math: 14.3 points behind
Logic puzzles: 27.6 points behind
Code shows the split best. On code-repair pairs where the bug is visible in the text, both judges score 99 to 100%. On LiveCodeBench, where you have to trace execution to know which answer is correct, Jev trails by 21.4 points.
On the 3,286 items the other thirteen LLM judges all get right, Jev scores 99.8% and GPT-6 99.7%. The whole gap sits in the middle, on hard items that reasoning models still solve.
Confidence Falls Where Accuracy Falls
That split only helps if Jev knows which side of it an item is on. It mostly does.
On the 3,744 items where Jev's confidence is 0.9 or higher, the two judges are effectively tied, 94.7% against 94.4%. On the 1,106 below that line, GPT-6 leads by 7 points.
So GPT-6's advantage is concentrated in exactly the items Jev would escalate.
The usual fear with a cheap judge is a wrong answer delivered with high confidence. Judged one call at a time, only 12 to 21% of Jev's preference errors come with confidence of 0.9 or more. For GPT-6 the figure is 25 to 41%.
Swapping the order of the two answers barely moves it either. Of Jev's 95 flips when the pair is reversed, only 3 happen above 0.9. The rest sit below the threshold, where the cascade escalates them anyway.
What the Cascade Buys
On 1,610 held-out pairs, with the threshold frozen before any results were seen, the cascade escalated 31% of items and beat GPT-6 alone by 0.9 points at 41% of its fee. That's where the 59% comes from.
The saving depends heavily on the workload:
RewardBench: escalates 25% of pairs, costs 27% of GPT-6's fee
JudgeBench: escalates 65%, and closes 94% of a 12-point gap Jev has on its own
Run live on 510 pairs, the cascade answered in 0.27 seconds at the median, against 2.10 for GPT-6 alone.
The paper also tried eight other cheap or open-weight first stages. Jev was the only one that stayed within two points of GPT-6 on both benchmarks while saving at least 30% of the fee on each. A cheap judge is easy to find. One whose confidence tracks its own mistakes is not.
Where It Breaks
Confidence routing only works where the cheap judge is unsure when it's wrong. Two cases break that.
Style-adversarial pairs. When the wrong answer is written more elaborately than the right one, Jev gets pulled toward it and stays confident. Its ability to flag its own errors drops, and the cascade loses about a point against GPT-6 on those pairs.
Reference-free prose. Judging free-text responses without a reference, every model tested was near chance and still confident. Jev's error detection there is a coin flip, and no threshold fixes that.
The paper says directly that it contributes measurements rather than a new routing algorithm, and it ships a package that reproduces the main analyses from saved outputs.
The number to watch in your own setup is the escalation rate. On easy workloads you escalate a quarter of items and keep most of the savings. On hard ones you escalate three quarters and keep the accuracy.
Either way, you only pay for reasoning on the items that need it.

That’s all for today. Thank you for reading today’s edition. See you in the next issue with more AI Engineering insights.
PS: We curate this AI Engineering content for free, and your support means everything. If you find value in what you read, consider sharing it with a friend or two.
Your feedback is valuable: If there’s a topic you’re stuck on or curious about, reply to this email. We’re building this for you, and your feedback helps shape what we send.
WORK WITH US
Looking to promote your company, product, or service to 200K+ AI developers? Get in touch today by replying to this email.



