auth token expired mid-renewal-forecast run: agent failed to refresh credentials
Fixes an agent whose credentials expire mid-renewal-forecast run by adding pre-flight credential checks, in-run refresh, and resumable forecast batches. Use when forecast runs fail partway on authentication. Not for a forecast run failing on data errors.
TL;DR
Forecast runs are long and batchy, so they hit credential expiry exactly like scoring runs do, but with a twist: a half-built forecast is worse than none because it looks complete. Check credential lifetime before starting, refresh at batch boundaries, stamp every forecast row with its run id, and publish the forecast only when the run completes, so partial work never poses as the forecast.
auth token expired mid-renewal-forecast run: agent failed to refresh credentialsUse this when
- Authentication errors appear in the later portion of forecast runs
- Partial forecasts have been mistaken for final ones
- Credential lifetime is shorter than the full run
Not for this skill when
- The forecast job's credentials were revoked after a personnel change
- Failures begin immediately, indicating wrong credentials rather than expiry
Steps
- Compare credential lifetime against the run's duration history. Verify: the expiry collision is confirmed with numbers
- Add a pre-flight check that estimates run length and refuses to start if credentials cannot be refreshed in-run. Verify: doomed runs no longer start
- Implement refresh at batch boundaries and run-id stamping on every written row. Verify: a long test run crosses expiry cleanly and its rows are traceable
- Publish via a completion marker: consumers read only runs marked complete. Verify: partial runs become invisible to forecast consumers by construction
- Alert separately on refresh failure with the run id and last completed batch. Verify: a credential incident arrives with its resume point attached
Variant phrasings
forecast run credentials expire midway
A related phrasing for the same underlying problem.
partial forecast mistaken for complete
A related phrasing for the same underlying problem.
refresh auth in long agent run
A related phrasing for the same underlying problem.
Compatibility: Compatibility: OAuth-backed CRM and warehouse access from scheduled agent jobs, current versions.
Why it happens
The expiry is predictable; the dangerous part is silent partial output. Run-id stamping plus a completion gate separates work-in-progress from published truth, which matters more for forecasts than for most data because executives act on them the same morning.
Edge cases / pitfalls
- Do not delete partial rows before the resumed run finishes; they are the resume map.
- Completion markers must be written by the runner, never inferred from row counts.
- If refresh requires human interaction in your setup, that is a design flaw to fix with a proper service credential, not a runbook step.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_hMbp8no4QvQr4YLcU3M5pg