What This Agent Does

The Supplier Intelligence Agent is the first agent in the pipeline. Its job is to find out if any of the manufacturer's suppliers are currently experiencing a disruption that could affect deliveries.

It does this by searching the live web for each supplier, reading the results, and making a judgment call about whether the news represents a genuine risk — not just background noise.


Step-by-Step Execution

Step 1 — Fetch all suppliers

The agent queries the supplysafe_suppliers table and retrieves all active suppliers. For NovaBrew, this is six suppliers: ZhenTech Components (China), KorElec Parts (South Korea), AlpineSeal GmbH (Germany), TimbaCraft (Vietnam), BrewSteel Inc. (Mexico), PackRight USA (USA).

Step 2 — Fire a web search per supplier

For each supplier, the agent calls Tavily's search API with a query constructed from the supplier's name, city, and country. Example query: "ZhenTech Components Shenzhen supply chain disruption shipping delay 2026". Tavily returns the top 5 current web results including titles, URLs, and content snippets.

Step 3 — LLM reasoning per supplier

The agent passes the search results to Groq's llama-3.3-70b-versatile with a structured prompt. The prompt includes: the supplier's name, location, and the manufacturer's dependency on them, the raw search results, and an instruction to reason about whether any of the results represent a genuine supply chain risk. The model must return a structured JSON object with fields: risk_detected (boolean), risk_level (critical/high/medium/low), risk_type, summary, and recommended_action.

Step 4 — Write alerts to Supabase

If risk_detected is true, the agent writes a new record to supplysafe_supplier_alerts with the full structured output. It also updates the risk_flag field on the supplier record.

Step 5 — Write to shared state

The agent writes suppliers_checked, new_alerts_created, and suppliers_flagged to the LangGraph state object before passing control to Agent 2.


The Reasoning Judgment

The most important design decision in this agent is what counts as a genuine risk versus background noise.

A news article about general global shipping slowdowns is not a risk for ZhenTech specifically. A news article about port congestion at Shenzhen terminals affecting shipments out of Guangdong province — where ZhenTech is located — is a specific, actionable risk.

The LLM makes this distinction. It is not matching keywords. It is reasoning about whether the geographic, logistical, and category specifics of the news are relevant to this particular supplier relationship. This is why the prompt includes the manufacturer's specific dependency: "NovaBrew Equipment sources Boiler Chambers from ZhenTech. Boiler Chambers are a critical component in their ProBrew X1 and X2 product lines."