Multi-step AI agent for perishable goods market allocation. Built on Elastic Agent Builder using ES|QL, Search, and Workflow tools.
Mandi Intelligence Agent
A Stateful Multi-Step Decision Engine for Perishable Goods Markets
Built on Elastic Agent Builder
Problem
Perishable agricultural goods face extreme short-term price volatility.
Spot prices can swing 30–40% within 48 hours, while shelf life remains fixed.
Farmer cooperatives typically make allocation decisions using static dashboards, spreadsheets, or messaging apps — without structured reasoning, historical context, or auditability.
A single wrong 24-hour decision can erase margin entirely.
This project builds a multi-step, tool-driven AI agent using Elastic Agent Builder that detects conflicting market signals, resolves them under real-world constraints, and persists every advisory to Elasticsearch for verification.
What This Agent Does
Given:
• 20 tonnes of perishable goods
• Multiple wholesale markets
• 7-day rolling price history
• Daily arrival volumes
• Transport cost + shelf life constraints
The agent:
1. Detects statistical price anomalies using ES|QL
2. Retrieves current market prices using the Search tool
3. Detects supply surges using ES|QL on arrival data
4. Resolves disagreement between analyst outputs
5. Calculates revenue impact
6. Persists a structured advisory using the Workflow tool
All queries shown in the demo execute live against indexed data in Elasticsearch Serverless.
Demo Scenario
• Commodity: Tomato
• Quantity: 20 tonnes
• Markets: Kolar APMC, Bangalore APMC (Yeshwanthpur), Tumakuru APMC
Observed:
• Kolar dropped 28% vs rolling 7-day baseline (glut signal)
• Bangalore temporarily elevated
• Arrival surge building in Bangalore
Naïve strategy: send 20T to Bangalore.
Agent decision:
• 12T → Bangalore (sell today)
• 8T → Hold at Kolar (sell in 2 days)
Additional gain over naïve strategy: ₹1,98,744
Per farmer across 50-member FPO: ₹3,975
Architecture
Elasticsearch Indices
• mandi-prices — rolling 7-day price history per market
• mandi-arrivals — daily arrival volume per market
• advisories — persisted …