Multi-agent supply chain decision system with HITL approval
Supply chain managers coordinating across 50+ suppliers face 15+ manual handoffs per disruption, causing 72-hour average response delays. LogiAgent autonomously detects disruptions, assesses risk with calibrated probabilities, optimizes routes with mathematical guarantees, and escalates to humans for high-impact decisions.
graph TB
A[Event] --> B[Classifier]
B -->|Low| C[Optimize Only]
B -->|Medium| D[Risk Assessment]
B -->|High/Critical| E[Parallel Assessment]
E --> F[Risk Assessor]
E --> G[Route Optimizer]
F --> H{HITL Required?}
G --> H
H -->|Yes| I[HITL Approval]
H -->|No| J[Aggregate Decision]
I --> J
J --> K[Execute/Complete]
Naive approach:
llm.invoke("rate risk 1-10").This module: Bayesian prior updating from historical disruption data, temporal evidence decay (recent signals weighted higher), Monte Carlo tail-risk simulation (1000 scenarios for VaR estimation), explainable evidence trace showing which signals shifted the posterior, credible intervals with uncertainty quantification.
Why it matters: LLMs produce uncalibrated risk scores; Bayesian scoring gives actual probabilities that decision-makers can act on.
Naive approach:
llm.invoke("suggest alternative route").This module: Google OR-Tools LP with decision variables per supplier per material, multi-objective minimization (cost + lead time + risk, configurable weights), dynamic constraints from SAP mock data (capacity, MOQ, contractual), 4-tier progressive constraint relaxation on infeasibility, sensitivity analysis (how much does the solution change if parameters shift ±10%), human-readable explanation generation.
Why it matters: Mathematical optimality guarantees; LLM route suggestions are not verifiable or reproducible.
Naive approach: Sequential agent function calls.
This module: LangGraph state machine with conditional routing by disruption severity, parallel agent execution (asyncio.gather with ProcessPoolExecutor for CPU-bound OR-Tools), HITL interrupt handling (graph pauses, serializes state to Cosmos DB, resumes on approval), cycle detection with max 3 re-evaluation loops, full checkpoint persistence at every node transition.
Why it matters: Multi-agent workflows need state management, failure recovery, and human oversight for high-stakes decisions.
git clone https://github.com/lAteralthInklAbs/logiagent.git
cd logiagent
pip install -e ".[dev]"
cp .env.example .env
make test| Method | Path | Description | Status Codes |
|---|---|---|---|
POST |
/api/v1/disruptions |
Report a disruption event | 201 / 422 |
POST |
/api/v1/disruptions/{id}/resolve |
Trigger resolution workflow | 202 |
GET |
/api/v1/decisions |
List pending decisions | 200 |
POST |
/api/v1/decisions/{id}/approve |
Approve HITL decision | 200 / 403 |
WS |
/ws/agent-stream |
Real-time agent updates | 101 |
make test # All tests with coverage
make ci # Full CI: lint + typecheck + testTest suite includes:
- Bayesian behavior tests — more evidence narrows confidence interval, recent evidence has more weight
- Hypothesis property tests — allocations always non-negative, total allocation meets demand, no supplier exceeds capacity (200+ generated examples)
- SAP repository mock tests — deterministic seeded data
- E2E agent pipeline integration — event to decision flow
Coverage target: ≥75% on src/optimization/ + src/agents/
docker-compose up --build
# API available at http://localhost:8000
# Cosmos emulator at https://localhost:8081az deployment group create \
--resource-group logiagent-rg \
--template-file infra/main.bicep \
--parameters environment=devAll major decisions documented as ADRs in docs/adr/:
| ADR | Decision | Rationale |
|---|---|---|
| 001 | LangGraph over CrewAI/AutoGen | Native state + checkpointing + HITL support |
| 002 | OR-Tools LP over LLM suggestions | Mathematical guarantees, reproducibility |
| 003 | Repository pattern for SAP | Zero-code swap from mock to real SAP |
| Metric | Target | Status |
|---|---|---|
| Optimization Savings | ≥ 15% vs naive | Pass 1 |
| Risk Calibration Brier | ≤ 0.05 | Pass 1 |
| E2E Latency | < 30s | Pass 1 |
| Classification Accuracy | ≥ 0.88 | Pass 1 |
| Agent Task Completion | ≥ 80% | Pass 2 |
| Forecast MAPE | ≤ 12% | Pass 2 |
- Prophet+LSTM demand forecaster
- Agent eval harness (30+ scenarios)
- Per-agent prompt versioning
- Cost-aware model routing (GPT-4o-mini for simple, GPT-4o for complex)
- OWASP guardrails
- Agentic trace logging with Streamlit viewer
- Prior updating without external libraries
- Temporal evidence decay (exponential, configurable half-life)
- Monte Carlo tail-risk estimation (1000 simulations)
- Brier score self-calibration
- OR-Tools LP for cost minimization
- 4-tier progressive relaxation
- HITL escalation for Tier 3-4
- Sensitivity analysis
- Round-robin baseline comparison
- Conditional routing by severity
- Parallel agent execution
- Cycle detection (max 3 iterations)
- HITL interrupt node
logiagent/
├── src/
│ ├── agents/ # LangGraph state machine
│ ├── optimization/ # Risk + route optimization (★DEEP)
│ ├── sap/ # SAP repository pattern
│ └── persistence/ # Cosmos checkpoint store
├── tests/
├── fixtures/
├── scripts/
├── infra/ # Azure Bicep
└── docs/
├── architecture.md
└── adr/
See configs/settings.yaml for all configuration options.
Key environment variables:
AZURE_OPENAI_KEY- Azure OpenAI API keyAZURE_OPENAI_ENDPOINT- Azure OpenAI endpointCOSMOS_ENDPOINT- Cosmos DB endpointCOSMOS_KEY- Cosmos DB key
- Language: Python 3.11+
- Agent Framework: LangGraph
- Optimization: Google OR-Tools
- Persistence: Azure Cosmos DB
- Testing: pytest, Hypothesis
- Type Checking: mypy
- Linting: ruff
- Containerization: Docker
- IaC: Azure Bicep
MIT — see LICENSE
Built for supply chain resilience.