refactor(model-routing): centralize explicit foreground fallback policy - #5811
Open
RaresKeY wants to merge 2 commits into
Open
refactor(model-routing): centralize explicit foreground fallback policy#5811RaresKeY wants to merge 2 commits into
RaresKeY wants to merge 2 commits into
Conversation
Make foreground fallback an explicit per-user, availability-only policy shared by streaming Chat, non-stream Chat, and Agent runs. Preserve strict defaults, owner/model and credential boundaries, pinned Agent routes, and truthful per-round provenance/accounting. Carry provider-reported model identifiers through native streaming adapters, non-stream responses, and caches, and keep legacy default_model_fallbacks as tombstoned raw storage that generic settings APIs and agent tools cannot expose or mutate.
RaresKeY
marked this pull request as ready for review
July 28, 2026 16:57
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This replaces #5683, which GitHub closed during the repository transfer and fork-network separation. The branch has been rebuilt on the current dev history; the implementation scope is unchanged.
Foreground Chat, non-stream Chat, and Agent runs now share one explicit per-user fallback policy. Selected models remain strict unless the current user enables an ordered list of exact endpoint/model candidates. Only availability failures may advance; request, authentication, authorization, unsupported-model, and configuration failures remain visible. Agent runs pin a fallback route after substantive output or a completed tool call, and model provenance follows the route that actually answered.
Target branch
dev, notmain. All PRs land indev;mainis curated by the maintainer at each release. If your PR is onmainby accident, click "Edit" on this PR and change the base.Linked Issue
Fixes #5626
Part of #5625
Depends on #5632
Type of Change
Checklist
devdocker compose uporuvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.Stack
This is the second PR in #5625: #5632 → this PR → #5684.
Until #5632 merges, GitHub shows both stack commits. The issue-specific commit is
1d0e7cdf32d162aaa1993d771348c36b61fd4387.Behavior contract
default_model_fallbacksdata remains stored but is not read, exposed, migrated, or used by foreground routing.Scope
In scope: foreground Chat and Agent routing, explicit per-user policy, owner-scoped resolution, availability classification, Agent pinning, provenance, accounting, and removal of dead silent-switching paths.
Out of scope: Settings controls, Utility, Vision, Deep Research, scheduled tasks, teacher, image, embedding, search-provider routing, inferred model tiers, and legacy-data migration.
Validation
Live-provider and interactive browser validation remain outstanding, so this PR remains draft.
How to Test
default_model_fallbacksvalues remain stored but have no runtime or Settings effect.Visual / UI changes — REQUIRED if you touched anything that renders
--red,--fg,--bg,--card,--border, etc.) — do not introduce new color values, font sizes, or spacing units.static/index.html) or plain text.Fira Code) for primary UI text. Don't override.Screenshots / clips
Not included. This PR changes existing fallback and provenance labels; manual browser validation remains outstanding.