Skip to content

Expand weather tool to comprehensive multi-day forecast with full metrics#270

Merged
alexkroman merged 1 commit into
mainfrom
claude/focused-ritchie-e3jhvj
Jun 23, 2026
Merged

Expand weather tool to comprehensive multi-day forecast with full metrics#270
alexkroman merged 1 commit into
mainfrom
claude/focused-ritchie-e3jhvj

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Summary

Transforms the weather tool from a minimal single-sentence report (current temperature + 2-day outlook) into a comprehensive, multi-line forecast that surfaces every field an LLM might need to answer follow-up questions. The report now spans 7 days and includes full current conditions (feels-like temperature, humidity, precipitation amount & probability, wind speed/direction/gusts, cloud cover, pressure, day/night indicator) plus detailed daily outlooks (high/low temps, conditions, precipitation, wind, UV index, sunrise/sunset).

Key Changes

  • Expanded forecast scope: 7-day forecast (today + 6 days) instead of 3 days, with all daily arrays now requested from Open-Meteo
  • Comprehensive current conditions: Added apparent temperature, humidity, precipitation, cloud cover, wind direction/gusts, pressure, and day/night indicator
  • Multi-line report format: Changed from space-separated single sentence to newline-delimited blocks:
    • Current conditions block (4 lines covering temperature, humidity/cloud/precipitation, wind, pressure)
    • One line per forecast day with all relevant metrics
  • Wind direction support: New describe_wind_direction() function converts bearings to 16-point compass names (N, NNE, NE, etc.)
  • Geocoding enhancement: _geocode() now returns country name (or None) as part of the location tuple, displayed in the report
  • Helper utilities: Added _num() for clean decimal rendering (drops trailing .0) and _local_time() to extract HH:MM from ISO timestamps
  • Robust daily-row handling: New _daily_rows() function transposes Open-Meteo's parallel arrays into per-day mappings, with ragged-array protection (shortest required field bounds row count)
  • Refactored formatting: Split report generation into _format_current() and _format_day() for clarity and testability

Implementation Details

  • All temperatures rendered in both Celsius and Fahrenheit (°F = round(c * 9/5 + 32))
  • Metric units throughout: km/h for wind, %, mm for precipitation, hPa for pressure
  • Wind direction computed as round(degrees / 22.5) % 16 to index the 16-point compass
  • Ragged-array safety: if Open-Meteo drops a trailing value, only complete days render (no IndexError)
  • Country field in geocoding result is optional (None when not present in API response)
  • Report structure designed for agent to read aloud only the slice the conversation calls for; full data available for follow-ups

Testing

  • Comprehensive test coverage for new functions (describe_wind_direction, _num, _local_time, _daily_rows)
  • Updated _FORECAST fixture with full current/daily field sets
  • Exact-match assertion on rendered report (_EXPECTED_REPORT) pins every field, rounding, and unit conversion
  • Tests verify ragged-array handling, country-optional rendering, and day/night detection
  • Compass table pinned to catch reordering or mutations

https://claude.ai/code/session_01GfS9w6EyrSFbVQhthm4MCt

The `get_weather` live tool requested only the current temperature/weather
code and a max/min/code daily outlook, then rendered a single spoken
sentence — leaving the LLM unable to answer follow-ups about humidity,
wind, precipitation chance, UV, sunrise/sunset, etc.

Request the full relevant Open-Meteo series and render a comprehensive,
labelled multi-line report the agent can draw on:

- Current: temperature + feels-like (both units), humidity, cloud cover,
  precipitation, wind speed/direction/gusts, pressure, day/night.
- Daily (7 days): high/low (both units), condition, precipitation amount +
  probability, max wind/gusts/direction, UV index, sunrise/sunset.

Surface the geocoded country and add a 16-point compass helper for wind
direction. The agent still reads aloud only the slice a turn calls for; the
rest is there when the conversation drills in.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GfS9w6EyrSFbVQhthm4MCt
@alexkroman alexkroman enabled auto-merge June 23, 2026 19:32
@alexkroman alexkroman disabled auto-merge June 23, 2026 19:32
@alexkroman alexkroman enabled auto-merge June 23, 2026 19:32
@alexkroman alexkroman added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 8c67fab Jun 23, 2026
20 checks passed
@alexkroman alexkroman deleted the claude/focused-ritchie-e3jhvj branch June 23, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants