πΎ AgroIntelligence β A Multi-Agent System for Smarter Agriculture

π Inspiration
Farmers often face difficulty accessing reliable data on weather, soil conditions, and market trends when deciding what crops to grow. Inspired by this, we built AgroIntelligence, a multi-agent AI system that simulates the decision-making of agricultural experts β each specializing in a particular domain β to recommend optimal crops in any region based on real-world data.
Our goal is to empower data-driven, sustainable agriculture.
π‘ What it does
AgroIntelligence:
- Takes a location as input.
- Uses five specialized agents to gather and analyze:
- Crop suitability
- Environmental data
- Soil health
- Market demand/supply
- Synthesizes this information to recommend ~10 crops, backed by reasoning and data.
- Displays the real-time thinking process of each agent on a React dashboard with WebSocket updates.
ποΈ How we built it
- Built using Agno, an open-source multi-agent orchestration framework.
- Agents communicate by passing structured responses in JSON format.
- FastAPI serves as the backend and agent controller, handling requests and WebSocket streams.
- The frontend, built with React, receives agent outputs in real-time and displays them in an interactive UI.
π€ Agent Overview
| Agent Name | Description |
|---|---|
CropRecommenderAgent |
Recommends crops suitable for the region using geolocation and agronomy. Starts the workflow, passing the shortlist to downstream agents |
EnvironmentalInfoAgent |
Enriches each candidate crop with locationβspecific Environment specific details.Runs in parallel with other agents; data is merged afterward.β |
MarketingInfoAgent |
Evaluates the economic feasibility of each crops. Scrapes market data, weighs stability and demand to finalize economic viability for each crop.β |
SoilHealthInfoAgent |
Analyzes soil quality, nutrients, and pH levels. Fetches soil surveys, compares actual values with cropβspecific requirements. |
SummaryAgent |
Crafts a clear, farmerβfriendly report from all verified data. Combines all domain insights, ranks crops, and adds practical guidance. |
𧬠Key Code Snippets
π οΈ Agent Definition
crop_recommender_agent = Agent(
model=make_chat(1000),
tools=[DuckDuckGoTools()],
description="CropRecommenderAgent",
instructions=thinking_prompt(
"""Search DuckDuckGo for agronomic guidance for the region.
Return 5β10 suitable crops with sources in `CropsList` format.
"""
),
response_model=CropsList,
structured_outputs=True
)
π Workflow Setup
def run(self) -> RunResponse:
self.log_steps: List[Dict[str, Any]] = []
...
self.status_callback(
AgentStatusUpdate(
agent="CropRecommenderAgent", status="Started crop recommendation"
).json()
)
crops_data: CropsList = self.safe_run(
crop_recommender_agent, location, CropsList()
)
self.status_callback(
AgentStatusUpdate(
agent="CropRecommenderAgent",
status="...
...,
next_agent=["SoilHealthInfoAgent", ...,],
).json()
)
...
β‘ Real-time WebSocket Handling (Frontend)
useEffect(() => {
// Connect to FastAPI backend
socketRef.current = new WebSocket("ws://localhost:8000/ws");
socketRef.current.onmessage = (event) => {
const data = JSON.parse(event.data);
handleWebSocketMessage(data);
};
socketRef.current.onerror = (error) => {
setOutput(prev => prev + "\nError connecting to server");
setLoading(false);
};
socketRef.current.onclose = () => { ... };
return () => socketRef.current?.close();
}, []);
π‘ FastAPI WebSocket Route
@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
user_input = await websocket.receive_text()
async for update in run_workflow_stream(user_input):
await websocket.send_text(update.json())
π§ Architecture Diagram
π§ Challenges we ran into
Chaining Agent Responses: Passing outputs as structured JSON between agents while keeping context.
WebSocket Integration: Real-time updates in React from Python (FastAPI) without delays.
Structured Output from LLMs: LLMs often responded with unstructured text; we enforced schemas to fix this.
Debugging Multi-agent Flows: Identifying where breakdowns occurred in an agent chain was tricky.
π Accomplishments that we're proud of
- Built an end-to-end agent-based AI system that mirrors human decision-making.
- Achieved real-time data aggregation using WebSockets and LLMs.
- Created a highly visual dashboard showing live agent states, interactions, and recommendations.
- Modular agent system β easily extendable to other domains like disaster planning or smart cities.
π What we learned
- Deep understanding of multi-agent system design and orchestration.
- Structuring agent communication via schemas and response models.
- WebSocket integration between Python backend and React frontend.
- Techniques for handling LLM unpredictability and timeouts in real-time applications.
π± What's next for AgroIntelligence
- Add support for live weather APIs, soil sensors, and market APIs.
- Expand to support personalized recommendations per farmer.
- Translate to regional languages and add voice interface.
- Integrate with blockchain supply chains for provenance tracking.
- Release as a mobile app for wider reach in rural areas.
π οΈ Tech Stack
- Backend: Python, Agno, FastAPI, WebSockets
- Frontend: React.js, Tailwind CSS
- Data: DuckDuckGoTools (search), Open-source LLMs (via Ollama)
- Architecture: Multi-Agent Workflow (Agno), REST + Socket APIs
π Project Structure
AgroIntelligence/
βββ backend/ # FastAPI backend + WebSocket endpoints
β βββ agent2_v1.py
β βββ requirements.txt
βββ agent-dashboard/
β βββ App.jsx
β βββ components/
β βββ AgentVisualization.jsx
β βββ DebugHelper.jsx
β βββ SequentialTreeVisualization.jsx
βββ package.json.py
βββ index.html
βββ ...
βββ requirements.txt
βββ README.md
π§ͺ Run Locally
π Backend
Navigate to the
backenddirectory:cd backendInstall the necessary dependencies:
pip install -r requirements.txtRun the FastAPI backend with Uvicorn:
uvicorn agent2_v1:app --reload
βοΈ Frontend
Navigate to the
agent-dashboarddirectory:cd agent-dashboardInstall the required frontend dependencies:
npm installRun the React frontend:
npm run devOpen your browser and navigate to http://localhost:3000 to view the dashboard.
Made with π§ +π± by Team "Barbenheimer" for Luddy Hackathon 2025.
Built With
- agno
- duckduckgo
- fastapi
- openai
- pydantic
- python
- react.js
- rest
- tailwindcss
- websockets
Log in or sign up for Devpost to join the conversation.