Skip to content

Commit 8b6de56

Browse files
mios-devclaude
andcommitted
strip "Thought" prefix even when polish skipped
Operator-pasted chat 2026-05-18: "Hey there!" produced the answer "Thought\n\nHello! How can I assist you today? 😊" -- the literal "Thought" prefix leaked because: * polish_can_skip returned True (short clean output, no narration) * the skip path returned `raw_output` AS-IS without running _strip_reasoning_leaks * hermes uses qwen3.5:4b which is a reasoning-mode model that emits "Thought\n\n<answer>" -- _LEADING_THOUGHT_RE was designed to catch this but only ran on the polish output, not the skip path Fix: the skip-polish branch now runs _strip_outer_md_fence + _strip_reasoning_leaks before returning the raw text. Same two post-processors the polish branch already applies. Idempotent on already-clean text. Live verified end-to-end: input "Thought\n\nHello! How can I assist?" -> output "Hello! How can I assist?" via the skip-polish path. has_Thought_prefix=False. Pipe re-installed into OWUI db; OWUI restarted clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 39b74de commit 8b6de56

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

usr/share/mios/owui/pipes/mios_agent_pipe.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,16 @@ async def _polish_via_cpu(
949949
return raw_output
950950
if self._polish_can_skip(raw_output):
951951
await self._emit(emitter, "✓ clean → skip polish")
952-
return raw_output
952+
# Even on skip-polish, strip reasoning leaks ("Thought\n\n",
953+
# <think>...</think>, <details>...</details>) from the
954+
# raw text. Hermes uses reasoning-mode models that emit
955+
# these prefixes; the operator should never see them.
956+
# Operator-flagged 2026-05-18: "Hey there!" returned
957+
# "Thought\n\nHello! How can I assist you today?" because
958+
# polish skipped and the leading "Thought" passed through.
959+
cleaned = self._strip_outer_md_fence(raw_output)
960+
cleaned = self._strip_reasoning_leaks(cleaned)
961+
return cleaned or raw_output
953962

954963
# Try to load the structured tool history from Hermes session
955964
# JSON (OpenAI-format messages with tool_calls + tool_result).

0 commit comments

Comments
 (0)