ai newsSa., 17. Okt.
EilmeldungReflection AI open-sources Beam’s weights, post-training recipes

Sub-100ms Cargo & Food Safety Triage: Eliminating 72% of Routing LLM Calls in National Supply Chains

Sub-100ms Cargo & Food Safety Triage: Eliminating 72% of Routing LLM Calls in National Supply Chains Part 3 of the "Jev-First Routing for LangGraph" series. Read Part 1: Your Agent Harness Is Paying LLM Prices for Classifier Decisions | Read Part 2: Manufacturing Safety Routing . Executive Summary

dev.toSamstag 00:26 · 17.10.5 Min. Lesezeit
Bild: dev.to

Posted on Oct 16 • Originally published at Medium

Part 3 of the "Jev-First Routing for LangGraph" series. Read Part 1: Your Agent Harness Is Paying LLM Prices for Classifier Decisions | Read Part 2: Manufacturing Safety Routing.

Executive Summary for Operations & Tech Leaders

In modern food distribution and freight logistics, timing is everything.

When a supplier or regulatory agency notifies a distribution center of an issue, warehouse operations cannot afford delays:

Every incoming notice demands an immediate operational decision:

[ Incoming Supplier Alert ] │ ▼ [ Supply Chain Triage Router ] │ ┌─────────────────────────────────┼─────────────────────────────────┐ ▼ ▼ ▼ [Emergency Quarantine] [Warehouse Hold] [Compliance Relabel] • Stop carrier trucks • Lock pallets at depot • Print corrected labels • Lock warehouse dock bays • Secondary QA lab test • Vendor notice sent • Broadcast customer recall • Vendor payment hold • No transit disruption Enter fullscreen mode Exit fullscreen mode The Bottleneck: Paying Generative LLM Taxes for 3-Way Routing Many supply chain teams build LangGraph multi-agent systems to automate logistics dispatch. However, having a generative LLM (GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro) act as the dispatch router at the graph entrance creates severe operational friction:

langgraph-jev-router solves this with confidence-gated System 1 reflex routing:

[ Supplier Recall Alert ] │ ▼ ┌───────────────────────────────┐ │ TypeSafe Jev Fast-Path │ │ (~88ms System 1 Reflex) │ └───────────────┬───────────────┘ │ ┌───────────────────┴───────────────────┐ │ │ Confidence ≥ 0.70 Confidence < 0.70 (Clear hazard) (Ambiguous / Complex) │ │ ▼ ▼ ┌─────────────────────┐ ┌─────────────────────┐ │ Direct Fast Dispatch│ │ Existing LLM Router │ │ ⚡ ~88ms / No LLM │ │ 🤖 Trusted Fallback │ └─────────────────────┘ └─────────────────────┘ Enter fullscreen mode Exit fullscreen mode Unambiguous hazards (e.g. "Positive swab test for Listeria in finished salad kits" ) are recognized by Jev in ~88ms without calling your LLM. Ambiguous or multi-factor events (e.g. "Sub-potent vitamin D levels in fortified milk cartons with minor packaging tear" ) automatically fall back to your full LLM router. Zero Risk: If the network blips or an API timeout occurs, the system transparently routes to your LLM.

The state graph never crashes. 3. Empirical Benchmark: openFDA Food Recall Enforcement Data We benchmarked this architecture on real-world regulatory notifications using the openFDA Food Enforcement Database (U.S.

Federal Government Public Domain, GitHub Benchmark ).

We evaluated a standard Google Gemini Flash router against langgraph-jev-router across 50 real supply chain hazard reports:

In food safety and supply chain logistics, operations directors require strict precision control.

langgraph-jev-router allows teams to tune the confidence threshold to match their exact risk profile. We executed a multi-threshold sweep ( python supply_chain/benchmark.py --sweep ) from 0.60 to 0.95:

Integrating langgraph-jev-router takes less than 20 lines of code in your existing LangGraph setup:

from typing import Literal from langchain_core.messages import AIMessage, HumanMessage from langgraph.graph import StateGraph, START, END, MessagesState from langgraph_jev_router import jev_first, attach_routes # 1. Define your 3 supply chain action routes with operational descriptions ROUTES = { " emergency_quarantine ": ( " Severe, life-threatening hazards (pathogens like Listeria, Salmonella, E. Coli, " " major undeclared lethal allergens like peanuts or milk, sharp glass or metal fragments).

" " Requires immediate halt of freight carriers, warehouse dock freeze, and public recall. " ), " warehouse_hold ": ( " Moderate, medically reversible hazards (minor biological contaminants, undeclared sulfites, " " cold-chain temperature transit excursions, non-sharp foreign particles, sub-potency). " " Requires quarantining pallets at warehouse, secondary QA inspection, and vendor payment hold.

" ), " compliance_relabel ": ( " Technical regulatory labeling or packaging non-compliance unlikely to cause adverse health consequences " " (missing net weight, omitted language translation, unapproved herbicide trace within safety limits, " " expiration date format, ingredient statement typo). Requires packaging relabeling without halting shipping. " ), } # 2.

Add one decorator to your existing triage function @jev_first ( routes = ROUTES, question = " Which supply chain operational action route should handle this product recall hazard? ", threshold = 0.85, # High precision mode ) def triage_router ( state: MessagesState ) -> Literal [ " emergency_quarantine ", " warehouse_hold ", " compliance_relabel " ]: # ── YOUR EXISTING LLM ROUTER (Acts as 100% zero-risk fallback) ── print ( " 🤖 Complex event: Falling back to Gemini LLM router... " ) # Your standard OpenAI / Gemini / Claude invocation runs here return " warehouse_hold " # 3.

Build your LangGraph state graph builder = StateGraph ( MessagesState ) builder. add_node ( " emergency_quarantine ", lambda s: { " messages ": [ AIMessage ( " Halt trucks and freeze warehouse docks " )]}) builder. add_node ( " warehouse_hold ", lambda s: { " messages ": [ AIMessage ( " Quarantine pallet for secondary QA testing " )]}) builder. add_node ( " compliance_relabel ", lambda s: { " messages ": [ AIMessage ( " Generate corrected packaging labels " )]}) builder. add_conditional_edges ( START, triage_router, [ " emergency_quarantine ", " warehouse_hold ", " compliance_relabel " ], ) for node in [ " emergency_quarantine ", " warehouse_hold ", " compliance_relabel " ]: builder. add_edge ( node, END ) # 4. Attach routes and compile graph = attach_routes ( builder ). compile () Enter fullscreen mode Exit fullscreen mode 6. Enterprise ROI Analysis for National Logistics Networks Consider a national grocery distribution conglomerate managing 18 regional distribution centers:

All benchmark scripts, dataset files, and calibration tools are open source:

git clone https://github.com/JTankariya/jev-router-benchmark.git cd jev-router-benchmark pip install -r requirements.txt export TYPESAFE_API_KEY = "your_api_key" # Run supply chain benchmark python supply_chain/benchmark.py --sample 50 # Run multi-threshold calibration sweep python supply_chain/benchmark.py --sweep Enter fullscreen mode Exit fullscreen mode Library on GitHub: https://github.com/JTankariya/langgraph-jev-router Benchmark Suite: https://github.com/JTankariya/jev-router-benchmark/tree/main/supply_chain PyPI Package: pip install langgraph-jev-router Notice: langgraph-jev-router is an independent open-source project released under the MIT license. Not affiliated with LangChain, Inc. or TypeSafe AI.

Quelle: dev.to (dev.to). Original öffnen