Skip to content

feat: add reasoning middleware - #6340

Closed
snipeship wants to merge 1 commit into
anomalyco:devfrom
snipeship:feat/add-reasoning-middleware
Closed

snipeship wants to merge 1 commit into
anomalyco:devfrom
snipeship:feat/add-reasoning-middleware

Conversation

@snipeship

@snipeship snipeship commented Dec 29, 2025 •

Copy link
Copy Markdown
Contributor

Closes #6337, #4033, #3703


Adds a new interleaved object shape to model config with tagName (required) and optional startWithReasoning.
Read ai-sdk's extractReasoningMiddleware() as a reference.

Example config:

"models": {
  "model-name": {
    "reasoning": true,
    "interleaved": {
      "tagName": "think" // or other XML tag
      // "startWithReasoning": true
    },
  }
}

Before (see issue)

After:
Screenshot 2025-12-29 at 10 14 57

@snipeship

Copy link
Copy Markdown
Contributor Author

@rekram1-node

Copy link
Copy Markdown
Collaborator

wondering if there is anyway we could avoid additional configs and just always have it on, and then default to handling which should cover 90% of users and they wont have to do configs manually?

@snipeship

Copy link
Copy Markdown
Contributor Author

wondering if there is anyway we could avoid additional configs and just always have it on, and then default to handling which should cover 90% of users and they wont have to do configs manually?

opened #6463
doesn't close #3703 because of the different thinking tags
guess if there are more users facing this issue (or labs being annoying), we can revisit this solution with some logic from the other PR (on by default, change thinking tags, or disable the middleware through config)

@letsrock85

Copy link
Copy Markdown
 "models": {
        "minimax": {
          "name": "minimax",
          "tool_call": true,
          "reasoning": true,
          "interleaved": {
            "tagName": "think"
          },
image_2026-01-09_01-43-12

Do I need to pull a specific issue from the repository, or am I missing something?

@snipeship

Copy link
Copy Markdown
Contributor Author
 "models": {
        "minimax": {
          "name": "minimax",
          "tool_call": true,
          "reasoning": true,
          "interleaved": {
            "tagName": "think"
          },
image_2026-01-09_01-43-12 Do I need to pull a specific issue from the repository, or am I missing something?

it should work by default now on the latest build without adding anything to the config. if for some reason you need custom think tags (looks like you don’t) you can build from source from this branch

@letsrock85

Copy link
Copy Markdown

I use VS Code opencode extension on Windows, last updated 3 days ago, it throws an error when I add "interleaved": { "tagName": "think" }. " which I need for Opencode to properly parse minimax-m2's tag.
image

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

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.

[FEATURE]: support extracting reasoning XML

3 participants