opencode-thinking-fix 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -7
- package/package.json +15 -2
- package/plugins/opencode-thinking-fix-universal.ts +2 -2
- package/proxy/proxy.js +20 -0
package/README.md
CHANGED
|
@@ -9,7 +9,47 @@
|
|
|
9
9
|
npm install opencode-thinking-fix
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
> Fix for the `reasoning_content` 400 error that kills multi-turn conversations with DeepSeek, Kimi, GLM, and
|
|
12
|
+
> Fix for the `reasoning_content` 400 error that kills multi-turn conversations with DeepSeek, Kimi, GLM, MiMo, and MiniMax-M3 in OpenCode.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Quick Install
|
|
17
|
+
|
|
18
|
+
**This is an OpenCode plugin. Install it inside OpenCode — no terminal needed.**
|
|
19
|
+
|
|
20
|
+
### Method 1: TUI (press Ctrl+P while OpenCode is running)
|
|
21
|
+
|
|
22
|
+
1. Press `Ctrl+P` to open the command palette
|
|
23
|
+
2. Type `install plugin` and press Enter
|
|
24
|
+
3. Press `Tab` to switch scope to **Global** (recommended — works across all projects)
|
|
25
|
+
4. Type `opencode-thinking-fix`
|
|
26
|
+
5. Press Enter — done. Restart OpenCode.
|
|
27
|
+
|
|
28
|
+
### Method 2: CLI (shell command)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
opencode plugin opencode-thinking-fix
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For specific version:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
opencode plugin opencode-thinking-fix@1.1.0
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Method 3: Manual config (add to opencode.json)
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"plugin": ["opencode-thinking-fix"]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Config file location:
|
|
49
|
+
- **Linux/macOS:** `~/.config/opencode/opencode.json` (global) or `.opencode/opencode.json` (project)
|
|
50
|
+
- **Windows:** `%APPDATA%/OpenCode/opencode.json` (global) or `.opencode/opencode.json` (project)
|
|
51
|
+
|
|
52
|
+
Restart OpenCode after adding. You should see `[ThinkingFix] Plugin loaded` at startup.
|
|
13
53
|
|
|
14
54
|
## Table of Contents
|
|
15
55
|
|
|
@@ -45,7 +85,13 @@ This repo fixes it. Three layers, pick what you need.
|
|
|
45
85
|
|
|
46
86
|
## Option 1: plugin (stops the crashes)
|
|
47
87
|
|
|
48
|
-
|
|
88
|
+
### Install via npm (recommended)
|
|
89
|
+
|
|
90
|
+
See [Quick Install](#quick-install) above — use OpenCode TUI (`Ctrl+P`) or CLI (`opencode plugin opencode-thinking-fix`).
|
|
91
|
+
|
|
92
|
+
### Manual install (for local development)
|
|
93
|
+
|
|
94
|
+
Drop the plugin file in your OpenCode plugins directory and restart:
|
|
49
95
|
|
|
50
96
|
```bash
|
|
51
97
|
mkdir -p ~/.config/opencode/plugins
|
|
@@ -80,13 +126,15 @@ The proxy runs on **two ports**:
|
|
|
80
126
|
Port 3457 auto-routes based on model name using the built-in route table. Port 3458 is a fixed-upstream proxy specifically for the OpenCode Go provider, which uses `delta.reasoning` (not `reasoning_content`) in its SSE streams. Both are handled by the same `proxy.js` binary — just different environment variables.
|
|
81
127
|
|
|
82
128
|
```bash
|
|
83
|
-
#
|
|
129
|
+
# Linux / macOS / Windows (Node.js required)
|
|
84
130
|
node proxy/proxy.js
|
|
85
131
|
|
|
86
|
-
#
|
|
132
|
+
# OpenCode Go proxy
|
|
87
133
|
PORT=3458 UPSTREAM_URL=https://opencode.ai/zen/go/v1 node proxy/proxy.js
|
|
88
134
|
```
|
|
89
135
|
|
|
136
|
+
> **Windows PowerShell:** use `$env:PORT=3457; node proxy/proxy.js` (PowerShell) or `set PORT=3457 && node proxy/proxy.js` (CMD).
|
|
137
|
+
|
|
90
138
|
### Install as systemd services (auto-start at boot)
|
|
91
139
|
|
|
92
140
|
```bash
|
|
@@ -153,9 +201,10 @@ The plugin is the safety net. If the proxy goes down, the plugin still injects e
|
|
|
153
201
|
| Kimi K2.5 / K2.6 | Yes | Nice to have | Accepts `""` |
|
|
154
202
|
| **Kimi K2.7 Code** | **Not enough alone** | **Required** | Needs real text |
|
|
155
203
|
| GLM-5.x / Zhipu | Yes | Nice to have | Accepts `""` |
|
|
156
|
-
| MiMo V2.5 / MiniMax | Yes | Nice to have | Accepts `""` |
|
|
204
|
+
| MiMo V2.5 / MiniMax | Yes | Nice to have | Accepts `""` (default mode embeds `<think>` in `content`) |
|
|
205
|
+
| **MiniMax-M3** | Yes | **Recommended** | `reasoning_details[]` array format; ~40% quality loss if stripped |
|
|
157
206
|
| OpenCode Go | Yes | Required | Uses `reasoning` field |
|
|
158
|
-
| Qwen, GPT, Claude, Gemini, Llama, Mistral | No | No |
|
|
207
|
+
| Qwen, GPT, Claude, Gemini, Llama, Mistral | No | No | No reasoning_content |
|
|
159
208
|
|
|
160
209
|
---
|
|
161
210
|
|
|
@@ -277,4 +326,40 @@ systemd/
|
|
|
277
326
|
|
|
278
327
|
## Tested on
|
|
279
328
|
|
|
280
|
-
|
|
329
|
+
| Platform | Plugin | Proxy | Watchdog | Systemd |
|
|
330
|
+
|----------|--------|-------|----------|---------|
|
|
331
|
+
| **Linux** (Kubuntu 24.04) | ✅ | ✅ | ✅ (bash) | ✅ |
|
|
332
|
+
| **macOS** | ✅ | ✅ | ✅ (bash) | ❌ (use launchd) |
|
|
333
|
+
| **Windows** | ✅ | ✅ | ❌ (bash) | ❌ |
|
|
334
|
+
|
|
335
|
+
OpenCode v1.17.9+, DeepSeek V4 Pro, Kimi K2.5/K2.6/K2.7, GLM-5.x, MiMo V2.5, MiniMax-M3, OpenCode Go.
|
|
336
|
+
|
|
337
|
+
### Windows notes
|
|
338
|
+
|
|
339
|
+
**Plugin and proxy work fully on Windows.** The proxy (`proxy.js`) uses only Node.js built-in modules (`http`, `https`, `url`) — zero platform-specific code. Start it with:
|
|
340
|
+
|
|
341
|
+
```powershell
|
|
342
|
+
# PowerShell
|
|
343
|
+
$env:PORT=3457; node proxy\proxy.js
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Watchdog and systemd are Linux-only.** For Windows auto-restart, use **Task Scheduler** or **NSSM** (Non-Sucking Service Manager) to run the proxy as a Windows service:
|
|
347
|
+
|
|
348
|
+
```powershell
|
|
349
|
+
# Using NSSM (install once: winget install nssm)
|
|
350
|
+
nssm install ReasoningCacheProxy node.exe proxy\proxy.js
|
|
351
|
+
nssm set ReasoningCacheProxy AppDirectory C:\path\to\opencode-thinking-fix
|
|
352
|
+
nssm set ReasoningCacheProxy AppEnvironmentExtra PORT=3457
|
|
353
|
+
nssm start ReasoningCacheProxy
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Repeat for the Go proxy on PORT=3458 with `UPSTREAM_URL=https://opencode.ai/zen/go/v1`.
|
|
357
|
+
|
|
358
|
+
**OpenCode config paths on Windows:**
|
|
359
|
+
|
|
360
|
+
| Scope | Path |
|
|
361
|
+
|-------|------|
|
|
362
|
+
| Global | `%APPDATA%\OpenCode\opencode.json` |
|
|
363
|
+
| Project | `<project>\.opencode\opencode.json` |
|
|
364
|
+
| Plugins dir | `%APPDATA%\OpenCode\plugins\` |
|
|
365
|
+
| npm cache | `%LOCALAPPDATA%\opencode\node_modules\` |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-thinking-fix",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Fix DeepSeek/Kimi/GLM/MiMo reasoning_content 400 errors in OpenCode. Plugin + proxy + watchdog.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "tbosancheros39",
|
|
@@ -17,7 +17,17 @@
|
|
|
17
17
|
],
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/tbosancheros39/opencode-thinking-fix.git"
|
|
20
|
+
"url": "git+https://github.com/tbosancheros39/opencode-thinking-fix.git"
|
|
21
|
+
},
|
|
22
|
+
"oc-plugin": [
|
|
23
|
+
"server"
|
|
24
|
+
],
|
|
25
|
+
"main": "./plugins/opencode-thinking-fix-universal.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
"./server": {
|
|
28
|
+
"import": "./plugins/opencode-thinking-fix-universal.ts",
|
|
29
|
+
"types": "./plugins/opencode-thinking-fix-universal.ts"
|
|
30
|
+
}
|
|
21
31
|
},
|
|
22
32
|
"files": [
|
|
23
33
|
"plugins/",
|
|
@@ -31,5 +41,8 @@
|
|
|
31
41
|
],
|
|
32
42
|
"scripts": {
|
|
33
43
|
"test": "node tests/test-plugin.js && node tests/test-proxy.js"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@opencode-ai/plugin": "^1.3.0"
|
|
34
47
|
}
|
|
35
48
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin } from '@opencode-ai/plugin'
|
|
1
|
+
import type { Plugin, PluginModule } from '@opencode-ai/plugin'
|
|
2
2
|
|
|
3
3
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
4
|
// CONFIRMED FACTS (cross-validated across DeepSeek V4 Pro, Claude MAX, Kimi
|
|
@@ -103,4 +103,4 @@ export const ThinkingFixPlugin: Plugin = async ({ client }) => {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
export default ThinkingFixPlugin
|
|
106
|
+
export default { server: ThinkingFixPlugin } satisfies PluginModule
|
package/proxy/proxy.js
CHANGED
|
@@ -115,6 +115,16 @@ function patchRequestBody(body, sessionId) {
|
|
|
115
115
|
modified = true
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// MiniMax-M3 reasoning_details array format (reasoning_split: true)
|
|
119
|
+
if (!msg.reasoning_details && !msg.reasoning_content) {
|
|
120
|
+
const cached = sessionCache.get(assistantIndex)
|
|
121
|
+
if (cached) {
|
|
122
|
+
msg.reasoning_details = [{ text: cached, type: 'thinking' }]
|
|
123
|
+
console.log(`[Cache] session ${sessionId.slice(-8)}: replayed reasoning_details for turn ${assistantIndex} (${cached.length} chars)`)
|
|
124
|
+
modified = true
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
118
128
|
// OpenCode Go uses reasoning instead of reasoning_content
|
|
119
129
|
if (!msg.reasoning) {
|
|
120
130
|
const cached = sessionCache.get(assistantIndex)
|
|
@@ -168,6 +178,16 @@ function createStreamParser(sessionId, onComplete) {
|
|
|
168
178
|
inReasoning = true
|
|
169
179
|
}
|
|
170
180
|
|
|
181
|
+
// reasoning_details array (MiniMax-M3 with reasoning_split: true)
|
|
182
|
+
if (Array.isArray(delta.reasoning_details)) {
|
|
183
|
+
for (const detail of delta.reasoning_details) {
|
|
184
|
+
if (typeof detail.text === 'string') {
|
|
185
|
+
reasoningBuffer += detail.text
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
inReasoning = true
|
|
189
|
+
}
|
|
190
|
+
|
|
171
191
|
// OpenCode Go uses delta.reasoning instead of reasoning_content
|
|
172
192
|
if (typeof delta.reasoning === 'string') {
|
|
173
193
|
reasoningBuffer += delta.reasoning
|