#9123: Feat/smart router backport and custom model provider
commands
agents
stale
Cluster:
Model Management Enhancements
Summary
This PR backports the Smart Router and Custom Provider functionality from Verso into OpenClaw. It allows agents to dynamically select the most appropriate model for each task (for example, routing simple queries to faster models and complex coding tasks to more capable ones) while also supporting embedded custom model providers.
Key Changes
Smart Router Integration
• Ported core router logic, including:
• src/agents/model-router.ts
• model-router-classifier.ts
• related supporting files
• Added RouterConfig to AgentDefaultsConfig in types.agent-defaults.ts
• Updated resolveModel to route requests through the Smart Router when enabled
Custom Provider Framework
• Added support for custom and embedded providers via
src/agents/pi-embedded-runner/model.ts
• Integrated custom authentication resolution and model discovery
CLI Updates
• Extended the openclaw configure wizard with a Smart Router configuration section
• Fixed export naming in configure.router.ts (configureRouter)
• Added Smart Router to shared wizard configuration options
Compatibility Fixes
• Replaced all VersoConfig references with OpenClawConfig to align with OpenClaw’s type system
• Fixed agent directory resolution (resolveVersoAgentDir → resolveOpenClawAgentDir)
• Resolved build and type issues, including adding the missing baseUrl to ResolvedProviderAuth
Verification
• Build: pnpm build passes successfully
• Tests: src/agents/model-router.test.ts updated and passing
• Manual Verification: Confirmed the configure wizard displays the new Smart Router options
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Backports Smart Router and custom/embedded provider support into OpenClaw by adding a router config type + schema, introducing a lightweight classifier helper, and wiring a new configure-wizard section plus model-resolution changes for inline/custom providers.
Main additions live under `src/agents/model-router*.ts` (dynamic model selection) and `src/commands/configure.router.ts` (wizard step), with updates to config typing/zod schema and model discovery/resolution to support custom OpenAI-compatible providers.
<h3>Confidence Score: 2/5</h3>
- Not safe to merge as-is due to a definite TypeScript compilation error and a user-facing CLI command regression.
- `src/config/types.router.ts` has an `import` after an `export type`, which will fail TS parsing/build. Additionally, an error message in `models auth login` now references `verso plugins install`, which is incorrect for OpenClaw and will mislead users.
- src/config/types.router.ts, src/commands/models/auth.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#7770: feat(routing): Smart Router V2 - Configuration-driven model dispatc...
by zzjj7000 · 2026-02-03
81.7%
#20587: feat: add Tetrate Agent Router Service provider
by RicHincapie · 2026-02-19
79.5%
#11833: 在openclaw onboard过程中,在model/auth provider选项中增加Huawei Cloud MAAS供应商的选择
by wukunming168 · 2026-02-08
79.3%
#9739: #9291 fix(models): preserve existing models in models.json when mer...
by ximzzzzz · 2026-02-05
79.1%
#12059: feat(agents): Add Azure AI Foundry credential support
by lisanyambere · 2026-02-08
78.2%
#7113: feat(providers): add CommonStack provider support
by flhoildy · 2026-02-02
77.7%
#7051: Add io-intelligence model inference provider
by rajagurunath · 2026-02-02
77.3%
#8258: feat: Add smart model tiering for cost optimization
by revenuestack · 2026-02-03
77.1%
#2429: added cerebras as a model provider.
by kkkamur07 · 2026-01-26
76.7%
#7020: feat: add search/filter to model selection in configure wizard
by GuoxiangZu · 2026-02-02
76.6%