From b5d0cae4a7ed9e8cef3bf45891857d6d6cbc8109 Mon Sep 17 00:00:00 2001 From: ImBenji Date: Fri, 4 Sep 2026 02:54:30 +0100 Subject: [PATCH] fix: raise the coordinator token ceiling, 6000 truncated a real article A replay article dead-lettered with 'coordinator response was truncated by max_tokens'. The cap was too tight, which is exactly the failure that was predicted when it went in. Raising it to 32000 costs nothing. The cap is there to satisfy openrouter's affordability check, not to ration tokens, and billing is on tokens used rather than reserved. The 402 handler already walks the ceiling down automatically when the budget cannot cover the reservation, so a high default is effectively uncapped while funded and degrades by itself when not. Verified against the live key at 64000 before picking 32000, so there is real headroom rather than a guess. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01WnNxwxfXSbeNtjvtz5gayb --- src/autonomy/llm.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/autonomy/llm.js b/src/autonomy/llm.js index d532629..9a4a583 100644 --- a/src/autonomy/llm.js +++ b/src/autonomy/llm.js @@ -35,12 +35,14 @@ async function callCoordinator(config, prompt, options = {}) { body: JSON.stringify({ model: config.openRouter.llmModel, temperature: 0, - // Sized against reality rather than guessed: the largest proposal this has - // ever produced was ~1,258 tokens carrying 12 predictions, the average is - // ~50. Reasoning models spend completion tokens thinking first, so this is - // still several times the worst case actually observed. + // Deliberately far above any output we have seen, because the cap exists to + // satisfy openrouter's affordability check, not to ration tokens: you are + // billed for what is used, not what is reserved. 6000 was tight enough to + // truncate a real replay article. The 402 handler below walks this down + // automatically when the budget cannot cover it, so a high ceiling costs + // nothing while funded and degrades on its own when not. max_tokens: options.maxTokens - || Math.max(512, Number(config?.openRouter?.maxTokens || process.env.OPEN_ROUTER_MAX_TOKENS) || 6000), + || Math.max(512, Number(config?.openRouter?.maxTokens || process.env.OPEN_ROUTER_MAX_TOKENS) || 32000), response_format: { type: 'json_object' }, messages: [ { role: 'system', content: 'You are a coordinator. Extract only evidence-backed categorical hypotheses. Never output probabilities, expected returns, confidence scores, position sizes, or trade actions.' },