R&D prototype · open/synthetic data
Multi-Agent Manufacturing QC
Problem
Manufacturing QC sits between two unsatisfying extremes: rule-based systems that go brittle as defect modes multiply, and end-to-end ML models that produce verdicts an operator cannot audit. What a real line needs is in between: a system that uses multiple narrow ML tools (PatchCore, AnomalyCLIP, XGBoost RUL) but treats their outputs as evidence to be cross-examined, not ground truth, and that escalates instead of silently choosing a tiebreaker when the tools disagree. That is the gap this project fills.
What I built
- Built end-to-end as the sole developer: the 11-agent orchestration, the guardrail and deliberation layers, the LLM-provider abstraction, the ML-tool wiring, and the React/TypeScript dashboard (the design choices behind each are below).
- ML-tool wiring as evidence, not verdicts: PatchCore / AnomalyCLIP / Grounded-SAM2 for vision and XGBoost / Chronos for RUL, each wrapped as a tool whose output the agents cross-examine rather than trust.
- Reviewable trace surfaced through a dashboard (ReAct Timeline, Cross-Agent Graph, Guardrail Log, Deliberation Trace, HITL queue, Metrics) so every verdict can be audited end to end.
Design decisions
-
LLM is the orchestrator, never the guardrail
Guardrail violations (physical_inconsistency, cross_agent_contradiction, low_confidence, tool_anomaly, cost_time_exceeded) are evaluated by deterministic Python rules in shared/guardrail.py. An LLM judging an LLM has no error floor; a rule does. Keeping the safety net separate from the agent layer is non-negotiable. The same principle shapes the feedback loop: the Learning agent observes HITL approvals/rejections and suggests threshold deltas via analyze_hitl_history + suggest_threshold_adjustment, but the suggestion is never auto-applied. There is no DB write, no config write, no consumer that mutates state from a model output. An operator manually applies the change, which then takes effect in the next inspection's guardrail evaluation. The loop is half-closed on purpose: parameters adapt, rules and write-paths stay human-authored. Verified by grep: suggest_threshold_adjustment is referenced in only 6 files, all of them tests / stub / the tuner itself / the agent registry, with no consumer applying the suggestion.
All five rules evaluated outside the LLM in shared/guardrail.py. Action column is the routed outcome (retry / deliberation / hitl / force_stop). Half-closed feedback loop: Learning agent suggests, operator applies. No code path writes thresholds from a model output (verified by grep: suggest_threshold_adjustment has 6 references, all in tests / stub / tuner itself / agent registry, no consumer applies the suggestion). -
Two-tier speed: Fast Path before ReAct
When an ML tool returns a confident result (PatchCore score > 0.9 or < 0.2, sensor |z-score| < 2), the agent skips the LLM entirely and returns the deterministic verdict in milliseconds. The expensive ReAct loop only fires when tools alone don't resolve the case. This collapses the median latency of clear cases without giving up the long-tail reasoning. The cheap path runs first by design, not as a fallback.

Case 2 - Tool failure recovery mid-loop: Plan -> Execute (patchcore_score) fails (model checkpoint missing) -> Replan -> Execute (anomaly_clip_classify) succeeds (scratch 0.7618) -> Execute (grounded_sam2_segment) -> Respond DEFECT 76% confidence. Captured run on the inspection DB (N=10): 1 Fast Path (cold-start 113s), 4 Goal-Driven ReAct (2.3-26s), 4 Deliberation (5.3-33s), 6 reached HITL. The cheap path runs first by design, not as a fallback. Warm Fast Path latency is not yet benchmarked separately. -
Disagreement is a first-class state, not a failure
When Recognition reports DEFECT and Prediction reports NORMAL, the system does NOT pick a tiebreaker. It enters a 2-round Deliberation Protocol: Round 1 each agent re-states a position with evidence; Round 2 each rebuts the other's claims; a synthesis node decides if there is consensus or escalates to HITL. The dashboard shows the full trace.

