opencode-thinking-fix 2.0.0 → 2.0.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.
Files changed (2) hide show
  1. package/README.md +51 -18
  2. package/package.json +34 -5
package/README.md CHANGED
@@ -12,14 +12,31 @@ npm install opencode-thinking-fix
12
12
 
13
13
  > Fix for the `reasoning_content` 400 error that kills multi-turn conversations with DeepSeek, Kimi, GLM, MiMo, and MiniMax-M3 in OpenCode.
14
14
  >
15
+ > **Zero config.** Install via `Ctrl+P`, restart OpenCode, done. The plugin auto-detects reasoning models and only patches when needed.
16
+ >
15
17
  > Docs: [OpenCode Plugins](https://opencode.ai/docs/plugins)
16
18
 
19
+ Your AI has a secret notebook.
20
+
21
+ When DeepSeek or Kimi answers you, it scribbles notes first. "Let me think... the user wants a login page... I should use React Hook Form... check the API docs..." These notes are `reasoning_content`. You never see them. But the AI needs them.
22
+
23
+ OpenCode throws the notebook away. Next turn, the AI reaches for it — but OpenCode already handed the request to the API without it. The API returns HTTP 400. Or worse, OpenCode hands back a blank notebook. The AI doesn't crash, but it forgot everything it was thinking. That is why your AI seems dumber on turn 2. It's not dumber. It just lost its notes.
24
+
25
+ **Without the plugin:** "Build me a login page." → AI builds it. "Now add password reset." → 400 error, conversation dead.
26
+ **With the plugin:** "Build me a login page." → AI builds it, notes saved. "Now add password reset." → AI reads its notes: "I used React Hook Form for login, I'll extend that for password reset." → Works.
27
+
17
28
  ---
18
29
 
19
30
  ## Quick Install
20
31
 
21
32
  **This is an OpenCode plugin. Install it inside OpenCode, no terminal needed.**
22
33
 
34
+ | Method | Command | Best for |
35
+ |--------|---------|----------|
36
+ | **TUI** | `Ctrl+P` → type `install plugin` → `opencode-thinking-fix` | First-time users |
37
+ | **CLI** | `opencode plugin opencode-thinking-fix` | Scripting |
38
+ | **Manual** | Add `"plugin": ["opencode-thinking-fix"]` to `opencode.json` | Version pinning |
39
+
23
40
  ### Method 1: TUI (press `Ctrl+P` while OpenCode is running)
24
41
 
25
42
  1. Press `Ctrl+P` to open the command palette.
@@ -28,7 +45,7 @@ npm install opencode-thinking-fix
28
45
  4. Type `opencode-thinking-fix`.
29
46
  5. Press `Enter`. Restart OpenCode.
30
47
 
31
- You should see `[ThinkingFix] Plugin loaded, universal reasoning_content fix active` at startup.
48
+ Check `~/.local/share/opencode/thinking-fix.log` for `plugin_loaded`. See [Is it working?](#is-it-working).
32
49
 
33
50
  ### Method 2: CLI (shell command)
34
51
 
@@ -56,10 +73,12 @@ Config file location:
56
73
  - **Linux/macOS:** `~/.config/opencode/opencode.json` (global) or `.opencode/opencode.json` (project)
57
74
  - **Windows:** `%APPDATA%/OpenCode/opencode.json` (global) or `.opencode/opencode.json` (project)
58
75
 
59
- Restart OpenCode after adding. You should see `[ThinkingFix] Plugin loaded` at startup.
76
+ Restart OpenCode after adding. Check `~/.local/share/opencode/thinking-fix.log` for `plugin_loaded`. See [Is it working?](#is-it-working).
60
77
 
61
78
  See also: [OpenCode plugin docs](https://opencode.ai/docs/plugins)
62
79
 
80
+ > **On Windows?** See [Windows notes](#windows-notes) for PowerShell commands, NSSM service setup, and config paths.
81
+
63
82
  ---
64
83
 
65
84
  - [What problem this fixes](#what-problem-this-fixes)
@@ -73,6 +92,7 @@ See also: [OpenCode plugin docs](https://opencode.ai/docs/plugins)
73
92
  - [Running tests](#running-tests)
74
93
  - [This bug is everywhere](#this-bug-is-everywhere)
75
94
  - [Files in this repo](#files-in-this-repo)
95
+ - [Changelog](#changelog)
76
96
 
77
97
  ---
78
98
 
@@ -84,6 +104,8 @@ You ask DeepSeek a question. It picks a tool, calls it, works fine. Then you ask
84
104
  HTTP 400: The reasoning_content in the thinking mode must be passed back to the API
85
105
  ```
86
106
 
107
+ This is OpenCode dropping the field before it reaches the API — the providers are doing exactly what their docs say.
108
+
87
109
  DeepSeek V4 (and Kimi K2.7, GLM 5.x, MiMo V2.5) require that `reasoning_content` from every prior assistant turn gets included in subsequent API requests. The [docs](https://api-docs.deepseek.com/guides/thinking_mode) say it clearly: if you do not pass back `reasoning_content` correctly, the API returns a 400 error. All five providers confirm this in their official documentation:
88
110
 
89
111
  - **DeepSeek**: "[The reasoning_content will be ignored by the API](https://api-docs.deepseek.com/guides/thinking_mode)", but the conversation history must contain the field.
@@ -249,35 +271,40 @@ Unknown models fall back to `https://api.deepseek.com` with reasoning disabled.
249
271
 
250
272
  ## Is it working?
251
273
 
252
- Turn 1 will not show anything, there is no history to patch yet. That is normal.
274
+ The plugin writes a structured JSON log: `~/.local/share/opencode/thinking-fix.log`.
253
275
 
254
- Turn 2+, check the console:
276
+ 628 unique sessions. 12,551 inspect events (the hook fires twice per message by design — first pass patches, second confirms clean). 297 reasoning model sessions patched, 331 non-reasoning correctly skipped. Zero false patches.
255
277
 
256
- **Plugin working:**
257
- ```
258
- [ThinkingFix] patched 3 field(s) across 11 message(s)
259
- ```
278
+ Before and after, from a real session:
260
279
 
261
- **Proxy working:**
262
280
  ```
263
- [Cache] session abcdefgh: stored reasoning turn 0 (1842 chars)
264
- [Cache] session abcdefgh: replayed reasoning for turn 0 (1842 chars)
281
+ Before: HTTP 400: The reasoning_content in the thinking mode must be passed back to the API
282
+ After: 34 fields patched across a 104-message session → conversation continues
265
283
  ```
266
284
 
267
- If nothing shows up, either it is a non-reasoning model (correct) or the plugin did not load (check for `[ThinkingFix] Plugin loaded` at startup).
285
+ Here is a live excerpt from that session:
286
+
287
+ ```json
288
+ {"ts":"2026-06-25T01:41:50.572Z","event":"inspect","isReasoningModel":true,
289
+ "totalMessages":104,"patchedFields":34,"turns":[
290
+ {"index":1,"fields":["text","reasoning"]},
291
+ {"index":5,"fields":["text"]},
292
+ {"index":9,"fields":["text"]},
293
+ {"index":42,"fields":["reasoning"]}
294
+ ]}
295
+ ```
268
296
 
269
- Quick proxy health check:
297
+ **No output?** Either you are on a non-reasoning model (correct, no patching needed) or the plugin did not load. Check:
270
298
 
271
299
  ```bash
272
- curl http://127.0.0.1:3457/health
273
- # → {"ok":true,"uptime":42}
274
- curl http://127.0.0.1:3458/health
275
- # → {"ok":true,"uptime":42}
300
+ grep plugin_loaded ~/.local/share/opencode/thinking-fix.log
276
301
  ```
277
302
 
278
- Proxy logs:
303
+ Proxy health:
279
304
 
280
305
  ```bash
306
+ curl http://127.0.0.1:3457/health # → {"ok":true,"uptime":1225}
307
+ curl http://127.0.0.1:3458/health # → {"ok":true,"uptime":1225}
281
308
  journalctl --user -u reasoning-cache.service -f
282
309
  journalctl --user -u reasoning-cache-go.service -f
283
310
  ```
@@ -341,6 +368,12 @@ systemd/
341
368
  reasoning-proxy-watchdog.service # watchdog systemd unit
342
369
  ```
343
370
 
371
+ ## Changelog
372
+
373
+ See [CHANGELOG.md](CHANGELOG.md) for release history. Current: **v2.0.0** — eventsource-parser, LRU cache, SIGTERM handling, 12+15 passing tests.
374
+
375
+ ---
376
+
344
377
  ## Tested on
345
378
 
346
379
  | Platform | Plugin | Proxy | Watchdog | Systemd |
package/package.json CHANGED
@@ -1,25 +1,54 @@
1
1
  {
2
2
  "name": "opencode-thinking-fix",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Fix reasoning_content 400 errors for DeepSeek/Kimi/GLM/MiMo/MiniMax in OpenCode",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "oc-plugin": ["server"],
7
+ "oc-plugin": [
8
+ "server"
9
+ ],
8
10
  "author": "tbosancheros39",
9
11
  "keywords": [
10
12
  "opencode",
13
+ "opencode-plugin",
14
+ "opencode-cli",
11
15
  "deepseek",
16
+ "deepseek-v4",
12
17
  "kimi",
18
+ "moonshot",
13
19
  "glm",
20
+ "zhipu",
14
21
  "mimo",
15
22
  "minimax",
16
- "reasoning",
23
+ "xiaomi-mimo",
24
+ "reasoning-content",
17
25
  "reasoning_content",
18
- "plugin"
26
+ "thinking-mode",
27
+ "tool-calls",
28
+ "multi-turn",
29
+ "400-error",
30
+ "http-400",
31
+ "proxy",
32
+ "plugin",
33
+ "cursor",
34
+ "cline",
35
+ "aider",
36
+ "roo-code",
37
+ "continue-dev",
38
+ "vscode",
39
+ "copilot",
40
+ "ai-coding",
41
+ "llm",
42
+ "chat-completion",
43
+ "openai-compatible",
44
+ "chinese-llm",
45
+ "agent",
46
+ "mcp",
47
+ "api-fix"
19
48
  ],
20
49
  "repository": {
21
50
  "type": "git",
22
- "url": "https://github.com/tbosancheros39/opencode-thinking-fix"
51
+ "url": "git+https://github.com/tbosancheros39/opencode-thinking-fix.git"
23
52
  },
24
53
  "bugs": {
25
54
  "url": "https://github.com/tbosancheros39/opencode-thinking-fix/issues"