fix: bound max_tokens on the openrouter calls
Neither the coordinator nor the graph resolver set max_tokens, so openrouter reserved the model's entire output window against the key's remaining budget and returned 402 before running anything: 131k tokens reserved to produce a few hundred. It never showed up with the old model because its output window is small enough to fit under the limit. Both are now bounded and overridable by env. The headroom is deliberate, the newer reasoning models spend completion tokens thinking before they answer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WnNxwxfXSbeNtjvtz5gayb
This commit is contained in:
@@ -101,6 +101,10 @@ Reply with just the number of the match, or "none" if none apply. No explanation
|
||||
model: llmConfig.cheapModel || llmConfig.llmModel || llmConfig.model,
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
temperature: 0,
|
||||
// Same reason as the coordinator: an unbounded request gets a 402 for reserving
|
||||
// the whole output window. This one only ever replies with a number or "none",
|
||||
// the headroom is for models that think before answering.
|
||||
max_tokens: Math.max(256, Number(process.env.OPEN_ROUTER_GRAPH_MAX_TOKENS) || 2000),
|
||||
});
|
||||
|
||||
if (Date.now() < llmCooldownUntil) return null;
|
||||
|
||||
Reference in New Issue
Block a user