[claude] Three-tier model router: Local 8B / Hermes 70B / Cloud API cascade (#882) #1297
Reference in New Issue
Block a user
Delete Branch "claude/issue-882"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #882
What this does
Implements the intelligent three-tier model router described in issue #882, making LLM backend selection automatic based on task complexity.
New files
src/infrastructure/models/router.py—TieredModelRouterclassify_tier(task, context)— heuristic classifier, no LLM call requiredLOCAL_FAST): short navigation/action tasks → 8B local modelLOCAL_HEAVY): planning, strategy, complex reasoning → 70B local modelCLOUD_API): explicit override or Tier-2 failure → cloud (Claude/GPT-4o)src/infrastructure/models/budget.py—BudgetTrackerrecord_spend(provider, model, tokens_in, tokens_out)with auto cost estimationcloud_allowed()checks daily + monthly limitsget_summary()for dashboardsConfig additions (
src/config.py)tier_local_fast_modelllama3.1:8bTIER_LOCAL_FAST_MODELtier_local_heavy_modelhermes3:70bTIER_LOCAL_HEAVY_MODELtier_cloud_modelclaude-haiku-4-5TIER_CLOUD_MODELtier_cloud_daily_budget_usd5.0TIER_CLOUD_DAILY_BUDGET_USDtier_cloud_monthly_budget_usd50.0TIER_CLOUD_MONTHLY_BUDGET_USDAcceptance criteria
"Walk to the next room"→LOCAL_FAST(Tier 1)"Plan the optimal path to become Hortator"→LOCAL_HEAVY(Tier 2)Tests
44 new unit tests in:
tests/infrastructure/test_tiered_model_router.py(router + classifier)tests/infrastructure/test_budget_tracker.py(spend tracking + limits)All 544 unit tests pass (
tox -e unit).