SIGN IN SIGN UP

fix: stream reasoning_content in LM Studio provider (#1175)

* fix: stream reasoning_content in LM Studio provider

The LM Studio handler only read `delta.content` and relied on TagMatcher to
extract <think>/<thought> tags. Reasoning models served by LM Studio (Qwen3,
DeepSeek-R1, QwQ) stream thinking in a dedicated `reasoning_content` field,
which TagMatcher never sees, so the whole thought stream was dropped. The
same model via the OpenAI Compatible provider worked because that handler
already calls the shared `extractReasoningFromDelta` helper — LM Studio was
the last provider missing it.

Reasoning text is now also counted toward output tokens; thinking models
previously reported ~0 output tokens for turns that were mostly reasoning.

Fixes #1075

* test(lmstudio): assert reasoning_content wins over reasoning

Add the both-fields-present case for the LM Studio stream handler, mirroring
the existing test in openai.spec.ts. The handler calls
extractReasoningFromDelta once per delta, so a delta carrying both
reasoning_content and reasoning must yield exactly one reasoning chunk. The
helper's own unit tests cover the precedence rule in isolation, but no
provider-level test pinned it end-to-end here.

Asserting on the filtered array rather than a single membership check fixes
the chunk count too, so a regression that emits both fields is caught.

Signed-off-by: daewoongoh <dw.oh@samsung.com>

---------

Signed-off-by: daewoongoh <dw.oh@samsung.com>
D
dw committed
252c69b520825ae6cc3c9f3aec5671520c85037f
Parent: b7f78f8
Committed by GitHub <noreply@github.com> on 8/20/2026, 1:52:56 AM