Skip to content

Feature: Global session reset on auth switch #8190

Description

@lancejames221b

Problem

When switching auth backends or API keys (e.g., switching between different Claude API accounts, OpenRouter, or other providers), each session caches its auth at creation time. This means:

  1. Config change applies to gateway
  2. Gateway restarts with new auth
  3. Existing sessions still use old cached auth
  4. User must manually /reset each active session (WhatsApp, Slack, Telegram, etc.)

This creates friction for users with multiple active channels who need to switch auth globally.

Proposed Solution

Add a gateway action=reset-sessions (or similar) that:

  1. Invalidates all active session auth caches
  2. Sessions reinitialize with current config auth on next message
  3. Preserves session memory/context across the reset (see below)
  4. Can be triggered as part of auth/config changes

Session State Preservation

When resetting sessions for auth switching, the conversation context should be preserved. Options:

  1. Export/restore session state: Before reset, serialize session context (recent messages, current topic, pending tasks) to a recoverable format. On reinit, restore from that state.
  2. Soft reset: Only invalidate the auth cache without clearing conversation history — session continues with same context but new auth credentials.
  3. Channel-specific restore:
    • Slack: Can read recent channel history via API on reinit
    • Other channels: Need explicit state export before reset

The goal: auth switch should be seamless — user doesn't lose conversation context or have to re-explain what they were working on.

Alternative Approaches

  1. Auth per-request: Sessions check auth on each API call instead of caching at creation (more overhead, but no reset needed)
  2. Auth invalidation signal: Gateway restart broadcasts "re-auth" event to all sessions (sessions keep context, just refresh auth)
  3. /reset-all chat command: Resets all sessions globally with optional context preservation flag

Use Case

User: switch to openrouter
Agent: [patches config, restarts gateway, resets all sessions with context preserved]
Agent: ✅ Switched to OpenRouter. All sessions updated.
# Conversation continues seamlessly

One command, global effect, no manual /reset per channel, no lost context.

Additional Context

  • Useful for switching between API providers (Anthropic direct, OpenRouter, AWS Bedrock, etc.)
  • Useful for switching between subscription tiers or accounts
  • Session context preservation is critical for good UX — users shouldn't have to re-establish context after an auth switch

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper-recovery-stuckclawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.enhancementNew feature or requestimpact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions