← All articles

Hermes Agent "Response Remained Truncated After 3/4 Continuation Attempts": Fix

Fix Hermes Agent 'Response remained truncated after 3/4 continuation attempts': check finish_reason=length vs stream interruption, save output & recover.

UniRoute ·

When Hermes Agent ends a turn with Response remained truncated after 3 continuation attempts or Response remained truncated after 4 continuation attempts, the agent entered its automatic continuation recovery loop (_continue_text) after an output-token cap (finish_reason='length') or a mid-stream disconnect (st.is_stub) and exhausted its retry limit before receiving a clean completion.

What to Do Right Now (3 Steps)

  1. Check the warning line printed immediately before the error: Look just above the (1/3) or (1/4) retry counter (or run hermes logs errors -n 100) to see whether the turn stopped on an output token limit (finish_reason='length'), a mid-stream interruption (Stream interrupted — requesting continuation), or no visible text was produced.
  2. Do not resend the full prompt—preserve your existing output first: Copy any stitched partial reply already printed above the notice, and run read-only /diff, /status, and /context to check whether earlier tool calls already modified files on disk before spending more tokens.
  3. Continue only the remaining section, shrink single-turn output, or switch to a model with a larger output cap: Ask Hermes to continue strictly from the last completed heading, split large patch / write_file edits into smaller steps, or switch to a model with a higher single-turn output limit. With one UniRoute API key (Hermes CLI setup guide), you can switch between Claude, GPT, and DeepSeek models inside Hermes—for example, DeepSeek's official pricing documentation lists a 384K maximum output token limit for deepseek-flash and deepseek-v4-pro (as of 2026-10-27; see current model pricing, and note that maximum output limits for individual models in the UniRoute catalog may differ—check /models).

Exact Error Messages Covered by This Guide (verified in NousResearch/hermes-agent commit b0427271e33c8b239985d3d66bd9d4f10f87e25b and official issues #628, #9372, #46833, #58423):

  • Response remained truncated after 3 continuation attempts (releases through mid-2026, e.g., v0.9.0–v0.16.0)
  • Response remained truncated after 4 continuation attempts (current main in agent/turn_truncation.py)
  • ⚠️ Response still truncated after N continuation attempts — no visible text was produced.
  • Codex response remained incomplete after 3 continuation attempts (codex_responses protocol path)

Note: Users also search paraphrased variants such as "response still truncated after two output token limit continuations"—that wording is not a literal string in the b0427271 source tree, but refers to the same continuation limit failure.

Verification Scope (2026-10-20): This guide is based on an inspection of official NousResearch/hermes-agent issues and fixed-commit source code (b0427271e33c8b239985d3d66bd9d4f10f87e25b). We did not reproduce this failure on UniRoute infrastructure, and the steps below are diagnostic and recovery procedures rather than a single guaranteed fix for every upstream server.


1. Quick Triage: Match the Preceding Warning Signal

The final truncation message only tells you that continuation recovery did not finish. Always check the warning printed immediately before the retry counter (1/3 or 1/4) or in hermes logs to see what actually stopped the turn:

Preceding Warning or Log SignalTrigger PathWhat HappenedFirst Safe Action
⚠️ Response hit token limit (finish_reason='length') followed by ↻ Requesting continuation (n/3)... or (n/4)...Output token limit (finish_reason == "length")The upstream model or OpenAI-compatible server stopped at its single-turn output cap; continuation turns also failed to finish.Check if usable partial text is already printed; run read-only /status and /context; ask the model to continue only the remaining part.
↻ Stream interrupted — requesting continuation (n/4)... or log entry stream ended before completionMid-stream interruption (st.is_stub)The streaming connection closed before sending a final completion reason; Hermes tried to continue from the interrupted stub and still could not finish.Inspect hermes logs errors -n 100 for upstream drops or timeouts; see our Stream Idle Timeout troubleshooting guide.
⚠️ Response still truncated after N continuation attempts — no visible text was produced.No visible text returned (requires log triage)Neither the initial response nor the continuation attempts produced visible text—for example, an empty/interrupted upstream stub or, as one possible cause, a reasoning model exhausting its output cap in thinking tokens.Inspect hermes logs errors -n 100 first to isolate the cause and verify server output limits; if logs confirm a reasoning model is exhausting budget and your route supports it, try lowering reasoning effort (/model with --reasoning low).
↻ Stream interrupted mid tool-call (...) — requesting chunked retry (n/4)... or truncated tool retryIncomplete tool-call JSONThe response cut off while generating arguments for a tool (such as patch or write_file); Hermes refused to execute broken JSON.Run /diff and git status to verify workspace state, then ask the agent to apply smaller, incremental edits.
Codex response remained incomplete after 3 continuation attemptsCodex Responses status=incompleteOn the codex_responses protocol path, the upstream endpoint returned status=incomplete across the retry budget.Check /context and server/provider token limits; split large prompts into smaller turns.

2. Stop Conditions & Cost Boundaries Before Retrying

Do not immediately resend the same prompt when a continuation loop fails. Because continuation attempts send follow-up requests to the model, repeating a failing turn can multiply token usage without producing a complete answer.

  1. Do not guess request counts or token spend from the banner alone: In agent/turn_truncation.py, _continue_text increments the retry counter (n += 1) before checking whether another continuation request is allowed (if n < 4 and filled is None:), or exits early if the context window is already full. That means the label alone does not tell you how many upstream requests succeeded, whether visible text was produced, or whether/how much a request was billed (which depends on your provider, local vs. hosted deployment, actual usage logs, and billing settlement).
  2. Check actual usage records and billing separately: Run /usage and /status in the CLI, and inspect agent.log (hermes logs) or your provider's request log to see the real api_calls and token counts. If you route requests through UniRoute, review the per-request log in the UniRoute Console (note that visible usage logs and wallet balance settlement are separate records).
  3. Preserve existing workspace output first:
    • If the turn printed a stitched partial_response above the error, copy or save what is already usable instead of regenerating the entire answer from scratch.
    • If the turn involved file or shell tools, run /diff (or git status / git diff in your terminal) and /agents first so you know whether earlier steps already modified files on disk.
    • Stop retrying if two consecutive scoped prompts still hit truncation; switch to the read-only diagnostics in Section 4 before spending more tokens.

3. Why You See "3" vs. "4" Attempts and Why Old max_tokens Advice Fails

Searching community threads often surfaces conflicting advice because both the retry counter and Hermes's token-limit configuration changed during 2026.

Why Some Logs Say 3 Attempts and Others Say 4

  • Historical releases (3 continuation attempts): Official GitHub issues from March through July 2026—including #628 (March 2026), #9372 (v0.9.0, April 2026), #46833 (v0.16.0, June 2026), and #58423 (July 2026)—report Response remained truncated after 3 continuation attempts.
  • Current main (4 continuation attempts): In current agent/turn_truncation.py (lines 305–370), _continue_text ends with Response remained truncated after 4 continuation attempts (while the separate codex_responses incomplete handler still uses a 3-attempt message).
  • Both length and mid-stream stubs use _continue_text: As shown in agent/turn_truncation.py (lines 328–337), _continue_text handles both finish_reason == "length" and mid-stream interruption stubs (st.is_stub, when a stream closes early after emitting partial content). Therefore, never assume this error is caused solely by an output token cap without checking the preceding warning line.

Version-Sensitive Configuration Policy (max_tokens vs. context_length)

Setting or Issue ReferenceStatus in Current Official Docs (b0427271)Practical Impact for Users
model.max_tokens, HERMES_MAX_TOKENS, model_overrides.*.*.max_output_tokensNo longer read — remove from config.yaml (providers.md lines 1290–1311)Adding these legacy keys on current Hermes will not raise single-turn output limits. Custom OpenAI-compatible endpoints use the inference server's own default output limit (e.g., SGLang --default-max-tokens).
model.context_length and model.ollama_num_ctxActive (Total Context Window) (providers.md lines 1173–1195, 1290–1292)Controls the combined input + output context window (used for compression thresholds and local context sizing), not the single-turn output cap. Official docs recommend at least 64000 tokens for agent use when hardware permits.
Issue #9372 (v0.9.0), PR #9489, PR #12152Issue closed; both PRs closed unmerged (merged: false)#9372 reported z-ai/glm4.7 hitting max output tokens on NVIDIA Build API. PR #9489 (internal retry boost) and PR #12152 (NIM default/wiring) were never merged; maintainer comment #9372#issuecomment-4668289126 noted progressive retry-boost landed on main (f7af90e2d).
Issue #58423 (cron/scheduler.py per-job max_tokens)Closed as not_plannedPer-job max_tokens in ~/.hermes/cron/jobs.json is ignored. The July 2026 comment suggesting global model.max_tokens is superseded by current providers.md.
Issue #46833 (v0.16.0, Ollama gemma4:12b thinking truncation & VRAM)Still openThinking tokens consumed the output budget, and Ollama /api/show returned the full 262,144 GGUF context (num_ctx=262144). The reporter's max_tokens: 16384 / context_length: 65536 values were specific to v0.16.0 on that machine; on current Hermes, configure server output limits plus model.context_length / model.ollama_num_ctx.

4. Read-Only Diagnostics First

Run read-only commands before changing session state or editing configuration files. Refer to the official CLI Commands Reference and Slash Commands Reference.

Read-Only TUI Slash Commands (Zero LLM Calls, No Cache Reset)

  • /status: Shows active model, provider, session ID, token totals, and a local session recap. Computed locally in memory with no LLM call and no prompt-cache impact (slash-commands.md line 65).
  • /context (alias /ctx): Displays a visual context-window breakdown and per-file token usage versus free headroom. Also purely read-only with no LLM call and no prompt-cache impact (slash-commands.md line 66).
  • /usage and /config: Inspect session token totals and active runtime settings.
  • /diff and /agents: Check uncommitted workspace file changes and list active background agents/tasks before taking recovery actions.

Read-Only Terminal Commands

# Check installed Hermes version and commit
hermes --version

# View service and profile status
hermes status

# Run configuration and connectivity check WITHOUT --fix first
hermes doctor

# Inspect recent warnings and errors in ~/.hermes/logs/
hermes logs errors -n 100
hermes logs --level WARNING --since 1h
  • hermes doctor boundary: Passing hermes doctor confirms config syntax and basic connectivity, but does not test whether your model endpoint will truncate long generations.
  • hermes dump privacy rule: If you run hermes dump to share setup details, never pass --show-keys, and manually redact private paths, internal hostnames, or account details before sharing. Avoid hermes debug share unless you pass --local, as it uploads to a public paste service by default.

5. Preserve-First Recovery Workflow (And Tradeoffs of Each Action)

Once you have inspected /context, /diff, and hermes logs, choose the recovery step that matches your root cause. Note that context compression and session resets are not lossless—always preserve your current state first.

Recovery ActionWhen to UseSide Effects & Cost / Data Tradeoffs
1. Scoped prompt continuationPartial text is already on screen or a single tool call was too large.Preserves session history, and sends a new model request (whether it is billed and at what rate depends on your provider, local vs. hosted deployment, and actual usage/settlement records). Ask Hermes to continue strictly from the last completed section or split file writes into smaller patches.
2. Adjust reasoning effort (/model ... --reasoning low)Logs show a reasoning model spending its output cap in thinking tokens (and your route supports reasoning controls).Modifies session/model config. Does not guarantee truncation disappears if the server's output cap or context window is still too small (in Issue #46833, lowering high to low on Ollama still truncated until context/server limits were addressed). Note: switching models with /model resets the prompt cache (slash-commands.md line 80).
3. Save then compress (/save → /compress)/context shows the conversation history is near the model's context ceiling (like the 648-message / ~299K-token session in Issue #628).Lossy summary + separate model request. /compress summarizes older exchanges (or use /compress here [N] to keep the last N exchanges verbatim) via a separate summarizer LLM request (configuration.md lines 997–1015; whether that request is billed depends on the provider/deployment configured for auxiliary.compression and your actual usage/settlement records). Always run /save first.
4. Start a new session (/new [name] or /reset)The current conversation thread is no longer needed and you want a clean context window.Drops active conversation history. Keep the confirmation prompt enabled. /new and /reset do not revert files already modified on disk (check /diff first) and do not stop background tasks.

Important Safety Rules for Config Edits and Background Processes

  • Close Hermes before editing ~/.hermes/config.yaml: Active CLI or gateway sessions can write runtime changes back to config.yaml and overwrite manual edits. If you enable automatic context compaction under compression: (which replaced the older session_hygiene: naming discussed in early #628 comments; see configuration.md lines 997–1015), stop the client first.
  • Be careful with /stop: According to slash-commands.md (line 51), /stop kills all running background processes. Do not run /stop as a routine cleanup step unless /agents shows a specific stuck background process that you have confirmed is safe to terminate.
  • Never delete ~/.hermes or ~/.hermes/state.db: Deleting the state directory wipes your persistent session database, cron schedules, and local configuration.

6. Related Upstream Error Guides

If hermes logs errors shows HTTP 500 responses, 529 Overloaded errors, or idle stream disconnects alongside truncation warnings, see Claude Code API Error 500 Troubleshooting, Fixing Claude API 529 Overloaded Errors, and Claude Stream Idle Timeout Guide.