The Core Decision: LangGraph over n8n

The first architectural question was whether to build SupplySafe in n8n — the same orchestration layer used for SmartForm AI, Recruit-AI, and OutreachIQ — or to use a proper agent framework.

The answer came from the nature of the task. n8n is a workflow tool. It executes sequences of steps that the developer pre-defines. The developer decides every branch, every condition, every output format. This works well for deterministic tasks where the logic is known in advance.

Supply chain risk monitoring is not deterministic. The Supplier Intelligence Agent needs to read unstructured web content — news articles, shipping reports, geopolitical commentary — and reason about whether any of it represents a genuine risk for a specific manufacturer with a specific supplier in a specific geography. That reasoning cannot be pre-written as workflow logic. It requires an LLM with agency over its own output.

LangGraph was chosen because it provides exactly what n8n cannot: a shared state object that persists across multiple agent invocations, directional control over which agent runs next based on the output of the previous agent, and the ability for each agent to read what prior agents concluded before forming its own output.


The Shared State Model

Every agent in SupplySafe reads from and writes to a single SupplySafeState TypedDict. This is the architectural equivalent of a shared whiteboard.

SupplySafeState:
  trigger: str
  run_id: str
  suppliers_checked: list[str]
  new_alerts_created: list[str]
  suppliers_flagged: list[str]
  materials_critical: list[str]
  affected_pos: list[str]
  at_risk_orders: list[str]
  total_revenue_at_risk: float
  risk_assessment_ids: list[str]
  draft_action_ids: list[str]
  errors: list[str]

Agent 1 writes suppliers_flagged. Agent 2 reads suppliers_flagged and writes at_risk_orders. Agent 3 reads at_risk_orders and writes total_revenue_at_risk. Agent 4 reads everything and writes draft_action_ids. Each agent builds on genuine intelligence from the previous agent — not just data passed through a pipe.


The Two-Model Strategy

SupplySafe uses two different LLMs for two different jobs.

Groq (llama-3.3-70b-versatile) handles the tasks that require speed and volume: reasoning about supplier news across six suppliers, drafting multiple communications simultaneously. Groq's inference speed — typically under 500ms per call — means the full pipeline runs in under 60 seconds.

Groq (DeepSeek R1 Distill 70b) was evaluated for the complex reasoning steps. In practice, llama-3.3-70b-versatile proved sufficient for the supplier intelligence reasoning task at the required output reliability level.

The original architecture considered Claude API for the deep reasoning steps, paralleling the Groq + Claude two-layer model in OutreachIQ. This was deprioritised for cost reasons in the initial build. The slot exists in the architecture for future integration.


Why Agents Are Separated

The four agents could theoretically be collapsed into one large prompt: search suppliers, trace cascade, calculate exposure, write emails. This was explicitly rejected.

Each agent has a single, well-defined job. This means: