Skip to content

[Feature]: fair session ring across Anthropic OAuth, API keys, and Codex API pools #8178

Open

Description

@vibewriter-hand

Area

Authentication and account pool

What are you trying to accomplish?

We want fair, session-pinned rotation for new sessions across Anthropic OAuth accounts, Anthropic API-key pool entries, and Codex pool accounts. One session should stay on one credential while new sessions are spread evenly. This should work for Claude Code and Codex API clients.

What prevents this today?

Round-robin chooses a new account per request, and affinity only binds after a session key exists. There is no shared ring that assigns new sessions fairly and keeps each session pinned across the Anthropic OAuth pool, single-key Anthropic providers, and the Codex pool. Existing pieces are partial:

We run a local anthropic-session-ring patch for the Anthropic side and want to retire it once upstream provides the behavior.

What should OpenCodex do?

Add an opt-in per-provider session ring:

  • Maintain an ordered ring of eligible credentials.
  • Assign each new session to the next eligible credential.
  • Keep the session on that credential across turns and proxy restarts.
  • On a credential failure, cooldown, pause, reauthentication, or removal, advance the ring and rebind once.
  • Preserve existing bindings and quota rules.
  • Include Anthropic OAuth accounts, Anthropic API-key pool entries, and Codex pool accounts (Codex API/Responses).
  • Use a bounded idle TTL and entry cap.
  • Expose the selected credential and ring position in request logs or diagnostics.

Example usage or interface

{
  "providers": {
    "anthropic": {
      "sessionRing": { "enabled": true, "idleTtlMs": 86400000 }
    },
    "codex": {
      "sessionRing": { "enabled": true, "idleTtlMs": 86400000 }
    }
  }
}
ocx account pool anthropic --session-ring on
ocx account pool codex --session-ring on

Alternatives or workarounds

Round-robin without a ring moves a session between accounts. Affinity alone does not spread new sessions fairly across credential types. Running one credential per proxy instance avoids the problem but loses pool capacity.

Additional context

Related: #3375 (generic OAuth pool lifecycle), #7738 (API-key cache affinity), #8098 (Codex pool pins across restart), #8092 (round-robin quota headroom), #7813 (Anthropic affinity persistence). This request is the fair ring plus one-session-one-credential contract, including Codex API.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. coderabbitai commented on Nov 5, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7828 - fix(anthropic): keep pool session affinity across restarts and transient detours [merged]
    #8094 - fix(claude): bind header-less Messages bridge turns to one Codex pool account (carry #8028) [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolOAuth, credentials, Codex pool, quota, failover, plansenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions