background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

Provider account pools for new sessions (random allocation)

Open open-inspect opened this issue 1 month ago • 0 comments

Follow-up from #2023, which was closed. Its running-session switching protocol needs a redesign, but provider account pools for new sessions don't depend on that work and can land on their own.

Goal

Let an admin pick, per provider, either a fixed default account (today's behavior) or a pool of accounts that new sessions are allocated from at random.

Proposed shape

  • Storage: extend the existing ProviderDefaultStore (db/provider-account-defaults.ts) with a selection mode and a pool membership table, instead of adding a parallel routing store.
    • Add a new D1 migration (0095 or later) with no triggers, so it passes the SQL-portability gate. Enforce account eligibility in the store.
    • Cap the pool size, or batch the queries, to stay under D1's 100-bind limit. Add a max-size D1 test.
  • Allocation:
    • Port the roughly 60-line random draw from #2023's provider-account-resolution.ts.
    • Keep the draw stable when a session create is retried, by reusing the existing binding for that session ID.
    • Child sessions inherit through the existing inherited_from_session_id path.
  • API: add routing GET/PUT routes, with route-catalog and admission-matrix entries.
  • UI: offer "random" in settings only when the server reports support for it.
  • Rollout: add a PROVIDER_ACCOUNT_RANDOM_ENABLED Terraform variable and a Worker binding.

Out of scope

Binding revisions, the issuance fence, account-switch tables, runtime changes, the session-switching UI, and switch recovery.

Notes

  • The Codex harness supports openai + provider_account. Make sure allocation covers it, and that the Codex OpenAI broker (#2347) issues credentials from the allocated account.
  • Rough size: 3–5 engineer-days, about 1,000–1,400 lines including tests.

open-inspect avatar Oct 29 '26 07:10 open-inspect