Skip to content

feature: transparent model and provider switching — continue a session across a limit, price or policy boundary #1019

Closed

Description

@mrsabath

Feature Description

@rubambiza's idea: when a session approaches a token or rate limit, Cortex switches the request
to a different model or provider in the background, without interrupting the user's work —
the agent keeps going instead of stalling on a 429 or a context-window error.

The same mechanism serves three other triggers:

  • Cost — route to an equivalent-quality, cheaper model or provider when one is available
  • Preference — a user or team pins a preferred model per task class
  • Policy / compliance — a request that would violate a data-residency, provider-approval or
    region constraint is routed to a compliant provider, or refused with a clear reason rather
    than silently sent

Cortex is uniquely placed to do this: it already sits in the request path with the request body
decrypted, and already rewrites bodies (Context Guru compaction, tool-definition pruning). This
is a new plugin in that pipeline, not new architecture.

Proposed Solution

  • Provider abstraction: translate a request between provider wire formats (Anthropic
    Messages ↔ OpenAI Chat Completions ↔ others) including tool definitions, tool results,
    system prompts and streaming events
  • Trigger evaluation before the upstream call: projected token count vs the target model's
    window, observed rate-limit headroom, price table, policy rules
  • Retry-on-limit path: a 429 or context-overflow from the primary is re-issued against the
    fallback rather than surfaced to the agent
  • Preserve streaming — the client must not be able to tell a switch happened mid-turn, and
    the fix for authbridge-proxy: early flush of leading thinking block turns a slow tool call into a client stream-idle timeout #926 (early flush of leading thinking block) applies here too
  • Credentials for each provider resolved through AuthBridge, so the agent never holds more
    than one provider's secret
  • Every switch is recorded and visible. A silent model change is a correctness hazard:
    the user must be able to see, per request, which model actually answered, why it was
    chosen, and what it cost. Depends on feature: per-session and per-model token and cost aggregation #950
  • Opt-in, off by default, with a documented list of substitutions the user has approved

Risks and open questions

  • Silent quality change is the real risk. "Without interrupting your work" and "you should
    know which model answered you" are in tension. Proposal: never interrupt, always record, and
    surface a visible marker in abctl and in the session summary
  • Semantics are not preserved across providers: prompt caching, thinking blocks, tool-call
    formats and stop reasons all differ. A switch mid-session can invalidate a cache the user was
    paying to build — the cost model has to account for that
  • Whether policy enforcement belongs here or in the existing egress-control / guardrails plugins
  • Does the agent's own context (conversation history) transfer cleanly, or does a switch
    effectively start a new upstream cache lineage?

Additional Context

Credit: @rubambiza — team brainstorming, September 2026. Post-v0.9.0 — this is the largest of the
four brainstorm items and would not fit the release window.

Foundational for #1020 (task-class routing) and #1021 (parallel dual-model comparison), which
both need the provider abstraction and the switch mechanism this issue builds.
Depends on #950 for per-model cost attribution.

Part of the post-v0.9.0 brainstorm backlog under #962.

Activity

  1. added
    enhancement
    on Sep 16, 2026
  2. self-assigned this
    on Oct 7, 2026
  3. huang195 commented on Nov 17, 2026

    @huang195
    Member

    closing this one as we can do this already

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

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions