SIGN IN SIGN UP

The all-in-one AI productivity accelerator. On device and privacy first with no annoying setup or configuration.

0 0 45 JavaScript

router-models: accurate token/message counting for model router decisions (#5680)

* fix: accurate token/message counting for model router decisions
Previously the router only counted tokens from the current user message,
ignoring system prompt, chat history, pinned docs, and parsed files.
Introduce ModelRouterService.gatherRoutingContext() to compute the true
conversation token count and reuse the fetched context downstream to
avoid redundant DB/filesystem lookups.
Also adds model router support to the OpenAI-compatible and API chat
handlers, propagates usageMetrics through ephemeral agents, and fixes
the router input to use the attachment-injected message.

* fix /chat API counter

* count current message in message count for router

* add router handler everywhere these is getLLMProvider

* router logic overhaul and refactor

* fix tests

* fix logger

* support generic openAI auto-detection for dropdown in model rules provider - fails over to plaintext input
T
Timothy Carambat committed
5981d482f31d312deff69cd7dd0fbb8fe4446135
Parent: 2f189f9
Committed by GitHub <noreply@github.com> on 5/23/2026, 1:21:34 AM