Skip to content

fix: strip Qwen3-ASR output prefix from transcriptions - #8773

Closed
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:upstream/fix/qwen3-asr-prefix
Closed

fix: strip Qwen3-ASR output prefix from transcriptions#8773
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:upstream/fix/qwen3-asr-prefix

Conversation

@malaiwah

Copy link
Copy Markdown
Contributor

Qwen3-ASR (via vLLM/sglang OpenAI-compatible endpoint) returns transcriptions with a structured prefix:

language English<asr_text>Hello. This is the actual text.

This prefix was passed verbatim to the LLM as the user's voice message. On short utterances it could confuse the model.

Fix: strip everything up to and including <asr_text> in _extract_transcript_text(). The marker is XML-like and cannot appear in natural speech, so false positives are impossible. The if '<asr_text>' in text guard makes this a no-op for non-Qwen providers (Whisper, Groq, etc.).

Qwen3-ASR (via vLLM/sglang OpenAI-compatible endpoint) returns
transcriptions in the format:

  "language English<asr_text>Hello. This is the actual text."

The "language <LANG><asr_text>" prefix was being passed verbatim
to the LLM as the user's voice message, adding noise and potentially
confusing the model on short utterances.

Fix: strip everything up to and including the <asr_text> marker in
_extract_transcript_text(). The marker is specific enough that false
positives are impossible (no natural speech produces angle brackets).
The guard `if "<asr_text>" in text` makes this a no-op for non-Qwen
providers (Whisper, Groq, etc.).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have provider/qwen Qwen / Alibaba Cloud (OAuth) tool/tts Text-to-speech and transcription labels Apr 28, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying the Qwen3-ASR response shape. The premise remains valid on current main: tools/transcription_tools.py:1787 returns string responses unchanged except for whitespace, and the OpenAI-compatible path calls this helper at tools/transcription_tools.py:1360.

Problems

  • The diff's right-side tools/transcription_tools.py:105 replaces provider-aware model resolution with a raw flat stt.model lookup. This is unrelated to prefix stripping and drops documented behavior from the PR base; it should not be part of the salvage.
  • The diff has no regression test. Current OpenAI transcription coverage in tests/tools/test_managed_media_gateways.py:305-346 covers ordinary text/JSON responses but not the Qwen marker.

Suggested changes

  • Apply only the marker normalization to current main's _extract_transcript_text() (tools/transcription_tools.py:1784) and preserve the current configuration architecture.
  • Add direct regression cases for string, .text, and dictionary text responses containing <asr_text>.

Automated hermes-sweeper review.

return legacy
from hermes_cli.config import read_raw_config
return read_raw_config().get("stt", {}).get("model")
except Exception:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unrelated replacement drops the provider-aware model lookup. Please omit this hunk when salvaging the Qwen transcript normalization; the prefix fix does not require changing model-resolution behavior.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
@LauraGPT

Copy link
Copy Markdown
Contributor

I refreshed this valid fix on current main in #65534.

The replacement keeps the current provider-aware STT configuration behavior, applies <asr_text> normalization to string / SDK .text / dictionary responses, and adds direct regressions for all three shapes. The original contribution remains credited in the commit trailer.

Fresh validation on the replacement head: 235 related tests passed, plus Ruff, changed-range formatting, Python compilation, and diff checks. Since this branch is now reported as conflicting, centralizing the current-main review in #65534 avoids carrying the stale unrelated config diff forward.

LauraGPT added a commit to LauraGPT/hermes-agent that referenced this pull request Jul 17, 2026
Normalize the structured <asr_text> marker after extracting text from string, SDK object, and dictionary transcription responses. Preserve the current provider-aware STT configuration architecture.

Refreshes NousResearch#8773 on current main.

Co-authored-by: angelos <angelos@oikos.lan.home.malaiwah.com>

Assisted-by: Codex:gpt-5.6
teknium1 pushed a commit that referenced this pull request Jul 28, 2026
Normalize the structured <asr_text> marker after extracting text from string, SDK object, and dictionary transcription responses. Preserve the current provider-aware STT configuration architecture.

Refreshes #8773 on current main.

Co-authored-by: angelos <angelos@oikos.lan.home.malaiwah.com>

Assisted-by: Codex:gpt-5.6
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
Normalize the structured <asr_text> marker after extracting text from string, SDK object, and dictionary transcription responses. Preserve the current provider-aware STT configuration architecture.

Refreshes NousResearch#8773 on current main.

Co-authored-by: angelos <angelos@oikos.lan.home.malaiwah.com>

Assisted-by: Codex:gpt-5.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have provider/qwen Qwen / Alibaba Cloud (OAuth) sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/tts Text-to-speech and transcription type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants