Skip to content

fix: add retry with exponential backoff to weather MCP tool#222

Open
Ladas wants to merge 1 commit intomainfrom
fix/weather-tool-resilience
Open

fix: add retry with exponential backoff to weather MCP tool#222
Ladas wants to merge 1 commit intomainfrom
fix/weather-tool-resilience

Conversation

@Ladas
Copy link
Copy Markdown
Contributor

@Ladas Ladas commented Apr 8, 2026

Summary

  • Add requests.Session with urllib3.Retry strategy (3 retries, exponential backoff)
  • Retry automatically on 429, 500, 502, 503, 504 status codes
  • Increase timeout from 10s to 30s (configurable via WEATHER_REQUEST_TIMEOUT)
  • Catch RequestException and return user-friendly message instead of crashing
  • All params configurable: WEATHER_MAX_RETRIES, WEATHER_BACKOFF_FACTOR, WEATHER_REQUEST_TIMEOUT

Context

The weather tool calls external Open-Meteo APIs that frequently timeout from CI runners, causing E2E test failures across ALL kagenti PRs. The tool had no error handling — any failure crashed the entire tool call.

The weather tool calls external Open-Meteo APIs that can timeout or
return transient errors in CI environments. This caused E2E test
failures across all kagenti PRs.

Changes:
- Use requests.Session with urllib3 Retry strategy (3 retries,
  exponential backoff, retry on 429/5xx)
- Increase timeout from 10s to 30s (configurable via WEATHER_REQUEST_TIMEOUT)
- Catch RequestException and return user-friendly error instead of
  crashing — lets the LLM retry the tool call gracefully
- All retry params configurable via env vars (WEATHER_MAX_RETRIES,
  WEATHER_BACKOFF_FACTOR)

Signed-off-by: Ladislav Smola <lsmola@redhat.com>
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.

1 participant