What This Agent Does

The Financial Impact Agent is the third agent in the pipeline. It reads the list of at-risk orders from Agent 2, calculates total revenue exposure, and writes a structured risk assessment to Supabase with a complete cascade summary in plain English.

This is the layer that converts the technical supply chain analysis into a business-language document that a founder or operations lead can read and act on immediately.


Step-by-Step Execution

Step 1 — Read at-risk orders from state

The agent reads at_risk_orders from the LangGraph state object.

Step 2 — Fetch order values

For each at-risk order ID, the agent queries supplysafe_orders to retrieve total_value, customer_id, status, required_ship_date, and delay_days.

Step 3 — Calculate total exposure

The agent sums total_value across all at-risk orders. It also segments the exposure: how much is in in_production status versus delayed versus processing.

Step 4 — Build cascade summary

Groq generates a plain-English cascade summary that reads: "[Supplier] disruption → [Material] stock will reach zero in approximately [X] days → [Product] production halts → [N] customer orders at risk totalling $[X] in revenue. Immediate orders affected: [order list]. Already delayed orders further compounded: [order list]."

Step 5 — Write risk assessment to Supabase

The agent writes a new record to supplysafe_risk_assessments with the full structured output including cascade summary, affected order IDs, revenue at risk, and severity classification.

Step 6 — Write to state

The agent writes total_revenue_at_risk and risk_assessment_ids to the LangGraph state object.


The Risk Assessment Record

Field Description
assessment_id UUID
severity critical / high / medium / low
cascade_summary Full plain-English cascade explanation
revenue_at_risk Total dollar value across all affected orders
affected_order_ids Array of customer order UUIDs
affected_po_ids Array of purchase order UUIDs
root_cause_alert_id UUID of the triggering supplier alert
status open / in_review / actioned
created_at Timestamp