Weather Agent
Weather agent with OpenWeatherMap integration
The weather-agent template is a small tool-calling agent that answers natural-language weather questions using the free Open-Meteo API - no weather API key required. It ships two workflows over the same underlying data: one returns typed data for programmatic use, the other routes through the agent for a conversational answer.
What you’ll build
- A
get_weather_datatool that geocodes a location and fetches current conditions from Open-Meteo - A
weather_agentthat answers questions like “what’s the weather like in Tokyo?” using that tool - A
get_weatherworkflow that returns structured, typedWeatherDatadirectly (no LLM) - A
get_weather_interactivechat workflow that routes the same request through the agent for a natural-language reply
Requirements
- Python 3.12+ or Node.js 22+
OPENAI_API_KEY- The AGNT5 CLI
- No weather API key - Open-Meteo is free and keyless
Install
curl -LsSf https://agnt5.com/cli.sh | bashSetup
Scaffold the project
agnt5 create —template python/weather-agent my-weather-agent
cd my-weather-agentagnt5 create —template typescript/weather-agent my-weather-agent
cd my-weather-agentSet environment variables
cp .env.example .envInstall dependencies
uv syncpip install -e .npm installStart the AGNT5 dev server
agnt5 dev upHow it works
A single data function accepts a city name, coordinates, or postal code, geocodes it, and calls Open-Meteo for current conditions - this one function backs both workflows. The structured workflow calls it directly and returns the typed result, useful for dashboards or pipelines that don’t need natural language. The chat workflow instead runs the weather agent, which decides when to call the same data function as a tool and how to phrase the answer.
Passing the workflow’s context into the agent call means every model turn and every tool call checkpoints through the workflow’s durable context - a crash mid-conversation resumes cleanly instead of re-issuing the request.
Both workflows share the same tool and data layer - pick the structured workflow for programmatic callers and the chat workflow for anything conversational.
Key files
app.py - Worker entry point
src/weather_agent/workflows.py - get_weather (structured) and get_weather_interactive (chat)
src/weather_agent/agents.py - the weather_agent definition and its instructions
src/weather_agent/functions.py - get_weather_data: geocode-and-fetch logic against Open-Meteo
src/weather_agent/tools.py - the tool wrapper the agent calls
src/weather_agent/models.py - the WeatherData result typeapp.ts - Worker entry point
src/workflow.ts - getWeather (structured) and getWeatherInteractive (chat)
src/agents.ts - createWeatherAgent(): builds the agent with its tool and instructions
src/functions.ts - getWeatherData: geocode-and-fetch logic against Open-Meteo
src/tools.ts - getWeatherDataTool: the tool wrapper the agent calls
src/models.ts - the WeatherData result typeCustomize
Swap the model. The agent’s model is set in agents.py. Change it to another provider’s model string and set the corresponding API key.
Add a forecast tool. Register a get_forecast function alongside get_weather_data, add it to the agent’s tool list, and the same loop handles it.
Change the response style. The agent’s instructions in agents.py control tone and format - tighten them for terser answers or broaden them for multi-day comparisons.
Next steps
- Read /docs/build/agents for the agent execution model
- Try coding_agent for a multi-tool agent with sandboxed execution
- Look at hitl_deep_research to see the workflow pattern for planned research with a human checkpoint