A Local Policy
- Policies can be synchronous or asynchronous.
- Router Core validates the returned model and reasoning effort.
- Omit
reasoningEffortto use the candidate’s default. - The TypeScript field is
reasoningEffort. Wire JSON usesreasoning_effort.
Inspect Or Serve A Selection
router.evaluatePolicy(request)runs the policy without reading or writing leases and without firing hooks. Use it for previews, logs, or tests.router.select(request)is the authoritative call. It reads an existing lease, applies any new lease the policy returns, and firesonSelection.router.fetch()uses the same rules.
Self-Hosted Selector Policy
UsecreateDariRoutingPolicy for the advanced self-hosted pipeline. It calls a selector model, an LLM that answers routing questions, and uses the deterministic policy engine to build the evidence, check the answer, and validate it. It is exported from /policy-engine because it is more opinionated than the core policy interface.
selectoris the only place the selector model is called. It is an option ofcreateDariRoutingPolicy, not ofcreateRouter.- You must supply your own pricing and observed output-token averages. Router Core does not ship or infer them.
- Cache state and model metadata are optional. If cache state is unknown, the engine makes no cache-savings claim.
Filter Evals Per Request
evals also accepts a callback, so a large benchmark pool can be filtered for each request. selectRelevantEvals asks TypeSafe’s Jev one yes or no question per card: does this benchmark measure the kind of work the agent is doing? It keeps the cards whose relevance probability is above JEV_EVAL_RELEVANCE_THRESHOLD (0.3). The Managed Router uses the same filter.
Custom Rules
- Rules steer the selector without narrowing the candidates. A request that no rule matches is routed among every candidate.
- The selector request is the same one every router uses, with a short rules section added to its system prompt.
- The selector must return an eligible model and effort.
- For a fully local, deterministic policy, write a
RoutingPolicydirectly. For full control of preparation and finalization, use the advanced policy engine.