fix(acp): go offline when Claude/Codex auth expires
Summary
- Classify headless
Authentication required(-32000) as a non-retryable auth error alongsideRe-authenticate/API Error: 401. - On auth expiry: dead-letter the turn, post a restart-needed notice, stop presence heartbeats, and publish presence
offlineso the agent stops looking live in the sidebar. - Document the recovery path in
buzz-acpREADME.
Fixes #3831
Test plan
- [x]
cargo test -p buzz-acp --lib auth_error - [ ] Run a managed Claude agent, force
claude auth logout(or expire creds), @mention it — expect channel notice + sidebar goes offline, no further online heartbeats - [ ] Re-login + restart harness — presence returns to online and mentions work again
Made with Cursor
@tlongwell-block @wesbillman @wpfleger96 mind taking a look when you get a chance?
Independent macOS managed-agent reproduction. The failure surfaced as:
Agent reported error (code -32000): Failed to authenticate: OAuth session expired and could not be refreshed
The current patch matches Re-authenticate, API Error: 401, and Authentication required, so this exact provider wording still appears to miss is_auth_error() and enter the generic requeue/backoff path. I observed repeated retries while the runtime continued to look available; the channel had no actionable reauthentication state.
Reauthenticating the Claude subscription and restarting the managed runtime restored turns.
Could this PR add a precise match and fail-first test for OAuth session expired and could not be refreshed (ideally constrained to AgentError / code -32000)? Suggested live acceptance:
- Expire subscription OAuth and mention the agent.
- One visible reauthentication notice; presence becomes offline/not-ready; no retry storm.
- Reauthenticate and restart.
- Presence returns online and one fresh mention produces exactly one turn.
This is the same user-facing failure as #3831, just a fourth message variant.
🔐 Codex Security Review
Status: review required for the current range.
The current range is
016310d3cc44688779a7d517a13d9cc8024ddfa8...a9b262fb056fb7f438e8a022c133580f628c972a. A new review must complete for this exact range. When manual authorization is required, a user with write access must comment exactly@buzz-security-review a9b262fb056fb7f438e8a022c133580f628c972ato authorize a new review. Any previous review applies only to its recorded range.