Skip to content

refactor(cross-stack): one LLM policy source of truth — retire hand-duplicated model_qos.rs vs model_config.py (follow-up to #9517) #9531

Closed

Description

@Git-on-my-level

Summary

Unify the LLM policy source of truth between the Python backend and the desktop Rust backend. Today desktop/macos/Backend-Rust/src/llm/model_qos.rs (12.6K) is a hand-maintained second implementation of the MODEL_QOS profiles that backend/utils/llm/model_config.py also implements, and the Rust lane carries its own BYOK (byok.rs, 23.7K), Vertex routing (vertex.rs), and provider-fallback policy next to a ~100K routes/chat_completions.rs + ~82K routes/proxy.rs serving lane. Nothing shares a source of truth, so policy drift between lanes is only caught by human review — 75 commits in Backend-Rust since 2026-05-15 means the drift surface is live.

This is the follow-up implementation to an exit criterion in #9517: that issue gates the gateway migration's "done" on the ownership decision being made; this issue tracks making the decision and doing the work.

Current state (verified in tree)

LLM provider/model/BYOK policy currently lives in four places:

  1. backend/utils/llm/ — Python selection policy (model_config.py: MODEL_QOS profiles, pinned features, provider-only feature sets) + client construction (being retired per chore(backend): define enforced exit criteria for the LLM gateway feature-mode migration (retire direct provider selection in utils/llm) #9517).
  2. backend/llm_gateway/ — the migration-target serving plane.
  3. desktop/macos/Backend-Rust/src/ — llm/model_qos.rs, byok.rs, vertex.rs, fallback.rs, routes/chat_completions.rs, routes/proxy.rs.
  4. Desktop bridge/harness modes — being converged into SessionExecutionProfile by refactor(macOS): converge chat, PTT, agents, tools, and continuity onto single owners #9515 domain 6.

Decision required (pick one, record it here)

  • (a) Gateway as the single serving/policy plane for desktop too. The Rust backend proxies LLM traffic to llm-gateway; model_qos.rs and duplicated BYOK/provider policy are deleted. Rust keeps only transport/auth/paywall concerns it genuinely owns.
  • (b) Rust lane as a declared bounded owner for desktop. The policy artifact is shared, not duplicated: QoS profiles / pinned features / provider constraints generated from one canonical source (checked-in manifest) consumed by both model_config.py and model_qos.rs, with a CI drift check that fails when either side diverges from the manifest.

Evaluation inputs for the decision: desktop latency budget for an extra gateway hop, BYOK key locality (keys that must not transit the gateway), offline/local-model paths, and paywall/rate-limit coupling in routes/rate_limit.rs.

Definition of done

  • Decision (a) or (b) recorded in this issue with the evaluation inputs above.
  • Zero hand-maintained duplicate policy tables: model_qos.rs vs model_config.py drift is mechanically impossible (deleted, or generated + CI drift check) — not just reviewed for.
  • BYOK/credential-scope policy has one authoritative definition; the other lane consumes or proxies it.
  • Rust-lane provider fallbacks flow through the existing fallback::record_fallback fixed-field contract (present in fallback.rs; verify byok/vertex branch coverage).
  • AGENTS.md service map + docs/doc/developer/ describe the final ownership, not the migration.
  • chore(backend): define enforced exit criteria for the LLM gateway feature-mode migration (retire direct provider selection in utils/llm) #9517's Rust-lane exit criterion checked off, referencing this issue's outcome.

Non-goals

Related

Activity

  1. added
    backend
    maintainer
    on Jul 12, 2026
  2. Git-on-my-level commented on Jul 12, 2026

    @Git-on-my-level
    MemberAuthor

    Consolidated into #9517 — the Rust-lane decision, evaluation inputs, and exit criteria now live in that issue's "Desktop Backend-Rust lane" section. Closing to keep one tracker.

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

    backenddesktopmacOSmaintainerrefactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions