AWS Builder Center

Can the kids play outside today? Building a school air-quality advisor with Strands Agents

School AQI Advisor turns air-quality estimates into a clear Go ahead, Modify or Move indoors verdict for each school activity, in English and Hindi. Built for the Environmental Hacks Air track with Python, Streamlit and the Strands Agents SDK, where deterministic code makes the decision and the AI explains it.

The problem

On a bad-air day, a principal or a parent faces a simple question: should the children go out for assembly, sports or the commute today?
Raw pollutant numbers such as "PM2.5: 87 µg/m³" don't answer that. Most people can't interpret them, so the decision falls back on a vague WhatsApp forward or guesswork. For the Air track of Environmental Hacks, I wanted to close that gap with a tool that gives a clear, activity-specific answer.

What I built

School AQI Advisor is a Streamlit web app. You pick a quick-select city or search any Indian locality, and it shows:
  • An estimated Indian AQI badge, colour-coded from Good to Severe
  • A verdict for each school activity: ✅ Go ahead, ⚠️ Modify, or 🏠 Move indoors, for outdoor assembly, sports, classroom activities and the school commute
  • A school-day timeline: hourly verdicts from 7 AM to 4 PM, with the safest two-hour window highlighted
  • A 48-hour forecast chart of estimated AQI
  • An asthma / vulnerable-children mode that makes every verdict one level stricter
  • A copy-ready WhatsApp message for parents, in English or Hindi
  • An "Ask the advisor" box for questions like "Can my son with asthma play cricket at 4 PM?"
  • A full Hindi interface

The key design decision: code decides, AI explains

It's tempting to hand everything to an LLM. For a decision about children's health, I didn't want a language model deciding anything.
So the project is split in two:
Part
Who does it
AQI calculation from PM2.5 and PM10
Plain Python, using CPCB-style breakpoints
Verdict for each activity
A fixed rule table in verdicts.py
Best two-hour window
Deterministic code
Plain-language explanation and Q&A
The AI agent, which cannot change the verdict
The AI layer is a Strands Agents SDK agent, powered by Gemini 2.5 Flash. It has four tools: current air quality, forecast, AQI calculation and activity verdict. When a user asks a question, the agent must call the tools, use only the values they return, and quote the verdict unchanged. If the AI is unavailable, the badge, verdicts, timeline and parent message still work, and static precautions are shown instead.
The verdict rules are visible in the app under "How verdicts are decided", so anyone can see why a result came out the way it did.

What fought back

  • A gap in the AQI bands. My first breakpoint table had bands like 0–30 and 31–60, so a reading of 30.5 matched nothing and returned no AQI. That could silently understate the result or crash the verdict step. I fixed the lookup to handle values between bands and cap values above the top band, and added tests for every boundary.
  • Stale advice on screen. If someone generated AI guidance and then changed the activity or language, the old text stayed visible and could contradict the new verdict. I now store each answer with the inputs that produced it and show it only when they match.
  • Streamlit quirks. A "Clear search" button crashed the page because a widget's value can't be changed after it's drawn, so it now uses a callback. The timeline chips first stacked vertically until I rendered them as one HTML block.

Honest limitations

I tried to make the app clear about what it doesn't know:
  • Values are model estimates from Open-Meteo, not station readings.
  • The badge is an instant estimate from the current hour. The official CPCB AQI uses 24-hour averages, so numbers can differ.
  • Results are for the selected locality, not an individual school.
  • The verdicts are project rules, not official or medical guidance. The thresholds are deliberately conservative.
  • The tool supports a decision. It is not a school-closure order, and users should follow official advisories.

What's next

  • Blend in nearest-station readings from CPCB or OpenAQ
  • Saved school locations
  • Automatic morning alerts to parent groups
  • Amazon Bedrock as the default model, since Strands supports it

Try it

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article