You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Output limits are merged per field and window exhaustion is read as a complete response #4164
Two places read output limits per field or per known value instead of as one concept.
GenerateOptions.mergeOptions() falls back per field for maxTokens and maxCompletionTokens. A request that overrides one of them keeps the other from the model defaults, so the merged options carry two output limits although the caller supplied one.
FinishReasons.indicatesOutputLimit() did not recognize Anthropic's model_context_window_exceeded. That value means the response filled the context window, and Anthropic's stop-reason guidance treats that response as truncated. The helper only covered length, max_tokens and the Responses API incomplete cause.
To Reproduce
GenerateOptionsmerged = GenerateOptions.mergeOptions(
GenerateOptions.builder().maxTokens(64).build(),
GenerateOptions.builder().maxCompletionTokens(16000).build());
System.out.println(merged.getMaxTokens()); // 64System.out.println(merged.getMaxCompletionTokens()); // 16000, inherited from the defaults
A request-supplied output limit replaces both inherited limits; a request that supplies neither keeps both defaults; a request that supplies both keeps both.
A response that stopped at its output limit, or filled the context window, is reported as truncated.
Error messages
Neither path throws. With two limits present, HarnessContextBuilder.inputLimit and JevRouteCatalog fold them with Math.max, so the inherited default becomes the reserved output budget and the input budget loses that room; OpenAIChatFormatter writes both into the request body. With the truncation value missed, ConversationCompactor.toValidatedSummary accepted a summary cut at the window and replaced the history it was summarizing. MemoryConsolidator and ReasoningContext.isTruncated read the same helper.
Environment (please complete the following information):
Truncation values checked across adapters: DashScope length, Gemini MAX_TOKENS, OpenAI Chat Completions length, Responses incomplete plus the cause in metadata, Anthropic max_tokens and model_context_window_exceeded. Anthropic was the only adapter missing from the helper, and the SDK this repo builds against (3.14.0) exposes it as StopReason.MODEL_CONTEXT_WINDOW_EXCEEDED.
The truncation half is fixed in #4567 (26f8b946a). The merge half is in #4564.
changed the title [-][Bug]: Request output limits retain the other inherited token limit[/-][+][Bug]: Output limits are merged per field and window exhaustion is read as a complete response[/+]on Dec 2, 2026
Activity
[-][Bug]: Request output limits retain the other inherited token limit[/-][+][Bug]: Output limits are merged per field and window exhaustion is read as a complete response[/+]