Repository navigation
Description
What happened
On PR #70, the post-fix re-review (run 42822485917, fullsend v0.54.0) was reviewing commit f73a7db. At 13:19:39 the runner logged OIDC token refresh failed: OIDC endpoint returned HTTP 504. About two minutes later (13:21:41) model calls retried twice with cloud_credential_error and then failed with invalid_grant: ID Token ... is stale to sign-in. The agent never wrote output/agent-result.json, so validation failed with FAIL: output/agent-result.json not found. The run spent $2.92 and posted nothing. Its correctness sub-agent had already produced a valid new finding. The repo owner had to notice and send /fs-review 6 minutes later. That review ($3.75) was then pre-empted by the merge, so the final head never received a posted review.
In the code (internal/cli/run.go, runOIDCRefresh / refreshOIDCToken, the same on main and v0.54.0), the refresh runs on a fixed oidcRefreshInterval = 4 * time.Minute ticker. refreshOIDCToken makes a single GET, and any non-200 returns an error. On error, runOIDCRefresh only logs and waits for the next tick. GitHub OIDC tokens live about 5 minutes, so one failed tick leaves the credential stale for roughly 4 minutes, which is enough to kill the session. mintclient.MintToken / fetchOIDCJWT already got exponential backoff in #8276, but this refresh path did not.
What could go better
The OIDC endpoint is an external dependency with occasional 5xx responses (the same family as #8276's 503). A transient 504 should not cost a whole agent run. I am highly confident in the causal chain: the refresh failed, roughly one token lifetime later the token was reported stale, and the run died. The timestamps line up with a 4-minute tick and a 5-minute token. I am less sure whether every invalid_grant report (#7477, #750, #8859) comes from this same mechanism. Some may also involve cadence or iteration-boundary reuse. This proposal fixes one concrete gap that those issues don't name. Following the flakiness guidance, it is a production-path resilience fix, not a retry budget on agent runs.
Proposed change
In internal/cli/run.go, when refreshOIDCToken fails with a retryable error (HTTP 5xx, 429, network error or timeout), retry inside the same tick using exponential backoff with jitter (for example 2s, 4s, 8s, 16s, 32s). Cap the total retry window well below the token lifetime (for example about 60–90s). Reuse the backoff helper added to mintclient for #8276 if it can be shared. Consider shortening the 120s per-request client timeout so retries fit before expiry. Keep failing fast on non-retryable 4xx. Log each retry attempt and the final outcome so runs show refresh recovered after N attempts instead of a silent stale window. Add a unit test with a fake OIDC endpoint that returns 504 once and then 200, and assert the token file is updated within the same tick.
Validation criteria
(1) Unit test: a fake endpoint returning 504 then 200 produces a refreshed token without waiting for the next ticker interval. A non-retryable 401 is not retried. (2) Over the next 30 days of agent runs across repos using the release that contains the fix, grep the run logs for OIDC token refresh failed. Each occurrence should be followed by a logged recovery, with no invalid_grant ... stale failure within 5 minutes of it.
Related issues checked
Searched: OIDC token refresh 504 retry backoff; invalid_grant stale ID token review session; cloud_credential_error agent-result.json not found; credential refresh retry runOIDCRefresh
Considered: #7477, #8859, #8276, #6667, #750, #2783, #705
#7477 (open): same stale-token symptom mid-review; it suggests checking refresh cadence but does not identify the missing 5xx retry. This proposal refines it with the concrete cause. #8859 (open): stale token reused across validation iterations; proposes re-minting between iterations, a different gap. #8276 (closed/completed): added backoff only to mintclient's OIDC fetch, not to refreshOIDCToken; this is the uncovered sibling path. #6667: single-attempt post-completion mint, a different code path. #750, #2783, #705: older stale-token reports addressed by the initial-refresh and cadence work, not the per-tick retry.
Generated by retro agent from fullsend-ai/react-shopping-cart#70
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity