Inspiration
Perishable goods markets move fast. A 30 to 40 percent price swing between nearby wholesale mandis can occur within 24 hours. Farmer Producer Organizations often rely on static dashboards or informal price signals without systematic deviation analysis across markets.
We wanted to build a rule bound decision engine that identifies arbitrage opportunities deterministically, with enforceable constraints.
What It Does
Mandi Intelligence Agent v3 is a multi step AI agent built on Elastic Agent Builder that detects actionable tomato arbitrage opportunities across Karnataka APMC mandis.
It performs the following steps: 1. Resolves “today” using MAX(@timestamp) from live data 2. Retrieves modal prices for tomato 3. Applies deterministic district to home mandi mapping 4. Validates routes using a distance index 5. Computes percentage deviation 6. Triggers alerts at 15 percent or higher 7. Generates structured advisory output 8. Persists the advisory to Elasticsearch
In the demo scenario, three non Bengaluru mandis show strong arbitrage to Bengaluru, all within tomato’s fixed 7 day shelf life window.
How We Built It
Built entirely using Elastic Agent Builder with: • Search Tool for price retrieval • ES|QL queries for timestamp resolution and aggregation • Workflow Tool for structured advisory persistence
Three Elasticsearch indices are used: • mandi-prices • mandi-distances • district-home-mandi
What We Liked About Elastic Agent Builder
Native ES|QL execution inside an agent tool call makes structured time series reasoning seamless and reliable.
Workflow persistence turns advisory output into a durable, queryable document rather than a temporary chat response.
Challenges
Ensuring the agent never hallucinated routes or prices required strict constraints in the system prompt: • Deterministic mandi mapping • Distance validation enforcement • Hard 15 percent deviation threshold • No invented mandis or price assumptions
Built With
- cloud
- elastic
- esql
- kibana
Log in or sign up for Devpost to join the conversation.