Coalesce auth model-fallback decision logs
Reduced repeated OpenClaw model-fallback warning spam for expired-token auth failures by coalescing matching decision logs while keeping first-occurrence diagnostics and fallback routing unchanged.
openclaw/openclaw · #94233
Problem
When an auth provider token expired, repeated model fallback attempts could emit many identical model-fallback/decision warnings for the same requested model, candidate, next candidate, and auth error. That increased log volume, made useful diagnostics harder to find, and added unnecessary operator noise.
Approach
Added a 30-second coalescing window for eligible auth/auth_permanent candidate_failed and skip_candidate decisions, keyed by session or run scope, requested model, candidate, next candidate, error identity, fallback flags, and attempt metadata. Later matching warnings summarize suppressed duplicates without changing fallback behavior.
Impact and scope
- Improves operator observability by quieting duplicate expired-token fallback warnings while preserving the first useful diagnostic record.
- Reduces log-volume and disk-I/O pressure during repeated auth-provider failures without changing provider routing, retries, cooldowns, or tool execution.
- Keeps diagnostic precision by leaving distinct sessions, candidate models, no-session runs, non-auth failures, and success decisions uncoalesced.
Validation
- Added focused Vitest coverage for duplicate auth failure coalescing, stale counter cleanup, distinct candidate/session/run scoping, skip-candidate auth cooldown coalescing, and non-auth/success decisions staying visible.
- Validated the logger path with a local OpenClaw harness showing two immediate duplicate warnings suppressed and summarized on the next emitted matching warning.
- PR validation covered model-fallback tests, oxlint, tsgo, build-all, and git diff checks from the submitted workflow.