Skip to main content
A policy receives the normalized request and the candidates that passed capability filtering. It returns a model ID and may choose a reasoning effort.

A Local Policy

  • Policies can be synchronous or asynchronous.
  • Router Core validates the returned model and reasoning effort.
  • Omit reasoningEffort to use the candidate’s default.
  • The TypeScript field is reasoningEffort. Wire JSON uses reasoning_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 fires onSelection. router.fetch() uses the same rules.

Self-Hosted Selector Policy

Use createDariRoutingPolicy 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.
  • selector is the only place the selector model is called. It is an option of createDariRoutingPolicy, not of createRouter.
  • 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 RoutingPolicy directly. For full control of preparation and finalization, use the advanced policy engine.