feat: add reasoning middleware
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:
as discussed here: https://discord.com/channels/1391832426048651334/1394667004979445931/1455066042056441982 cc @rekram1-node
wondering if there is anyway we could avoid additional configs and just always have it on, and then default to handling
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 https://github.com/sst/opencode/issues/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)
"models": {
"minimax": {
"name": "minimax",
"tool_call": true,
"reasoning": true,
"interleaved": {
"tagName": "think"
},
Do I need to pull a specific issue from the repository, or am I missing something?
"models": { "minimax": { "name": "minimax", "tool_call": true, "reasoning": true, "interleaved": { "tagName": "think" },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
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
Do I need to pull a specific issue from the repository, or am I missing something?