Live trace from the dashboard for the case above - NO CONSENSUS badge top-right. Deliberation Protocol for Case 3 — Recognition reported DEFECT and Prediction reported NORMAL, each at 0.95 confidence. Across 2 rounds neither agent moved, so synthesis returned NO CONSENSUS and escalated to a human; the live trace is the next screenshot. -
On-prem first
Default config is Ollama running qwen2.5:7b locally on a 12 GB GPU, so inspection data never leaves the machine. The same code path swaps to Claude or Gemini by changing one env var (LLM_PROVIDER=claude|gemini|ollama). Data sovereignty is the constraint manufacturers in this domain raise most often, so positioning it as the default rather than the option was deliberate.
-
Goal in the prompt, not how-to
Every system prompt across all 11 agents follows the same skeleton: Domain -> Goal -> Available tools -> Constraints -> JSON output. Notably absent: instructions like 'if score > 0.5 then call SAM2', 'first call A then call B', or 'if confidence > 0.9 return early'. The LLM picks tools, sequence, and stop point, guided only by the goal text, the constraint list, and the tool results it observes. When the toolchain shifts (PatchCore -> FastFlow), only the Available tools block changes; the orchestration logic stays untouched. One mild exception: the Automation agent carries a single soft-ordering constraint (CRITICAL priority actions require HITL approval before execution).
Recognition agent's SYSTEM_PROMPT dissected by region (Domain / Goal / Tools / Constraints / JSON). All 11 agents share this skeleton; one mild exception (Automation has a single line of soft sequencing). The right panel lists what is not in any prompt: no procedural branching, no tool ordering, no control flow.
In operation

Engineering foothold
| Claim | Evidence |
|---|---|
| Pipeline agents: 11 | agents/{recognition,prediction,automation,spc,learning,optimization,safety,scheduling,supply_chain,communication,generation}/ — `ls -d agents/*/` returns exactly 11 directories |
| Tests: 1,150 passing (1,168 collected) | Static count: 1,140 `def test_` functions across 42 test files + parametrize expansions = 1,168 collected; README states 1,150 passing (the remaining 18 skip because they need a live LLM). |
| Python source: ~15,000 LOC | `find shared agents orchestrator -name '*.py' | xargs cat | wc -l` = 14,966 (117 files) |
| TypeScript source: ~3,000 LOC | `find dashboard/src -name '*.ts' -o -name '*.tsx' | xargs cat | wc -l` = 3,011 (33 files) |
| Guardrail rules: 5 deterministic rules | shared/guardrail.py — _check_physical_inconsistency, _check_cross_agent_contradiction, _check_low_confidence, _check_tool_anomaly, _check_cost_time_exceeded (lines 52-193) |
| LLM provider abstraction: 3 (Claude / Gemini / Ollama) | shared/llm_client.py — ClaudeLLMClient (anthropic.AsyncAnthropic, default claude-sonnet-4-20250514), GeminiLLMClient (google-genai), OllamaLLMClient; selectable via LLM_PROVIDER. (A StubLLMClient also exists for offline tests but is not a production provider.) |
| ML-tool benchmarks on synthetic/open data | results/phase1_kpi.json — PatchCore AUROC 1.0000 and AnomalyCLIP AUROC 0.9850 on the synthetic casting set, XGBoost F1 0.9851 on the open AI4I-2020 dataset, Chronos-2 RMSE 40.29 on the open NASA C-MAPSS FD001 set. |
| Recurring API cost: $0 (Ollama on-prem default) | .env.example — LLM_PROVIDER=ollama, OLLAMA_MODEL=qwen2.5:7b (local, no API billing) |
| End-to-end captures: 8 dashboard verifications | 8 multi_agent_*.png in repo root (cross_agent_trace, deliberation, docker_ps, hitl, metrics, ops, react_trace, tech) |

Tech stack
- Orchestration
- LangGraph (StateGraph, conditional edges, checkpointing)
- Inter-agent protocol
- MCP Streamable HTTP, max_depth=2, call-stack circular detection
- LLM
- Ollama qwen2.5:7b (default, RTX 3060), Claude, Gemini (single-env-var swap via LLM_PROVIDER)
- Vision
- PatchCore (anomalib), AnomalyCLIP (open_clip ViT-B/32), Grounded SAM2
- Time-series / RUL
- XGBoost (AI4I-2020, open), Chronos (chronos-forecasting; C-MAPSS, open)
- Vector DB
- ChromaDB PersistentClient (embedded per-agent, no separate server)
- API & runtime
- FastAPI, uvicorn, async-everywhere, websockets
- Frontend
- React 18, TypeScript, Tailwind CSS, Recharts, Vite
- Storage
- SQLite (inspections, defect history)
Gallery

