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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WnNxwxfXSbeNtjvtz5gayb
This commit is contained in:
ImBenji
2026-09-04 02:54:30 +01:00
co-authored by Claude Opus 5
parent ca69ad0e73
commit b5d0cae4a7
+7 -5
View File
@@ -35,12 +35,14 @@ async function callCoordinator(config, prompt, options = {}) {
body: JSON.stringify({ body: JSON.stringify({
model: config.openRouter.llmModel, model: config.openRouter.llmModel,
temperature: 0, temperature: 0,
// Sized against reality rather than guessed: the largest proposal this has // Deliberately far above any output we have seen, because the cap exists to
// ever produced was ~1,258 tokens carrying 12 predictions, the average is // satisfy openrouter's affordability check, not to ration tokens: you are
// ~50. Reasoning models spend completion tokens thinking first, so this is // billed for what is used, not what is reserved. 6000 was tight enough to
// still several times the worst case actually observed. // 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 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' }, response_format: { type: 'json_object' },
messages: [ 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.' }, { 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.' },