← Back to PRs

#9123: Feat/smart router backport and custom model provider

by JuliusYang3311 open 2026-02-04 22:14 View on GitHub →
commands agents stale
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