Token budget options in settings
Describe feature
Summary
When extended thinking is enabled on the Anthropic provider, Trilium caps total output at a hardcoded budget that's too small for some complex answers, causing responses to cut off mid-answer — or in the worst case, be entirely empty because the token budget is exhausted during the thinking phase itself, before any answer text is generated.
e.g.
packages/trilium-core/src/services/llm/providers/anthropic.ts#L138, in chat():
const thinkingBudget = config.thinkingBudget || 10000;
const maxTokens = Math.max(config.maxTokens || 8096, thinkingBudget + 4000);Anthropic's API counts thinking tokens and the final answer together. On
a question that requires substantial reasoning, thinking alone can consume
most or all of the hardcoded budget, leaving little or no room for the actual answer.
When thinking consumes the entire budget, the stream ends with
finish_reason: "length" and no text content block is ever produced.
Steps to reproduce issue
- Configure an Anthropic provider with extended thinking enabled (Claude Sonnet with extended thinking).
- Ask a question complex enough to require heavy reasoning (may require several attempts).
- Observe the response cut off mid-sentence, or in some cases return entirely empty with no visible text.
Feature request
- Expose
thinkingBudgetandmaxTokens(and the equivalent for other providers) as configurable fields in the settings UI - Show more detailed logging information to the user — e.g. detect
finish_reason: "length"and show a notice like "Response was cut off — increase max tokens in provider settings" so users aren't left wondering why things randomly quit.
Environment
- Trilium version: 0.105.0
- Provider: Anthropic (API key), Claude Sonnet 5, extended thinking enabled
Additional Information
No response
Source: TriliumNext/Trilium