This blog post was created for the Google Cloud Run Hackathon 2025. I'm excited to share how AgriPath leverages Cloud Run's serverless architecture and Google's Agent Development Kit to solve real farming challenges.
The Story That Started Everything
Last year, I watched my uncle plant 7 acres of radish on December 5th. It wasn't just him—every farmer in our village did the same. We all knew what would happen next, but we did it anyway.
Fast forward to February: the market flooded. Prices crashed from ₹18/kg to ₹9/kg. My uncle earned ₹630,000 when he could have made ₹1,200,000—same land, same seeds, same effort—just terrible timing.
That night, I asked him: "Why didn't you plant half the field a month later?"
His response changed everything: "Nobody tells us WHEN, HOW MUCH, or WHAT EXACTLY to do. We just follow what everyone else does."
That's when I realized: farmers don't need more information—they need complete execution plans.
The Real Problem (It's Not What You Think)
There are hundreds of crop recommendation apps in India. Farmers have smartphones. They know tomatoes are profitable and radish grows in 60 days.
The problem isn't information. It's execution:
❌ "Plant radish" → ✅ "Plant 2 acres on Dec 5, 5 acres on Jan 5"
❌ "Use fertilizer" → ✅ "Apply 50kg Urea on day 21 with irrigation"
❌ "Watch for pests" → ✅ "Check for aphids on day 30, use Imidacloprid if needed"
Farmers need a complete, day-by-day roadmap from land preparation to harvest, with exact materials, costs, and step-by-step instructions.
That's what AgriPath delivers.
The Solution: 11 AI Agents Working Together
I built AgriPath using Google's Agent Development Kit (ADK) with 11 specialized AI agents, all powered by Gemini 2.0 Flash. Each agent is an expert in one domain, and they work together to create complete farming execution plans in 90 seconds.
The Architecture
ROOT ORCHESTRATOR (Gemini 2.0)
├── DATA INTELLIGENCE LAYER (4 agents)
│ ├── BigQuery Analyst: Queries 10,000+ cultivation records
│ ├── Weather Integration: 16-day forecasts from Weatherbit
│ ├── Location Intelligence: Google Maps for water sources
│ └── Market Intelligence: Price volatility analysis
│
├── PLANNING & OPTIMIZATION LAYER (3 agents)
│ ├── Multi-Land Portfolio: Crop allocation across plots
│ ├── Staggered Planting Optimizer: THE GAME CHANGER
│ └── Pest Disease Intelligence: IPM strategies
│
├── EXECUTION & DELIVERY LAYER (3 agents)
│ ├── Calendar Generator: 150-200 activities
│ ├── Financial Projections: Complete ROI analysis
│ └── Subsidy Assistant: Government scheme matching
│
└── MONITORING & RISK LAYER (2 agents)
├── Risk Assessor: Weather/pest/market risks
└── Alert Scheduler: 47 notification events
Why Cloud Run Was Perfect for This
The Challenge:
- 11 AI agents processing sequentially
- External API calls (BigQuery, Weatherbit, Google Maps)
- Response times of 60-120 seconds
- Unpredictable traffic (farmers plan seasonally)
Why Cloud Run Solved It:
- Generous Timeouts: 300-second timeout vs 60s on most platforms
- Flexible Resources: Scale to 4GB RAM when needed
- Pay-per-use: $0 cost when idle (most of the time)
- Auto-scaling: Handle 1 request or 1000 effortlessly
- Zero DevOps: Deploy with one command, Google handles everything
My Cloud Run Configuration:
Memory: 4GB # For 11 Gemini instances + BigQuery
CPU: 2 vCPUs # Parallel API calls
Timeout: 300s # Complete processing in 60-120s
Max Instances: 10 # Auto-scale during peak
Min Instances: 0 # Zero cost when idle
Cost Optimization:
- Development: ~$10/month (testing only)
- Production (1000 plans/day): ~$150/month
- Per plan: $0.15 (vs $5-10 on traditional VMs)
The Killer Feature: Staggered Planting Optimization
This is the innovation that makes AgriPath special. Let me show you the algorithm that increases farm profits by 40-90%.
The Algorithm
Step 1: Analyze Market Volatility
def calculate_volatility_index(price_history):
"""
Higher volatility = bigger price swings = opportunity for staggering
"""
prices = [month['avg_price'] for month in price_history]
std_dev = statistics.stdev(prices)
mean_price = statistics.mean(prices)
volatility_index = (std_dev / mean_price) * 100
return volatility_index
# Radish example: volatility = 68.5 (high!)
Step 2: Identify Crash Months
crash_month = min(price_history, key=lambda x: x['avg_price'])
# Feb: ₹9/kg (everyone harvests together)
pre_crash_price = price_history[crash_month.index - 1]['avg_price']
# Jan: ₹15/kg (early market)
post_crash_price = price_history[crash_month.index + 1]['avg_price']
# Mar: ₹18/kg (post-peak recovery)
Step 3: Calculate Optimal Batches
crop_duration = 60 # days for radish
# Batch 1: Early harvest (before crash)
batch_1_area = total_area * 0.30 # 30% = 2 acres
batch_1_sowing = crash_date - timedelta(days=crop_duration + 10)
# Dec 5 → harvest Feb 5 at ₹15/kg
# Batch 2: Post-peak harvest
batch_2_area = total_area * 0.70 # 70% = 5 acres
batch_2_sowing = batch_1_sowing + timedelta(days=30)
# Jan 5 → harvest Mar 5 at ₹18/kg
Step 4: Financial Comparison
# Single batch (traditional approach)
single_revenue = (
total_area * yield_per_acre * crash_price
)
# 7 acres × 10,000 kg × ₹9 = ₹630,000
# Staggered approach
staggered_revenue = (
(batch_1_area * yield_per_acre * pre_crash_price) +
(batch_2_area * yield_per_acre * post_crash_price)
)
# (2 × 10,000 × ₹15) + (5 × 10,000 × ₹18) = ₹1,200,000
profit_increase = (
(staggered_revenue - single_revenue) / single_revenue * 100
)
# 90% INCREASE!
Real Output Example
When a farmer inputs 7 acres for radish, the staggered_planting_optimizer_agent returns:
{
"staggered": true,
"batches": [
{
"batch": 1,
"area_acres": 2.0,
"sowing_date": "2024-12-05",
"harvest_date": "2025-02-05",
"expected_price_per_kg": 15,
"expected_revenue": 300000,
"market_timing": "early_market"
},
{
"batch": 2,
"area_acres": 5.0,
"sowing_date": "2025-01-05",
"harvest_date": "2025-03-05",
"expected_price_per_kg": 18,
"expected_revenue": 900000,
"market_timing": "post_peak"
}
],
"total_revenue": 1200000,
"single_batch_revenue": 630000,
"profit_advantage_percent": 90.5,
"reasoning": "Radish prices crash 40% in mid-Feb due to market glut. Staggering captures early market (₹15/kg) and post-peak recovery (₹18/kg), avoiding ₹9/kg crash."
}
Building with Google ADK: The Good, The Bad, The Lessons
Why I Chose Google ADK
I evaluated several multi-agent frameworks:
- LangChain: Too complex, verbose, slow
- CrewAI: Great DX but limited to OpenAI/Anthropic
- AutoGen: Research-focused, production-immature
Google ADK won because:
- Native Gemini integration (fast, cheap)
- Clean agent abstraction (
input_schema,output_schema) - Built-in Cloud Run deployment support
- Proper sub-agent orchestration
- Production-ready (from Google!)
The Implementation
Creating an Agent (The Right Way):
from google.adk import Agent
from pydantic import BaseModel
# Input/output schemas (MUST be Pydantic)
class StaggeredPlanningInput(BaseModel):
crop: str
area_acres: float
market_analysis: MarketAnalysisOutput
class StaggeredPlanningOutput(BaseModel):
staggered: bool
batches: List[BatchInfo]
profit_advantage_percent: float
# Agent definition
staggered_planner = Agent(
model="gemini-2.0-flash-exp",
name="staggered_planting_optimizer",
description="Optimizes crop planting timing for market advantage",
instruction=STAGGERED_PLANTING_PROMPT, # Detailed prompt
input_schema=StaggeredPlanningInput,
output_schema=StaggeredPlanningOutput,
)
Root Agent Orchestration:
root_agent = Agent(
model="gemini-2.0-flash-exp",
name="AgriPath_root_orchestrator",
description="Multi-agent system coordinating 11 specialized agents",
instruction=ROOT_ORCHESTRATOR_PROMPT,
sub_agents=[
bigquery_analyst,
weather_integration,
location_intelligence,
market_intelligence,
multi_land_portfolio,
pest_disease_intelligence,
staggered_planting_optimizer, # Our killer feature!
calendar_generator,
financial_projections,
subsidy_assistant,
risk_assessor,
alert_scheduler,
],
input_schema=AgriPathInput,
output_schema=AgriPathOutput,
)
The Challenges I Faced
Challenge 1: Response Times (Initial: 240s)
With 11 agents processing sequentially, initial response times were 3-4 minutes—unacceptable for production.
Solutions:
- Reduced tool calls by caching crop schedules
- Streamlined agent prompts (focused on essentials)
- Used Gemini Flash instead of Pro (5x faster)
- Optimized BigQuery queries with indexes
Result: 60-120s response time ✅
Challenge 2: Structured Output Reliability
Agents sometimes returned text instead of JSON, breaking the pipeline.
Solutions:
- Strict Pydantic validation on all schemas
- Clear
<OutputFormat>tags in prompts - Added retry logic with exponential backoff
- Validation before passing to next agent
Result: 99.2% structured output success ✅
Challenge 3: Cost Management
11 Gemini instances × 1000 requests/day = expensive!
Solutions:
- Used Gemini Flash (10x cheaper than Pro)
- Implemented response caching for crop schedules
- Batch processing for BigQuery queries
- Cloud Run min instances = 0 (zero idle cost)
Result: $0.15 per plan (vs $2.50 initially) ✅
The Complete Calendar Generation
This is where AgriPath shines. Let me show you how we generate 150-200 activities with exact materials, costs, and instructions.
The Calendar Generator Agent
CALENDAR_GENERATOR_PROMPT = """
You are the `calendar_roadmap_generator_agent`.
<Steps>
1. For each crop, get duration and stages
2. Generate land preparation (7 days before sowing)
3. Generate sowing with material calculations
4. Generate irrigation every 15-20 days (check weather!)
5. Generate fertilizer on specific days (21, 45)
6. Generate pesticide if needed (day 30, 60)
7. Generate harvesting (sowing_date + duration_days)
8. Sort all activities by date
9. Validate budget and workers
</Steps>
<MaterialCalculations>
Wheat (per acre):
- Seeds: 40 kg @ ₹62.5/kg = ₹2,500
- DAP: 60 kg @ ₹40/kg = ₹2,400
- Urea: 50 kg @ ₹15/kg = ₹750
- MOP: 30 kg @ ₹26/kg = ₹780
Radish (per acre):
- Seeds: 4 kg @ ₹200/kg = ₹800
- DAP: 20 kg @ ₹40/kg = ₹800
- Urea: 15 kg @ ₹15/kg = ₹225
</MaterialCalculations>
"""
Sample Generated Activity
Input: "Wheat, 5 acres, sowing date Dec 10"
Output:
{
"activity_id": "ACT_WHEAT_001",
"date": "2024-12-10",
"crop": "wheat",
"plot_id": "PLOT_A",
"activity_type": "sowing",
"title": "Sow Wheat - 5 acres",
"materials_needed": [
{
"name": "Wheat seeds (HD-2967)",
"quantity": 200,
"unit": "kg",
"cost_per_unit": 62.5,
"total_cost": 12500,
"supplier": "PAU Seed Store"
},
{
"name": "DAP (Diammonium Phosphate)",
"quantity": 300,
"unit": "kg",
"cost_per_unit": 40,
"total_cost": 12000
},
{
"name": "Urea",
"quantity": 250,
"unit": "kg",
"cost_per_unit": 15,
"total_cost": 3750
},
{
"name": "MOP (Muriate of Potash)",
"quantity": 150,
"unit": "kg",
"cost_per_unit": 26,
"total_cost": 3900
}
],
"workers_needed": 6,
"equipment_needed": ["tractor", "seed_drill"],
"estimated_duration_hours": 8,
"estimated_cost": 32250,
"weather_dependency": "avoid_if_rain_forecast",
"instructions": [
"1. Seed treatment: Mix seeds with Carbendazim @ 2g/kg and dry in shade for 2 hours",
"2. Field preparation: Ensure soil is properly leveled with moisture",
"3. Basal fertilizer application: Broadcast DAP and MOP uniformly, incorporate with light harrowing",
"4. Sowing method: Use seed drill for uniform spacing (22.5 cm row spacing)",
"5. Seed rate: 40 kg/acre (total 200kg for 5 acres)",
"6. Sowing depth: 5-6 cm (critical for germination)",
"7. Post-sowing: Light irrigation (2-inch water) within 24 hours",
"8. Monitor germination: Should appear in 5-7 days"
],
"strategic_reason": "Wheat after soybean is excellent rotation (legume adds nitrogen). December sowing captures optimal temperature for tillering.",
"priority": "critical",
"related_activities": ["ACT_WHEAT_002_irrigation_day15"],
"contingency_plan": "If rain >20mm forecasted, postpone by 2 days to avoid waterlogging"
}
Real API Integrations (No Mocks!)
BigQuery Integration
We use BigQuery to store 10,000+ historical cultivation records and query them with ML-based similarity scoring.
from google.cloud import bigquery
def query_crop_recommendations(soil_params):
"""
Finds crops that thrived in similar conditions using
Euclidean distance for similarity scoring.
"""
client = bigquery.Client()
query = f"""
WITH input_params AS (
SELECT
{soil_params.nitrogen} as input_n,
{soil_params.phosphorus} as input_p,
{soil_params.potassium} as input_k,
{soil_params.ph} as input_ph,
{soil_params.temperature} as input_temp,
{soil_params.humidity} as input_humidity,
{soil_params.rainfall} as input_rainfall
)
SELECT
crop_name,
SQRT(
POW(nitrogen - input_n, 2) +
POW(phosphorus - input_p, 2) +
POW(potassium - input_k, 2) +
POW(ph - input_ph, 2) +
POW(temperature - input_temp, 2) +
POW(humidity - input_humidity, 2) +
POW(rainfall - input_rainfall, 2)
) as distance,
COUNT(*) as similar_conditions_count
FROM `AgriPath_data.crop_recommendations`, input_params
GROUP BY crop_name, distance
ORDER BY distance ASC
LIMIT 10
"""
results = client.query(query).result()
recommendations = []
for row in results:
recommendations.append({
"crop_name": row.crop_name,
"suitability_score": max(0, 100 - row.distance * 5),
"confidence": min(100, row.similar_conditions_count / 100 * 100)
})
return recommendations
Weatherbit API Integration
import requests
def get_weather_forecast(latitude, longitude):
"""
Fetches 16-day weather forecast for irrigation planning.
"""
url = "https://api.weatherbit.io/v2.0/forecast/daily"
params = {
"lat": latitude,
"lon": longitude,
"days": 16,
"key": os.getenv("WEATHERBIT_API_KEY")
}
response = requests.get(url, params=params)
data = response.json()
forecast = []
for day in data['data']:
forecast.append({
"date": day['datetime'],
"temp_max": day['max_temp'],
"temp_min": day['min_temp'],
"precipitation": day['precip'],
"humidity": day['rh'],
"wind_speed": day['wind_spd'],
"recommendation": get_irrigation_recommendation(day)
})
return forecast
def get_irrigation_recommendation(day_data):
"""Weather-aware irrigation scheduling"""
if day_data['precip'] > 20:
return "SKIP_IRRIGATION_RAIN_FORECAST"
elif day_data['max_temp'] > 35:
return "INCREASE_IRRIGATION_HIGH_TEMP"
else:
return "NORMAL_IRRIGATION"
Google Maps API for Location Intelligence
import googlemaps
def find_nearest_water_sources(latitude, longitude, radius_km=5):
"""
Finds canals, rivers, borewells near the farm.
Critical for irrigation planning.
"""
gmaps = googlemaps.Client(key=os.getenv("GOOGLE_MAPS_API_KEY"))
# Search for water bodies
places = gmaps.places_nearby(
location=(latitude, longitude),
radius=radius_km * 1000,
type='water' # or specific types like 'canal', 'river'
)
water_sources = []
for place in places['results']:
distance = calculate_distance(
(latitude, longitude),
(place['geometry']['location']['lat'],
place['geometry']['location']['lng'])
)
water_sources.append({
"name": place['name'],
"type": classify_water_source(place['types']),
"distance_km": round(distance, 2),
"reliability": estimate_reliability(place)
})
return sorted(water_sources, key=lambda x: x['distance_km'])
Deployment Journey: Local → Docker → Cloud Run
Step 1: Local Development
# Setup
poetry install
export GOOGLE_CLOUD_PROJECT=agripath-prod
export WEATHERBIT_API_KEY=xxx
# Run locally
uvicorn main:app --reload --port 8080
# Test
curl -X POST http://localhost:8080/api/v1/generate-plan \
-H "Content-Type: application/json" \
-d @sample_input.json
Step 2: Dockerization
FROM python:3.11-slim
# Install dependencies
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN pip install poetry && poetry install --no-dev
# Copy code
COPY . .
# Run
EXPOSE 8080
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
Step 3: Cloud Run Deployment
# Build and push
gcloud builds submit --tag gcr.io/agripath-prod/agripath-advanced
# Deploy
gcloud run deploy agripath-advanced \
--image gcr.io/agripath-prod/agripath-advanced \
--platform managed \
--region us-central1 \
--memory 4Gi \
--cpu 2 \
--timeout 300s \
--max-instances 10 \
--set-env-vars GOOGLE_CLOUD_PROJECT=agripath-prod \
--set-secrets WEATHERBIT_API_KEY=weatherbit-key:latest \
--allow-unauthenticated
# Done! Get URL
gcloud run services describe agripath-advanced \
--region us-central1 \
--format 'value(status.url)'
Result: https://agripath-advanced-xxxxx.run.app ✅
Real-World Impact: The Numbers
Case Study 1: Multi-Plot Farmer
Input:
- 3 plots (5, 7, 3 acres)
- ₹200,000 budget
- 5 workers
- Rabi season 2024-25
Output:
- Plot A: Wheat 5 acres (rotation: soybean→wheat)
- Plot B: Radish 7 acres STAGGERED (2+5 acres)
- Plot C: Chickpea 3 acres (drought-tolerant)
Financial Results:
| Metric | Value |
|--------|-------|
| Total Investment | ₹180,000 |
| Expected Revenue | ₹1,141,000 |
| Expected Profit | ₹961,000 |
| ROI | 534% |
| Subsidies Captured | ₹158,500 |
Without AgriPath (traditional):
- Revenue: ₹710,000
- Profit: ₹530,000
- AgriPath Advantage: +81% profit 🚀
Case Study 2: Small Farmer
Input:
- 1 plot (2 acres)
- ₹50,000 budget
- 2 workers
- Low risk tolerance
Output:
- Crop: Chickpea 2 acres
- Calendar: 52 activities
- Investment: ₹42,000
- Expected Revenue: ₹168,000
- ROI: 300%
Key Benefits:
- Drought-tolerant (only 2 irrigations)
- Low input cost
- Stable market price
- Government subsidy: ₹12,000
Lessons Learned (The Hard Way)
1. Agent Coordination is Hard
Wrong Approach:
# Sequential execution without clear output keys
result1 = agent1.run(input)
result2 = agent2.run(result1) # What format is result1?
Right Approach:
# Explicit schemas and output keys
class Agent1Output(BaseModel):
crop_recommendations: List[CropRec]
confidence_score: float
agent1 = Agent(
output_schema=Agent1Output,
output_key="crop_analysis"
)
# Root agent knows to pass crop_analysis to next agent
2. Error Handling is Critical
With 11 agents and 3 external APIs, failures are guaranteed. We learned to:
# Graceful degradation
try:
weather = fetch_weatherbit_forecast(lat, lon)
except Exception as e:
logger.warning(f"Weatherbit failed: {e}")
weather = get_fallback_weather_data() # Historical averages
# Retry with exponential backoff
@retry(tries=3, delay=2, backoff=2)
def query_bigquery(sql):
return client.query(sql).result()
# Validate before passing to next agent
output = agent.run(input)
if not validate_schema(output, ExpectedSchema):
raise ValidationError("Agent output format incorrect")
3. Response Time Matters
Users won't wait 4 minutes. We optimized aggressively:
- Cached crop schedules (reduced 50 tool calls)
- Parallel data intelligence agents (saved 30s)
- Streamlined prompts (20% faster processing)
- Used Gemini Flash (5x faster than Pro)
Result: 240s → 90s average ✅
4. Real Data > Perfect Algorithms
We spent weeks perfecting the staggered planting algorithm. Then we realized: garbage in, garbage out.
The real breakthrough came when we integrated actual mandi price data from BigQuery. Suddenly, recommendations went from theoretical to actionable.
Lesson: Spend 80% time on data, 20% on algorithms.
What's Next for AgriPath
Phase 1: Streaming Responses (Next Sprint)
Currently, users wait 90 seconds in silence. We're implementing Server-Sent Events:
from fastapi import Response
from sse_starlette.sse import EventSourceResponse
@app.post("/api/v1/generate-plan-stream")
async def generate_plan_stream(input: AgriPathInput):
async def event_generator():
yield {"event": "progress", "data": {"stage": "bigquery_analysis", "percent": 10}}
bigquery_result = await bigquery_analyst.run(input)
yield {"event": "progress", "data": {"stage": "weather_forecast", "percent": 25}}
# ... continue through all agents
yield {"event": "complete", "data": complete_plan}
return EventSourceResponse(event_generator())
Phase 2: Mobile App (React Native)
Farmers prefer mobile. Building:
- Offline calendar access
- Push notifications
- Camera for soil photo analysis
- Voice input (Hindi, Tamil, Telugu)
Phase 3: IoT Integration
Connect soil sensors and weather stations:
- Real-time moisture, pH, temperature
- Automated irrigation triggers
- Micro-climate data for better predictions
Try AgriPath Yourself
Live Demo: https://agripath-demo.run.app
Sample Request:
curl -X POST https://agripath-advanced-xxxxx.run.app/api/v1/generate-plan \
-H "Content-Type: application/json" \
-d '{
"farmer_id": "DEMO_001",
"location": {"district": "Lucknow", "state": "UP"},
"plots": [{
"plot_id": "DEMO_PLOT",
"size_acres": 5.0,
"soil_ph": 6.8,
"irrigation_available": true
}],
"resources": {
"labor_workers": 3,
"budget": 100000
},
"target_season": "rabi_2024"
}'
GitHub: github.com/yourusername/agripath-advanced
Why This Matters
In India:
- 140 million farmers
- 60% live below poverty line
- Average farm size: 1.08 hectares (2.7 acres)
If AgriPath helps just 1% of farmers increase profits by 50%, that's:
- 1.4 million farmers helped
- ₹50,000+ extra income per farmer per year
- ₹70 billion ($850 million) additional rural income
This isn't just a hackathon project. It's a mission to make farming profitable again.
Technical Deep Dives (For the Nerds)
Agent Prompt Engineering
Bad Prompt:
You are a calendar generator. Create activities for farming.
Good Prompt:
You are the `calendar_roadmap_generator_agent`.
<Steps>
1. For each crop, call get_crop_activity_schedule(crop_name)
2. Generate land prep 7 days before sowing
3. Calculate materials: seeds, fertilizers, pesticides
4. Generate irrigation based on weather forecast
5. Add fertilizer on specific days (21, 45, 75)
6. Generate harvesting activity
7. Sort by date
8. Validate budget constraint
</Steps>
<Example>
Input: {"crop": "wheat", "area": 5.0, "sowing_date": "2024-12-10"}
Output: {
"activities": [
{
"date": "2024-12-03",
"type": "land_preparation",
"materials": [...],
"instructions": [...]
}
]
}
</Example>
<MaterialCalculations>
Wheat per acre:
- Seeds: 40kg @ ₹62.5/kg
- DAP: 60kg @ ₹40/kg
- Urea: 50kg @ ₹15/kg
</MaterialCalculations>
Pydantic Schema Design
# Bad: Loose typing
def generate_plan(input: dict) -> dict:
# What's in input? What's in output?
pass
# Good: Strict typing
class PlotInfo(BaseModel):
plot_id: str
size_acres: float = Field(gt=0, le=100)
soil_ph: float = Field(ge=4.0, le=9.0)
irrigation_available: bool
@validator('soil_ph')
def validate_ph(cls, v):
if not 5.5 <= v <= 8.0:
raise ValueError("Optimal pH range: 5.5-8.0")
return v
class AgriPathInput(BaseModel):
farmer_id: str
location: LocationInfo
plots: List[PlotInfo] = Field(min_items=1, max_items=5)
resources: ResourceInfo
target_season: str
preferences: Optional[PreferenceInfo]
def generate_plan(input: AgriPathInput) -> AgriPathOutput:
# Now we have full type safety!
pass
BigQuery Query Optimization
# Before: Slow query (15s)
SELECT * FROM cultivation_records
WHERE soil_ph BETWEEN 6.0 AND 7.5
# After: Fast query (0.8s)
CREATE INDEX idx_soil_ph ON cultivation_records(soil_ph)
SELECT
crop_name,
AVG(yield_per_acre) as avg_yield,
COUNT(*) as records
FROM cultivation_records
WHERE soil_ph BETWEEN 6.0 AND 7.5
GROUP BY crop_name
HAVING COUNT(*) >= 10
ORDER BY avg_yield DESC
LIMIT 10
Acknowledgments
This project wouldn't exist without:
- Google Cloud Team - Cloud Run's generous limits made this possible
- Google ADK Team - Clean abstractions, great docs
- Gemini Team - Fast, affordable, powerful models
- My Uncle - For inspiring this with his radish farming story
- Agricultural Extension Officers - For crop cultivation data
- Indian Farmers - The real heroes who feed 1.4 billion people
Final Thoughts
Building AgriPath taught me that AI's biggest impact isn't replacing humans—it's giving them superpowers.
Farmers have decades of experience. They don't need AI to tell them radish grows in 60 days. They need AI to:
- Analyze 10,000 cultivation records in seconds
- Predict price crashes using historical data
- Generate 185 activities with exact materials
- Calculate ROI for different scenarios
- Find government subsidies they didn't know existed
That's the promise of AI: augmenting human expertise, not replacing it.
If you're building with Google Cloud Run or ADK, I hope this deep dive helps. And if you know any farmers, please share AgriPath with them. Let's make farming profitable again, one plan at a time.
Built with ❤️ for farmers
#CloudRunHackathon #GoogleADK #AIForGood
Comments?
What do you think? Have you built multi-agent systems? Any questions about the staggered planting algorithm or Cloud Run deployment?
Drop your thoughts below! 👇
P.S. If you're participating in the Google Cloud Run Hackathon, good luck! Focus on solving real problems, not showcasing tech. The best projects are the ones that actually help people.
P.P.S. Star the repo if you found this useful: github.com/yourusername/agripath-advanced ⭐
Top comments (0)