You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provider: Anthropic (claude-opus-4-6, claude-sonnet-4-6) via OAuth
Setup: Multi-topic Telegram bot with subagent orchestration
Describe the bug
OpenClaw maintains OAuth credentials for Anthropic in auth-profiles.json, but these credentials desync from ~/.claude/.credentials.json (the source of truth updated by openclaw models auth login and Claude CLI). When the token in auth-profiles.json expires and its refresh token has been invalidated (because ~/.claude/ already used a newer refresh), all subagent completions fail silently.
The gateway stays alive, openclaw status looks healthy, but subagent announce calls fail with:
OAuth token refresh failed for anthropic: Failed to refresh OAuth token for anthropic. Please try again or re-authenticate.
This is particularly insidious because:
The main session may work fine (using a different auth path or cached token)
Subagent spawns succeed (task is accepted)
Only the completion announce fails — the result is computed but never delivered
The subagent is then pruned as orphan: Subagent orphan run pruned ... reason=missing-session-entry
From user perspective: subagent "silently disappears" with no error message
Steps to reproduce
Authenticate Anthropic via OAuth (openclaw models auth login)
Tokens saved in both ~/.claude/.credentials.json AND auth-profiles.json
Wait for token expiry (~2-10 hours depending on grant)
~/.claude/.credentials.json gets refreshed (by CLI or auto-refresh)
auth-profiles.json still has the OLD refresh token (now invalidated by Anthropic)
Spawn a subagent via sessions_spawn
Subagent completes the task successfully
Announce back to parent session fails with OAuth 401
After retries, system gives up: Subagent announce give up (retry-limit)
No user-visible error. Result is lost.
Root cause
Two independent credential stores with no automatic sync:
~/.claude/.credentials.json — updated on login/refresh
~/.openclaw/agents/<id>/agent/auth-profiles.json — used by gateway for model calls
When Anthropic rotates the refresh token (standard OAuth behavior — old refresh is invalidated when a new one is issued), the auth-profiles.json copy becomes permanently broken until manual intervention.
Additional context
Multiple agents (main, hr-bp, etc.) each have their own auth-profiles.json, all needing sync. With N agents, the desync probability multiplies.
Workaround
We wrote a systemd timer that syncs ~/.claude/.credentials.json → all auth-profiles.json every 30 minutes and alerts when expiry < 1 hour. Happy to share the script.
Proposed fix
Single source of truth: auth-profiles.json should be the canonical store, and refreshOAuthTokenWithLock should update it atomically on every refresh
Cross-store sync: When ~/.claude/.credentials.json is updated, propagate to all agent auth-profiles.json (or read from a single location)
Announce resilience: If OAuth fails during subagent announce, surface the error to the parent session instead of silently pruning
Environment
Describe the bug
OpenClaw maintains OAuth credentials for Anthropic in
auth-profiles.json, but these credentials desync from~/.claude/.credentials.json(the source of truth updated byopenclaw models auth loginand Claude CLI). When the token inauth-profiles.jsonexpires and its refresh token has been invalidated (because~/.claude/already used a newer refresh), all subagent completions fail silently.The gateway stays alive,
openclaw statuslooks healthy, but subagent announce calls fail with:This is particularly insidious because:
Subagent orphan run pruned ... reason=missing-session-entrySteps to reproduce
openclaw models auth login)~/.claude/.credentials.jsonANDauth-profiles.json~/.claude/.credentials.jsongets refreshed (by CLI or auto-refresh)auth-profiles.jsonstill has the OLD refresh token (now invalidated by Anthropic)sessions_spawnSubagent announce give up (retry-limit)Root cause
Two independent credential stores with no automatic sync:
~/.claude/.credentials.json— updated on login/refresh~/.openclaw/agents/<id>/agent/auth-profiles.json— used by gateway for model callsWhen Anthropic rotates the refresh token (standard OAuth behavior — old refresh is invalidated when a new one is issued), the
auth-profiles.jsoncopy becomes permanently broken until manual intervention.Additional context
Multiple agents (
main,hr-bp, etc.) each have their ownauth-profiles.json, all needing sync. With N agents, the desync probability multiplies.Workaround
We wrote a systemd timer that syncs
~/.claude/.credentials.json→ allauth-profiles.jsonevery 30 minutes and alerts when expiry < 1 hour. Happy to share the script.Proposed fix
auth-profiles.jsonshould be the canonical store, andrefreshOAuthTokenWithLockshould update it atomically on every refresh~/.claude/.credentials.jsonis updated, propagate to all agentauth-profiles.json(or read from a single location)Related issues