Skip to content

[FEATURE]: Per-session provider account selection without splitting conversation history #54136

Open

Description

@Scorpius86

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

For OpenCode V2, allow each session to select a specific saved account/credential for a provider, independently of the globally active account and independently of other sessions in the same project.

I searched existing issues. #51152 requests project/location-scoped selection, while #51410 requests credential activation through the plugin API. This request is specifically for session-scoped selection, including concurrent sessions in the same directory. Neither global activation nor a project-level binding covers that use case.

Use case

On one shared OpenCode server, with two authorized accounts for the same provider:

  • Chat A in a project uses OpenAI account A.
  • Chat B in the same project uses OpenAI account B.
  • Chat C uses a selected GitHub Copilot account.

If account A reaches its usage allowance, I want to manually switch Chat A to another authorized account and continue its existing conversation, without changing Chat B or Chat C. This is not a request to bypass provider policies or for automatic account rotation.

Requested behavior

  1. Persist an explicit provider-account binding on a session. Multiple sessions in the same project can bind different accounts of the same provider.
  2. Allow selecting or changing that binding in the UI and through the HTTP API/SDK, using a stable credential identifier where appropriate. Display the selected account label without exposing secrets.
  3. Changing the account preserves the session identity and conversation history; no export/import or separate history database is required.
  4. Session-bound requests must not change the provider's globally active account or affect unrelated sessions, including running background agents.
  5. Apply the binding consistently to model requests, retries, title generation and compaction wherever that provider is used. Define whether subagents inherit the binding or can explicitly override it.
  6. Restore the binding after reconnecting or restarting the server. If the selected credential is removed, unavailable or ambiguous, fail clearly rather than silently charging another account.
  7. Account-specific model discovery, endpoints and OAuth refresh should use the selected credential, especially for Copilot personal/enterprise accounts.
  8. Define safe switching behavior for an in-flight turn and invalidate account-bound provider continuation/cache identifiers when necessary, while preserving the durable conversation history.

For example, an API could expose a session-level provider-to-credential mapping, with precedence of explicit session binding over project binding (if introduced) over the existing global default. The exact schema is up to maintainers.

Why profiles alone are insufficient

Separate server profiles/databases isolate accounts but split the history. The goal here is a single durable session history with independent credential selection, usable by the TUI and external clients such as a remote-terminal monitor.

Environment and validation

Installed version: OpenCode v2.0.26 on Linux. The public V2 API schema I reviewed exposes model/provider selection per session but no explicit account/credential selector on the session model or prompt operations. This is a feature request based on that public surface, not a claim of a controlled concurrent-account runtime test.

Related: #51152, #51410.

Activity

  1. opencode-agent commented on Oct 9, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed request! In short: you'd like each session to keep its own saved account for a provider, so two chats in the same project can use different OpenAI (or Copilot) accounts. Switching a chat's account would keep its conversation history and leave the global active account and other sessions alone.

    Right now, v2 uses the provider's one active account for every model request, and a session stores only its model and provider, not an account. So this would be new behaviour, and maintainers will consider it. It also can't be done as a plugin today. Plugins have no way to choose the account for a single session's requests, and switching the active account changes it for every session.

    Related issues:

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions