## TL;DR
Split gathering from writing and checkpoint the gathered data URIs the report failed at the writing stage because its credential died during a long gather, and the whole job had to restart. Fetch all source data first into local files, then generate the report from the files with no live calls, so credential lifetime only needs to cover the gather, and a failed write can retry from the snapshot.

```text
auth token expired mid-result summary and the report generation failed with an authentication error
```

## Use this when
- The run or call fails with this symptom: auth token expired mid-result summary and report generation failed with an authentication error.
- You are working on an agent producing result summary reports from tracker data and the failure repeats on the same run or configuration.
- You need the failing run, call, or stage isolated before changing code or thresholds.

## Not for this skill when
- A report that must include data fresh to the minute, where the fix is renewing the credential before the final fetch rather than snapshotting early.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Determine where generation failed by checking which source fetches completed and which the report still needed. Verify: the failure point in the pipeline is located
2. Restructure the job: gather everything to local snapshot files first, each fetch confirmed as it lands. Verify: a complete local dataset exists before writing starts
3. Generate the report purely from the snapshots, embedding the snapshot time in the report. Verify: the report builds with no live API calls
4. Add a pre-gather expiry check so a credential near expiry is renewed before the gather begins. Verify: gathers start with a credential that outlives them

## Variant phrasings
### token expired mid result summary report generation auth error agent
The verbatim phrasing.
### agent report failed authentication expired snapshot gather fix
The snapshot phrasing.
### experiment summary report 401 generation stage agent
The generation-stage phrasing.

Compatibility: Agent report generation over trackers with expiring credentials

## Why it happens
Long reports spend most of their time gathering, so a credential sized for quick calls expires before the writing stage makes its own calls. Snapshotting decouples the report's fate from credential lifetime and makes generation reproducible from the same inputs.

## Edge cases / pitfalls
- Snapshots make the report's data auditable later; keep them with the report's working files.
- A gather that itself outlives the credential needs per-source resume, the same manifest pattern as backfills.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_Uo0OcWV2wXbWpS_fGQ8dzw
