fix: honour OPEN_ROUTER_CHEAP_MODEL, it was set and never read

The env var has been set to google/gemma-4-31b-it all along and nothing ever
mapped it onto openRouter.cheapModel, so graphWorker's fallback chain silently
used the main model instead. Graph entity resolution is the highest volume llm
call in the system and its entire job is to reply with the number of a match.

Measured on the live key, same prompt:

  deepseek v4 flash   7564 completion tokens, 7558 of them reasoning  $0.0013708
  gemma-4-31b-it        14 completion tokens, 0 reasoning             $0.0000121

113x. Gemma is actually the more expensive model per token, which is why this
was worth measuring rather than reasoning about prices: the cost is not the
price of the tokens, it is a reasoning model spending seven thousand tokens
thinking about a multiple choice question.

This also explains the reasoning tokens dominating the usage dashboard, and why
the daily spend roughly doubled today rather than yesterday. Removing the token
ceiling let a trivial prompt reason without bound. The ceiling was never the
right control for that, the model choice is.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WnNxwxfXSbeNtjvtz5gayb
This commit is contained in:
ImBenji
2026-09-04 21:57:17 +01:00
co-authored by Claude Opus 5
parent f464c94708
commit 9b490c4d39
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -26,6 +26,10 @@ const openRouter = { ...rawConfig.openRouter };
if (process.env.OPEN_ROUTER_API_KEY) openRouter.apiKey = process.env.OPEN_ROUTER_API_KEY;
if (process.env.OPEN_ROUTER_LLM_MODEL) openRouter.llmModel = process.env.OPEN_ROUTER_LLM_MODEL;
if (process.env.OPEN_ROUTER_EMBED_MODEL) openRouter.embeddingModel = process.env.OPEN_ROUTER_EMBED_MODEL;
// OPEN_ROUTER_CHEAP_MODEL was already set in the environment and nothing read it,
// so graph entity resolution ran on the reasoning model: 7,558 reasoning tokens to
// answer "reply with just the number", 113x the cost of a model that just answers.
if (process.env.OPEN_ROUTER_CHEAP_MODEL) openRouter.cheapModel = process.env.OPEN_ROUTER_CHEAP_MODEL;
const config = {
duriin_db: process.env.DURIIN_DB || resolvePath(rawConfig.duriin_db, path.resolve(configDir, "archive.sqlite")),