hermes - 💡(How to fix) Fix [Bug]: LLM responses returned without spaces between words via api_server path (related to #2049, not covered by 1173adbe8)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

[7] assistant: "Error:modelservicesisnotavailable.therequestmightbeinvalid,pleasecheckapirequestandyourAPIkey."

Code Example

[7] assistant: "Error:modelservicesisnotavailable.therequestmightbeinvalid,pleasecheckapirequestandyourAPIkey."

---

[1]  (clean)   "Hey there! How can I assist you today?"
[3]  (clean)   "Error: Invalid API key"
[5]  (clean)   "Error: Stream error: aborted"
[7]  (BROKEN)  "Error:modelservicesisnotavailable.therequest..."
[9]  (BROKEN)  "ThisisClaude-3.0-Sonic-24B-HF,theremote..."
[11] (BROKEN)  "I'mClaude-3.0-Sonic-24B-HF,theremoteDeepHermesmodel."

---

- chunk_text = str(content.get("text") or "").strip()
+ chunk_text = str(content.get("text") or "")

---

Hermes Agent v0.13.0 (2026.5.7)
Git HEAD:   c23a87bc1 union paid recs from nous portal with static list (#24509)
Python:     3.11.13
OpenAI SDK: 2.24.0
OS:         macOS 26.5 (Darwin 25.5.0), M4 Max
Client:     Hermes Desktop v0.3.5 (com.nousresearch.hermes / fathah/hermes-desktop)
Backend:    Reproduced with local oMLX (DeepHermes-3-Mistral-24B-Preview-4bit, 127.0.0.1:8000)
            AND with a separate remote Hermes server (different model). Independent of LLM provider.
RAW_BUFFERClick to expand / collapse

[Bug]: LLM responses returned without spaces between words via api_server path (related to #2049, not covered by 1173adbe8)

Bug Description

Same symptom as the closed issue #2049 — assistant streaming responses arrive with all inter-word whitespace stripped:

Expected: Hey there! I noticed your request earlier, but I noticed that message had issues. What changes should I make to my answer to help better?

Actual: Heythere!Inoticedyourrequestearlier,butInoticedthatmessagehadissues.WhatchangesshouldImaketomyanswertohelpbetter?

But this is not the ACP path that #2049 / 1173adbe8 fixed. It manifests on the api_server path: an OpenAI-compatible HTTP client (Hermes Desktop v0.3.5 in my case, but presumably reproducible with any OpenAI client) talking to gateway/platforms/api_server.py over /v1/chat/completions. The fix pattern from 1173adbe8 (remove per-chunk .strip() on streaming content) has not been applied to this path.

Strongest evidence — bug appears in a hard-coded server error string

~/.hermes/sessions/session_api-<hash>.json from an affected session contains:

[7] assistant: "Error:modelservicesisnotavailable.therequestmightbeinvalid,pleasecheckapirequestandyourAPIkey."

That string never went through any LLM. It is a hard-coded server-side error message, and it is corrupted with the same whitespace-stripping pattern as model output. This rules out:

  • LLM tokenizer / detokenizer issues
  • The desktop UI / Electron renderer
  • The SSE wire format (verified clean — direct curl against the same api_server produces "Hello", " there", " friend" with correct leading spaces; same for upstream providers tested)
  • The desktop's own SSE parser (read the source; preserves whitespace)

The bug must be on the server side, in the path between agent text generation/error construction and SSE chunk emission.

Trigger pattern

Bug is intermittent. First-turn responses in a fresh session are reliably clean. The bug triggers after multi-turn activity that includes errors. From session_api-<hash>.json:

[1]  (clean)   "Hey there! How can I assist you today?"
[3]  (clean)   "Error: Invalid API key"
[5]  (clean)   "Error: Stream error: aborted"
[7]  (BROKEN)  "Error:modelservicesisnotavailable.therequest..."
[9]  (BROKEN)  "ThisisClaude-3.0-Sonic-24B-HF,theremote..."
[11] (BROKEN)  "I'mClaude-3.0-Sonic-24B-HF,theremoteDeepHermesmodel."

Once it starts, it persists for the rest of the session. + (new chat) clears it.

Steps to Reproduce

  1. Run hermes-agent v0.13.0 with api_server enabled on 127.0.0.1:8642.
  2. Point any OpenAI-compatible streaming client at it.
  3. Hold a multi-turn conversation that hits at least one error mid-stream (wrong key, aborted request, etc.) and then continues.
  4. After the error path, subsequent assistant content starts arriving with all whitespace stripped.

Direct single-shot curl against the same server does not reproduce the bug — chunks arrive correctly spaced. The trigger requires accumulated agent state (likely error-recovery or post-abort path).

Suspect code regions

Commit 1173adbe8 fix(acp): preserve leading whitespace in streaming chunks removed per-chunk .strip() calls in agent/copilot_acp_client.py:

- chunk_text = str(content.get("text") or "").strip()
+ chunk_text = str(content.get("text") or "")

The same family of bug is likely present in one of:

  • The api_server's delta forwarding (between _on_delta at gateway/platforms/api_server.py:1093 and the SSE writer near line 1349).
  • An error-message construction path (since [7] above is a hard-coded error that is also corrupted).
  • The list-content normalizer near agent/copilot_acp_client.py:200-210 still has parts.append(text.strip()) followed by "\n".join(parts).strip() — if this helper is reused by the api_server, it would be a direct match for the bug.

Environment

Hermes Agent v0.13.0 (2026.5.7)
Git HEAD:   c23a87bc1 union paid recs from nous portal with static list (#24509)
Python:     3.11.13
OpenAI SDK: 2.24.0
OS:         macOS 26.5 (Darwin 25.5.0), M4 Max
Client:     Hermes Desktop v0.3.5 (com.nousresearch.hermes / fathah/hermes-desktop)
Backend:    Reproduced with local oMLX (DeepHermes-3-Mistral-24B-Preview-4bit, 127.0.0.1:8000)
            AND with a separate remote Hermes server (different model). Independent of LLM provider.

Related

  • #2049 — same symptom, ACP path, closed
  • Commit 1173adbe8 — fix that was applied only to ACP path
  • (Distinct from #21760 and #10942 — those are chunk-truncation bugs; this is whitespace-stripping.)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING