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
The error "Response truncated due to output length limit" persists despite previous fixes in #7242 and #9525, which were merged in response to the now-closed issue #7237.
The issue was closed by a maintainer last month with the explanation that it is "not a bug" but rather a context window limitation. However, extensive testing and user reports (see the 10+ comments since the closure) continue to reproduce the error across different models — including those with very large context windows (414k tokens, 131k tokens, and even Gemini 1.5 with 2M tokens).
This suggests that while the input context might be sufficient, the output token cap or the continuation logic for long tool outputs/summaries is failing. This new issue is meant to re-surface the problem with specific reproduction data showing failures on fresh sessions with large-context models.
Trigger a tool call that returns a large, dense payload (e.g., >80KB).
Example: mcp_mongodb_collection_schema on a complex database collection.
Example: read_file on a large lockfile (e.g., pnpm-lock.yaml or package-lock.json).
Observe the agent stop mid-generation (often during a summary or a sub-agent's response) with: :warning: Response truncated (finish_reason='length') - model hit max output tokens :warning: Truncated tool call response detected — refusing to execute incomplete tool arguments. Error: Response truncated due to output length limit
This happens even on fresh sessions (low input context), ruling out simple history overflow.
Expected Behavior
Long responses should be split into chunks or the continuation logic should reliably retry until a complete response is assembled. The 3-retry mechanism introduced in #7242 / #9525 should prevent hard truncation in all API modes (chat_completions and anthropic_messages) by detecting finish_reason='length' and requesting the remainder.
Actual Behavior
The agent throws "Response truncated due to output length limit" and halts. The continuation/retry logic does not trigger effectively, or the truncated JSON/summary is rejected by the agent's core before it can be completed.
The current logic fails to differentiate between "Context Window Full" (Input) and "Max Output Tokens Hit" (Output).
Many providers have a hard limit on single completion length (e.g., 4096 or 8192 tokens).
When a tool returns a massive result (e.g., a 100KB schema), the model tries to process/summarize it and hits its output cap long before it exhausts its input context.
Intelligent Tool Output Management: If a tool result exceeds a certain size (e.g., 50KB), save it to a temporary file and only inject a summary/snippet into the context to prevent the model from "choking" on the output generation.
Unify Continuation Logic: Ensure anthropic_messages and chat_completions paths are perfectly synced regarding truncation detection and retry.
Configurable Output Caps: Allow users to override the 32k boost cap or the default max_tokens for completions in config.yaml.
Improved Logging: Surface the actual token counts (Output used / Max output) when a truncation occurs to distinguish from Input context limits.
Bug Description
The error "Response truncated due to output length limit" persists despite previous fixes in #7242 and #9525, which were merged in response to the now-closed issue #7237.
The issue was closed by a maintainer last month with the explanation that it is "not a bug" but rather a context window limitation. However, extensive testing and user reports (see the 10+ comments since the closure) continue to reproduce the error across different models — including those with very large context windows (414k tokens, 131k tokens, and even Gemini 1.5 with 2M tokens).
This suggests that while the input context might be sufficient, the output token cap or the continuation logic for long tool outputs/summaries is failing. This new issue is meant to re-surface the problem with specific reproduction data showing failures on fresh sessions with large-context models.
Steps to Reproduce
hermes chat(CLI) orhermes gateway start(Telegram / Discord / Slack).mcp_mongodb_collection_schemaon a complex database collection.read_fileon a large lockfile (e.g.,pnpm-lock.yamlorpackage-lock.json).:warning: Response truncated (finish_reason='length') - model hit max output tokens:warning: Truncated tool call response detected — refusing to execute incomplete tool arguments.Error: Response truncated due to output length limitExpected Behavior
Long responses should be split into chunks or the continuation logic should reliably retry until a complete response is assembled. The 3-retry mechanism introduced in #7242 / #9525 should prevent hard truncation in all API modes (chat_completions and anthropic_messages) by detecting
finish_reason='length'and requesting the remainder.Actual Behavior
The agent throws "Response truncated due to output length limit" and halts. The continuation/retry logic does not trigger effectively, or the truncated JSON/summary is rejected by the agent's core before it can be completed.
Confirmed still occurring in:
Affected Component
Agent Core (conversation loop, tool output handling, continuation logic)
Debug Report
Operating System
Ubuntu 24.04
Root Cause Analysis
The current logic fails to differentiate between "Context Window Full" (Input) and "Max Output Tokens Hit" (Output).
Proposed Fix
anthropic_messagesandchat_completionspaths are perfectly synced regarding truncation detection and retry.max_tokensfor completions inconfig.yaml.Are you willing to submit a PR for this?