Skip to content

feat(livekit): make reasoning middleware configurable per model - #1902

Draft
icycodes wants to merge 4 commits into
mainfrom
feat/configurable-reasoning-middleware
Draft

feat(livekit): make reasoning middleware configurable per model#1902
icycodes wants to merge 4 commits into
mainfrom
feat/configurable-reasoning-middleware

Conversation

@icycodes

Copy link
Copy Markdown
Member

Summary

  • Add a useReasoningMiddleware model flag so reasoning-tag extraction can be enabled/disabled per model, wired through the config schema, display-model mapping, and LLM request data.
  • Support <think>-style reasoning tags that carry attributes (not just a bare <think> tag), preserving them for later use.
  • Fix a multi-turn round-trip bug: extracted reasoning was being replayed as an SDK reasoning part, which providers either dropped or mapped to a field the model never wrote. Assistant reasoning is now re-serialized back into its original tag (attributes included) before the request leaves the client.
  • Regenerate assets/config.schema.json to include the new useReasoningMiddleware field.

Test plan

  • bun run test in packages/livekit (reasoning-middleware tests cover tag-with-attributes parsing and the multi-turn echo-back round trip)
  • bun check / bun tsc at repo root

🤖 Generated with Pochi | Task

icycodes and others added 4 commits August 19, 2026 13:30
The reasoning middleware was only enabled by a hardcoded well-known model
list, so users could not turn it on for their own <think>-emitting models.
Expose it as a `useReasoningMiddleware` model option (like
`useToolCallMiddleware`), keeping the well-known list as fallback.

🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-c1444bad2f084203a178cac40505c024)

Co-Authored-By: Pochi <noreply@getpochi.com>
Models such as GLM emit signed thinking blocks like <think signature="...">,
which the reasoning middleware previously failed to detect because it only
matched the bare <think> tag. Parse attributes on the opening tag and keep
them in the reasoning part provider metadata so they are not lost.

🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-c1444bad2f084203a178cac40505c024)

Co-Authored-By: Pochi <noreply@getpochi.com>
A multi-turn round-trip test showed the extracted reasoning was replayed as
an SDK reasoning part, so providers either dropped it or mapped it to a
field the model never wrote. Re-serialize assistant reasoning into the
original tag (attributes included) before the request leaves the client.

🤖 Generated with [Pochi](https://getpochi.com) | [Task](https://app.getpochi.com/share/p-c1444bad2f084203a178cac40505c024)

Co-Authored-By: Pochi <noreply@getpochi.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.02%. Comparing base (1d09b87) to head (71f52d9).

Files with missing lines Patch % Lines
packages/cli/src/cli.ts 0.00% 4 Missing ⚠️
...ebui/src/features/chat/lib/display-model-to-llm.ts 0.00% 4 Missing ⚠️
packages/common/src/vendor/types.ts 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (40.00%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1902   +/-   ##
=======================================
  Coverage   37.02%   37.02%           
=======================================
  Files         770      770           
  Lines       81194    81209   +15     
  Branches     3646     3646           
=======================================
+ Hits        30065    30071    +6     
- Misses      51014    51023    +9     
  Partials      115      115           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants