## TL;DR
A profiling run outlives its credential when profiling is slow, so the fix is the same pattern as any mid-run expiry, applied to profiling: refresh the credential automatically, profile schema by schema with stored results, and let the run resume after a refresh instead of restarting. Profiling's long tail of small queries makes it the run type most likely to cross a credential lifetime.

```text
auth token expired mid-warehouse profiling run error agent failed
```

## Use this when
- The check or run fails with this symptom: the profiling run fails partway when its authentication expires.
- You are working on an agent warehouse profiling run failing on an expired credential and the failure repeats on the same data or configuration.
- You need the failing rows, rule, or stage isolated before changing thresholds or code.

## Not for this skill when
- A profiling run that fails at its first query on a wrong credential, which is configuration rather than expiry instead.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Compare the credential lifetime with the profiling run's duration history to confirm the expiry theory. Verify: lifetime and duration are compared with data
2. Locate the credential source and confirm whether the deployment offers automatic refresh or workload identity. Verify: the refresh options for this deployment are known
3. Wire refresh into the profiling runner, triggered ahead of expiry, and test it on a shortened lifetime setting if available. Verify: refresh is wired and tested
4. Store each schema's profile as it completes so an interruption resumes mid-run. Verify: profiles persist per schema during the run
5. Run a full profiling pass longer than the original lifetime and confirm it completes across a refresh. Verify: the long pass completes with all schemas profiled

## Variant phrasings
### auth expired mid warehouse profiling run agent
The verbatim profiling-expiry phrasing, with the credential named generically.
### warehouse profiling credential refresh resumable agent
The refresh phrasing for long profiling runs.
### agent profiling authentication failed partway through schemas
The partway phrasing for per-schema progress.

Compatibility: Agent warehouse profiling runs using cloud IAM or warehouse credentials

## Why it happens
Profiling touches every schema with many small queries, so its wall-clock time grows with the warehouse, while credential lifetimes stay fixed by policy. The crossing point is inevitable as the warehouse grows, which is why refresh and resumability, not longer lifetimes, are the durable fix.

## Edge cases / pitfalls
- Estimate run duration from the last run and warn before starting a run that cannot finish without refresh.
- Profile changed schemas first so the most valuable results land earliest in the run.

## Provenance

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