Files
loki/drizzle/0089_model_routing.sql
CatoandClaude 981ed229cf feat(models): Auto decides — a greeting never spends a frontier model (#1131)
With a person's own keys, "Auto" meant the first key's one model for every
turn: an Anthropic key put Fable 5.1 on "what time is it". George's rule:
never a frontier model for trivial work, and a cheap model may be as good
for the rest.

- lib/models/difficulty.ts (pure): message + history → light / standard /
  heavy with a reason. Explicit asks win ("think hard", "quick"); then code,
  a judgement call, a professional domain, writing, research, length and a
  numbered list count as signs (two make heavy, one standard); then the
  shapes a cheap model answers as well as any (greeting, capture, lookup,
  short question) are light.
- lib/models/auto-picks.ts (pure): from what the keys reach, three picks —
  economy (best value among cheap tool-capable), standard (best value at or
  above the median below frontier price), frontier (smartest). A hand pick
  wins and says "your choice". Stance thrifty / balanced / best maps a
  difficulty to a pick; a light turn goes to economy under every stance.
  chainFor: the pick, nearest tiers up before down, every key's default.
- lib/models/routing.ts: candidates per key (a router reaches the
  catalogue, a lab key its namespace, a host or endpoint only what was
  stored); routeTurn for one turn; routingFor for the screens; autoSummary.
  loki-core.ts#loadOwnModel walks the turn's links on Auto; provenance says
  "your key: X — light turn (a greeting)". A composer pick bypasses it; no
  catalogue yet falls back to the keys as stored.
- Migration 0089: user_preferences.model_stance; user_model_tiers for hand
  picks. /api/settings/model/routing GET/PUT.
- components/models/AutoRouting.tsx on /models (with keys) and in Settings
  → AI: stance, the three picks with reasons, a select per tier, "Loki
  decides". The composer's Auto row names the two ends.
- Tests: difficulty (5), auto-picks (5). Doc section "Auto decides".
  Changelog.


Claude-Session: https://claude.ai/code/session_01YKx4TPejLvFR9Uj4xrTf6Y

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-10 04:02:48 -07:00

15 lines
696 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Migration: Auto decides which model answers which kind of turn.
-- `model_stance` is the person's stance (thrifty / balanced / best, see
-- lib/models/auto-picks.ts); `user_model_tiers` holds the picks they set by
-- hand per tier — the computed ones are not stored, they follow the catalogue.
-- Hand-written, like 0073–0088.
ALTER TABLE user_preferences ADD COLUMN IF NOT EXISTS model_stance text NOT NULL DEFAULT 'balanced';
CREATE TABLE IF NOT EXISTS user_model_tiers (
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
tier text NOT NULL,
vendor text NOT NULL,
model text NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, tier)
);