Skip to content

feat: add model selection engine (APR-205)#53

Open
JacobSampson wants to merge 1 commit into
mainfrom
APR-205/model-selection-engine
Open

feat: add model selection engine (APR-205)#53
JacobSampson wants to merge 1 commit into
mainfrom
APR-205/model-selection-engine

Conversation

@JacobSampson

Copy link
Copy Markdown
Contributor

Summary

  • Implements selectModel() in @aprovan/devtools/model-selection — maps a 1-5 complexity score to the best available model
  • Selection priority: free tier (complexity ≤ 2) → subscription with available quota → paid budget → paid mid-tier → paid frontier → paid premium
  • DEFAULT_CATALOG covers OpenRouter free models, OpenCode + Claude subscription plans, and paid models from Anthropic, OpenAI, and Google
  • ScoringPlugin interface scaffolds MCP injection points for 3rd-party data sources (Artificial Analysis, etc.) — data collected but not yet weighted
  • Returns SelectionResult with modelId, provider, tier, planType, optional subscriptionPlan, and human-readable reasoning
  • New ./model-selection subpath export added to package.json and tsup

Test plan

  • 37 new tests covering all 5 complexity scores, priority ordering, subscription quota gating, plugin scaffolding, and error paths
  • 53/53 tests pass (pnpm test)
  • 0 type errors (pnpm typecheck)
  • 0 lint errors on new files (pnpm lint)
  • Build succeeds with model-selection.{js,cjs,d.ts} emitted (pnpm build)

Notes

  • quotaState is optional; omitting it means no subscription plans are considered (all pass through to paid routing)
  • Assumes quota is available for any plan listed with hasAvailableQuota: true — real-time quota data will be plugged in via APR-206/APR-207
  • Plugin errors are swallowed (fire-and-forget) so they never block model selection

Closes APR-205. Unblocks APR-206 (OpenRouter integration) and APR-207 (MCP plugin scaffold).

🤖 Generated with Claude Code

Implements the core complexity → model tier routing engine in
@aprovan/devtools/model-selection.

- `selectModel(input)` maps a 1-5 complexity score to the best
  available model, applying the priority order: free tier →
  subscription (prepaid quota) → paid (budget → mid-tier →
  frontier → premium).
- `DEFAULT_CATALOG` defines routing options across OpenRouter free,
  OpenCode/Claude subscriptions, and paid models from Anthropic,
  OpenAI, and Google.
- `ScoringPlugin` interface scaffolds MCP integration points for
  3rd-party data sources (Artificial Analysis etc.) — data is
  collected but not yet weighted in selection decisions.
- Returns `SelectionResult` with modelId, provider, tier, planType,
  optional subscriptionPlan, and human-readable reasoning.
- 37 new tests covering all complexity scores, priority ordering,
  subscription quota gating, plugin scaffolding, and error paths.
- All CI gates green: 53/53 tests, 0 type errors, 0 lint errors, build succeeds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant