[Bug] Call agent reads a reasoning model's thinking aloud when the chat template prefills <think>

Author: FenjuFuCreated Sep 29, 2026Updated Sep 29, 2026

Before filing

  • I searched existing issues and this isn't a duplicate.
  • I'm on the latest release (or main).

What happened?

With a local reasoning model whose chat template prefills <think>, the call agent reads its reasoning aloud to the person on the phone, in the user's voice. Spark-X2.5, the Qwen3 thinking variants and DeepSeek-R1-0528 all use such templates. The reasoning is also saved in the call transcript and the agent's history.

It's the streaming version of #2420. ReplyParser._body (backend/services/telephony/agent.py:229) only skips reasoning that starts with <think>. When the template has already written the opening tag into the prompt, a server without a reasoning parser streams …reasoning</think>SAY: …. There's no opening tag, so as soon as the first characters can't be the start of SAY:, the parser settles on plain mode and every reasoning sentence goes to the SentenceChunker and on to TTS. The </think> and SAY: get spoken too.

This affects the phone call feature (#2306), so the text reaches a third party, not only the user. It can include anything the model was thinking about: the brief, whether it's allowed to reveal something, and so on.

Steps to reproduce

This uses the real parser and chunker from main, with no LLM and no telephony:

python
from services.telephony.agent import ReplyParser
from services.sentence_chunker import SentenceChunker

def spoken(chunks):
    p, c, out = ReplyParser(), SentenceChunker(language="en", aggressive_first_flush=True), []
    for d in chunks:
        out += c.push(p.feed(d))
    return out + c.push(p.finish()) + c.flush()

reply = ["The caller", " asked for the booking name. The brief says Palash. ",
         "I should confirm and end.\n</think>\n\nSAY: It's under Palash. Thank you, goodbye.\nACTION: end_call"]

print(spoken(reply))            # prefilled template
print(spoken(["<think>"] + reply))  # same reply with the opening tag

Output:

['The caller asked for the booking name.', 'The brief says Palash.', 'I should confirm and end.', "</think>  SAY: It's under Palash.", 'Thank you, goodbye.']
["It's under Palash. Thank you, goodbye."]

With a real stack: serve Spark-X2.5 with the vLLM command from its README (no --reasoning-parser, thinking on by default), select it as the LLM, and place a call. I haven't run this end to end myself because I have no GPU or Twilio setup here. The parser output above is the same code path.

What did you expect instead?

The reasoning is never spoken or recorded. Only the SAY: text reaches TTS, and the action and outcome still parse.

Once the first sentence has been spoken it can't be taken back, so the parser can't wait until the end of the reply to decide. Two options, which could also be combined:

  1. Parser side (covers any server). The system prompt requires the reply to start with SAY: or {. If the body starts with anything else, hold it back instead of speaking it right away. If a bare </think> (or a SAY: at the start of a line) appears later, drop everything before it and continue as tagged. If the stream ends without either, speak it as plain text, as it does now. Models that follow the format keep first-sentence streaming. Only replies that ignore the format lose it.
  2. Request side (lower latency). Ask for no thinking on the call path, the same way dictation passes reasoning_effort="none". Prefilled templates such as Spark-X2.5 only read chat_template_kwargs.enable_thinking, and OpenAI rejects unknown fields, so this needs the same reject-and-remember retry llm_backend already has for reasoning_effort. It also doesn't help when a server ignores the flag, so I don't think it can be the only fix.

I'd go with 1, and optionally add 2 for latency. I'm happy to send a PR for whichever you prefer.

Operating system

Any. This is backend logic only and doesn't depend on the OS or GPU.

How did you install it?

From source

Version

main @ eef0e23

Compute device

N/A

Anything else?

The end-of-call summary goes through chat_messages, which uses _strip_reasoning. #2425 (for #2420) makes that handle prefilled templates, so only the live, spoken path is left.

Source: debpalash/OmniVoice-Studio