Manufacturing Defect Investigation Agent

AboutJune 2026

12· AI Engineering, Data EngineeringAcademic project

Most factory inspection stops at a reject signal, which stops the bad part but not the next hundred. This treats the defect as the start of an investigation: an AI agent pulls the part's production history, compares it to past cases, and writes a root-cause report the way a quality engineer would.

RAGETL

Source ↗

Defect caughtVision stage
The vision model at work on a real transistor photo: its anomaly score (0.0604) clears the threshold it learned during training (0.0341), and the heatmap highlights exactly where the misplaced lead is. This is where a case enters the investigation, not where it ends.
Normal caseVision stage
The same model on a good part: the score stays under threshold, so the case is logged without a defect flag, keeping the system's defect-rate statistics tied to confirmed anomalies rather than every part that passed through the line.
Write-up

Automated visual inspection is mature, and most factories running it still stop at a label: this part is bad, reject it. Nobody is told why, so the same defect keeps being produced until an engineer eventually works through machine logs, supplier batches and shift records by hand. A root-cause answer is worth far more than a reject signal, because it is the one that stops the next hundred defects instead of catching them.

So this treats the label as the start of an investigation. A computer-vision model trained to spot manufacturing flaws (PatchCore, a well-known anomaly-detection approach) flags defects in real photos of a manufactured part, and each flagged part is linked to a production history: which machine made it, which supplier's materials it used, which shift it was made on. That history is built from a real public dataset of machine telemetry and failure records, with a few realistic patterns deliberately planted in it (one machine, for example, tends to run hot and cause heat-related failures), so there is something genuine for the investigation to uncover.

All of it, defects, machines, suppliers and shifts, is stored as a connected network (a knowledge graph) rather than flat tables, which makes relational questions cheap to ask directly: which machine shows up unusually often across defective parts, which suppliers cluster together by failure pattern, which past cases look most like this one. Those questions, plus a search tool over maintenance logs and reference documents, are exposed as 24 individual tools a program can call, following a shared standard (MCP) for how an AI agent is allowed to ask for information. Twenty-four bounded, inspectable tools is a deliberate choice over giving an agent free rein.

A locally-run AI agent sits on top. Given nothing but a case ID, it decides on its own which tools to call and in what order: pulling the case's production history, searching for similar past defects, checking which machines or suppliers look statistically suspicious, then writing up a case summary with a root-cause hypothesis and recommended next steps. Running the model locally keeps proprietary production data inside the plant, which is usually the blocker on manufacturing AI rather than capability.

One caveat that belongs on the front page rather than in a footnote: the production history is simulated, with its patterns planted deliberately. This demonstrates that the investigation loop works, not that it has found anything real yet.

Things to underline
  • Combined three unrelated data sources with no shared ID between them (defect images, machine telemetry, and a simulated production history) into one connected dataset, using a custom pipeline to link them
  • Trained a computer-vision model (PatchCore) to spot and localize physical defects, like a misplaced or bent component lead, in real manufacturing photos
  • Exposed 24 tools an AI agent can call to investigate a case: graph analysis (which machines or suppliers look suspicious), similarity search over past cases, and search over maintenance logs and reference documents
  • Wired a locally-run AI agent to call those tools on its own from just a case ID, producing an evidence-backed root-cause report instead of a bare defect label
Built with
PythonNeo4j GDSMCPOllama