Skip to content

feat: auto model routing from SynthBench routing.json (--model auto) - #597

Merged
the-data-viking merged 2 commits into
mainfrom
feat/auto-model-routing
Oct 14, 2026
Merged

the-data-viking merged 2 commits into
mainfrom
feat/auto-model-routing

Conversation

@the-data-viking

Copy link
Copy Markdown
Collaborator

Summary

Step 1 of the SynthBench → Althing routing contract (v1): Althing reads SynthBench's routing.json and picks a model or weighted blend for a panel.

  • --model auto on panel run, model="auto" on MCP run_panel / run_quick_poll, and run_panel(model="auto") in the SDK. All three call althing.model_routing.route_models.
  • Slice from --use-case, else --population (non-US country → cross-national; US demographic attributes → us-subgroups) and the persona pack (global-respondents → cross-national), else us-general.
  • Topic from --topic, else whole-word keyword match of the question text against the routing.json taxonomy; a topic is used only when more than half the questions match it, otherwise all.
  • Selection: the route's best_althing. Not confident → the slice's all route → the default model. Model ids run as openrouter/<model_id>, or a direct alias when Althing has one and the provider key is set. Members that cannot run are dropped and the blend is renormalized; a one-member blend becomes a single model; at most 4 members.
  • Blends run as a weighted per-persona split (the existing largest-remainder split, moved to althing.model_split so CLI, MCP and SDK share it). This works on multi-round instruments. --blend with a routed blend uses the blend path on single-round instruments.
  • Decision record: CLI prints models, weights, slice, topic, confident, source and a one-sentence reason to stderr, and stores it under metadata.model_routing. MCP returns model_routing (also in metadata). SDK: panel.metadata["model_routing"].
  • synthbench.load_routing(): same fetch / 24h cache / ETag / offline / bundled-snapshot machinery as the leaderboard, with its own cache file and ALTHING_SYNTHBENCH_ROUTING_URL.
  • Blend-aware recommend(): ensemble rows produce members with weights and model_spec(). Baseline rows are skipped. --best-model-for keeps working (first runnable member of a blend) and its help points at --model auto.

Snapshots

  • data/synthbench-routing-snapshot.json: copied from a local SynthBench build of the routing builder (routing-local.json, generated 2026-10-14), since https://synthbench.org/data/routing.json is not published yet. Replace it with the published file on the next refresh.
  • data/synthbench-snapshot.json: refreshed from the live leaderboard (2026-10-14), baselines and topic_metrics removed, one entry per line.

Behavior change

--best-model-for used to stamp bare upstream ids like google/gemini-2.5-flash-lite onto --model, which no provider accepts. It now uses openrouter/google/gemini-2.5-flash-lite. Two existing tests were updated for this.

Docs

  • New docs/model-routing.md.
  • ensemble.md and the --models help now describe the split as largest remainder with at least one persona per model.
  • model-packs.md / task-recommendations.md no longer pair --blend (or --max-cost) with multi-round instruments, and no longer claim MCP returns a blend block or a convergence score.
  • synthbench-integration.md no longer shows a --topic example.
  • April-era model claims are replaced with pointers to live data and a table regenerated from the new snapshot.

Test plan

  • tests/test_model_routing.py (60 tests): slice and topic inference, word-boundary matching, the confident fallback chain, ensemble → members, dropping and renormalizing members, max members, the routing client (live/cache/offline/404/bundled), snapshot shape, CLI --model auto with a fake runner (metadata recorded, split applied, invalid combinations), MCP model="auto" for run_panel and run_quick_poll, SDK.
  • Full suite on Windows: the same 44 pre-existing failures as origin/main, 62 more passing tests.
  • ruff check, ruff format --check, mypy --platform linux src/althing/.

🤖 Generated with Claude Code

Add `--model auto` (CLI), `model="auto"` (MCP run_panel / run_quick_poll)
and `run_panel(model="auto")` (SDK). All three call
althing.model_routing.route_models, which:

- infers the slice (us-general / us-subgroups / cross-national) from
  --population and the persona pack, unless --use-case / use_case is given;
- infers the topic by whole-word keyword match against the routing.json
  taxonomy, taking a topic only when more than half the questions match it,
  unless --topic / topic is given;
- uses the route's best_althing system, falling back to the slice's
  all-topics route and then the default model when a route is not
  confident;
- maps model ids to openrouter/<model_id> (or a direct alias when the
  provider key is set), drops members that cannot run, renormalizes, and
  collapses a one-member blend to a single model.

Blends run as a weighted per-persona split (shared largest-remainder split,
moved to althing.model_split). The CLI prints the decision to stderr and
records it in metadata.model_routing; MCP returns it as model_routing.

Also:
- synthbench.load_routing: routing.json client with its own cache, URL
  override (ALTHING_SYNTHBENCH_ROUTING_URL) and bundled snapshot, sharing
  the leaderboard fetch/ETag/offline machinery.
- recommend() is blend-aware (members + model_spec()), skips baseline rows,
  and maps model_id through openrouter/ instead of stamping a bare id.
- Bundle a routing snapshot from a local SynthBench build and refresh the
  leaderboard snapshot from the live leaderboard, trimmed.
- Docs: new docs/model-routing.md; fix the weighted-split description,
  --blend examples on multi-round instruments, the MCP blend/convergence
  claims, a nonexistent --topic example, and April-era model claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@the-data-viking the-data-viking added the semver:minor Bump minor version on merge label Oct 14, 2026
A route that is not confident has a best system that is close to the
runner-up, not a poor one. Falling back to the surface default (Sonnet on
the CLI, Haiku on MCP) picked a model SynthBench ranks well below the
slice's top Althing-conditioned system, or never measured. The chain is
now: confident topic route, confident all-topics route, the all-topics
route's top system with confident=false (fallback="slice-top"), and the
default model only when the slice has no routes or nothing can run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Deploying synthpanel with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9e1581a
Status: ✅  Deploy successful!
Preview URL: https://c5d09ded.synthpanel.pages.dev
Branch Preview URL: https://feat-auto-model-routing.synthpanel.pages.dev

View logs

@the-data-viking

Copy link
Copy Markdown
Collaborator Author

Changed the fallback chain in 9e1581a. When neither the topic route nor the all-topics route has a clear lead, auto now uses the all-topics route's top Althing-conditioned system with confident: false and fallback: "slice-top", not the surface default. "Not confident" means the top two are close, not that the leader is poor. The surface default (Sonnet on the CLI, Haiku on MCP) is a model SynthBench ranks lower or never measured. The default is now used only when the slice has no routes or none of the members can run. Docs, changelog and tests are updated.

@the-data-viking
the-data-viking merged commit 99b39ab into main Oct 14, 2026
22 checks passed
@the-data-viking
the-data-viking deleted the feat/auto-model-routing branch October 14, 2026 22:36
the-data-viking added a commit that referenced this pull request Oct 14, 2026
)

actions/checkout persists GITHUB_TOKEN as an http extraheader, and git
sends that header instead of the x-access-token credentials in the push
URL. The bump commit therefore went out as github-actions[bot], which is
not a ruleset bypass actor, and main rejected it with GH013 (v1.9.0 after
#597). The ruleset itself is right: Integration 3967952 is a bypass actor.

Reset the header for the bump push only; the tag push keeps GITHUB_TOKEN
so it still does not trigger publish.yml.

Co-authored-by: the-data-viking <wesley@thedataviking.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:minor Bump minor version on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants