AWS Builder Center
Five Tools and a Docstring: A Grounded Bedrock Agent with the Strands Agents SDK

Five Tools and a Docstring: A Grounded Bedrock Agent with the Strands Agents SDK

I built an air-quality agent that answers "is Saturday's school sports day safe?" for Delhi-NCR. The hard part wasn't the model — it was making sure it could never invent an arrival time. Here's how Strands Agents on Amazon Bedrock turned five Python functions into a tool-grounded agent in about forty lines, and why I chose a Lambda Function URL over API Gateway.

Software Developer
Every October, crop-residue fires in Punjab and Haryana send smoke into Delhi. I built  SmokeTrace  to forecast where that smoke lands over the next 48 hours, by neighbourhood.
A map is useful. But the question people actually ask isn't "what is the smoke index for North Delhi" — it's "is Saturday's sports day in Noida safe?" That's a language question over numeric data, which is exactly what an agent is for.
It's also a question where a confidently wrong answer has a cost. If the agent invents an arrival time, a school holds a match outdoors in heavy smoke. So the design constraint came first: the agent must be structurally unable to make up a number.

Tools are just functions with docstrings

This is where the Strands Agents SDK earned its place. A tool is a decorated function, and its docstring is the schema:
Python
from strands import Agent, tool
@tool
def area_forecast(area: str) -> dict:
"""Smoke forecast for one Delhi-NCR area for the next 48 hours: alert level,
smoke arrival time, peak time (ISO, UTC), relative smoke index, top source
districts and the official advice text.
Args:
area: Area name or id, e.g. "Noida", "south-delhi", "Gurugram".
"""
q = area.lower().replace(" ", "-")
for r in load()["receptors"]:
if q in (r["id"], r["name"].lower().replace(" ", "-")):
return {k: r[k] for k in ("name", "level", "index", "arrival",
"peak", "top_sources")}
return {"error": f"Unknown area '{area}'. Call list_areas to see valid areas."}

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