Skip to content

Add 429 retry/backoff to Grain API client - #7

Draft
dplakon wants to merge 1 commit into
mainfrom
fix/grain-429-retry
Draft

Add 429 retry/backoff to Grain API client#7
dplakon wants to merge 1 commit into
mainfrom
fix/grain-429-retry

Conversation

@dplakon

@dplakon dplakon commented Jul 27, 2026

Copy link
Copy Markdown

Summary

While running the daily Grainiac orchestrator to process today's meetings, scripts/fetch_daily_meetings.py consistently failed with HTTP Error 429: Too Many Requests. The first page of /recordings succeeded, but the immediately-following cursor request was rate-limited — Grain throttles bursts of requests during rapid pagination. The client had no retry/backoff, so the whole fetch aborted.

Change

  • Add a shared _request helper in scripts/grain_client.py that retries 429 responses with exponential backoff, honoring the Retry-After header when the server provides one.
  • Route both _get (list/detail) and get_transcript_text through the helper so pagination and transcript fetches are both resilient.
  • Retry count and base backoff are configurable via GRAINIAC_GRAIN_MAX_RETRIES (default 5) and GRAINIAC_GRAIN_BACKOFF_SECONDS (default 2).

Verification

After the change, the fetch completed successfully: pagination retried each transient 429 once and scanned all 2000 recent recordings. For 2026-07-26 there were 0 external customer meetings, so no child agents were spawned (per the orchestrator skill).

Conversation: https://app.warp.dev/conversation/fd71ff24-6c87-4f71-9517-92864b8876f1
Run: https://oz.warp.dev/runs/019fa1f1-bf28-7cea-a5e4-d2f9c50f36c9

This PR was generated with Oz.

Grain throttles bursts of requests during rapid pagination, causing the
daily meeting fetch to fail with HTTP 429 on the second page. Wrap all
Grain HTTP calls in a shared _request helper that retries 429 responses
with exponential backoff, honoring the Retry-After header when present.
Retry count and base backoff are configurable via env vars.

Co-Authored-By: Oz <oz-agent@warp.dev>
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