* chore: create learning subdirectory structure (routing, agents, intelligence) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: extract classify_query to routing/_utils.py Move the classify_query() function and its regex patterns into a shared utility module so multiple routing policies can import it without depending on the full trace_policy module. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move routing files to learning/routing/ subdirectory Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: create LearnedRouterPolicy merging trace-driven + SFT routing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add conditional Algolia DocSearch integration Add Algolia DocSearch as an optional search upgrade — native lunr.js search remains the default until credentials are configured. Includes CDN assets, Jinja2 conditional config injection, init script with graceful fallback, light/dark theme CSS, improved search tokenization for snake_case/dotted identifiers, and search boosts for key pages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move agent_evolver and skill_discovery to learning/agents/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: move learning/orchestrator to learning/intelligence/orchestrator Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: delete removed learning policies, rewrite __init__.py, clean up api_routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add SFT/GRPO/DSPy/GEPA config dataclasses, update LearningConfig Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add general-purpose SFT trainer (intelligence/sft_trainer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update stale imports in multi_model_router example Update imports to use new learning/routing/ paths after the subdirectory reorganization. Replace BanditRouterPolicy with LearnedRouterPolicy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add general-purpose GRPO trainer (intelligence/grpo_trainer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add DSPy agent optimizer (agents/dspy_optimizer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add GEPA agent optimizer (agents/gepa_optimizer.py) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add learning-dspy and learning-gepa optional dependency extras Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: update integration test to check for learned policy instead of grpo Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: clean up stale APIs and unused params in examples - deep_research: remove system_prompt and max_turns params not accepted by Jarvis.ask(), inline system prompt into the query instead - doc_qa: remove unused --top-k CLI arg that was never passed to the API - multi_model_router: fix select_model() call to match single-arg signature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: import SFT/GRPO trainers in intelligence/__init__.py for registry Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: remove .md file changes from PR Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: restore search boost frontmatter for key docs pages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Multi-Model Router
Route queries to the cheapest capable model using OpenJarvis's learning/routing system. Simple queries go to small fast models; complex code or math queries go to larger models.
Requirements
- OpenJarvis installed (
git clone https://github.com/open-jarvis/OpenJarvis.git && cd OpenJarvis && uv syncoruv sync --extra dev) - An inference engine running with multiple models available
Usage
python examples/multi_model_router/multi_model_router.py --help
# Simple query -> routes to smallest model
python examples/multi_model_router/multi_model_router.py --query "What is 2+2?"
# Complex reasoning -> routes to largest model
python examples/multi_model_router/multi_model_router.py \
--query "Explain quantum entanglement step by step" --verbose
# Code query -> routes to code-specialized model
python examples/multi_model_router/multi_model_router.py \
--query "def fibonacci(n):" --verbose
# Specify available models explicitly
python examples/multi_model_router/multi_model_router.py \
--query "Summarize this paper" \
--models "qwen3:0.6b,qwen3:8b,qwen3:32b"
# Use bandit (Thompson Sampling) strategy
python examples/multi_model_router/multi_model_router.py \
--query "Solve the integral of x^2" --strategy bandit
How It Works
The script uses OpenJarvis's routing infrastructure from the learning pillar:
-
HeuristicRouter (default) -- rule-based routing that analyzes the query for code patterns, math keywords, length, and complexity to pick the right model tier. Short simple queries go to the smallest model; code and math queries go to larger or specialized models.
-
BanditRouterPolicy -- Thompson Sampling multi-armed bandit that learns which model performs best for each query class over time.
Both routers use build_routing_context() to extract query features (length,
has_code, has_math) and then select from the available model pool. Use
--verbose to see the routing decision details.