opencode-thinking-fix 2.0.1 → 3.2.0

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 CHANGED
@@ -10,7 +10,7 @@
10
10
  npm install opencode-thinking-fix
11
11
  ```
12
12
 
13
- > Fix for the `reasoning_content` 400 error that kills multi-turn conversations with DeepSeek, Kimi, GLM, MiMo, and MiniMax-M3 in OpenCode.
13
+ > Restores reasoning content that clients and SDKs drop from multi-turn conversations — DeepSeek, Kimi, GLM, MiMo, MiniMax, and OpenCode Go.
14
14
  >
15
15
  > **Zero config.** Install via `Ctrl+P`, restart OpenCode, done. The plugin auto-detects reasoning models and only patches when needed.
16
16
  >
@@ -20,13 +20,82 @@ Your AI has a secret notebook.
20
20
 
21
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
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.
23
+ The client and its SDK throw the notebook away. Next turn, the AI reaches for it — but the request already went to the API without it. The request carries no notes, or 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
+ The drop happens in SDK serializers and client transforms (truthy checks, missing type members, stripped signatures), not in the providers — the providers are doing exactly what their docs say.
26
+
27
+ **Without the plugin:** "Build me a login page." → AI builds it. "Now add password reset." → AI lost its notes, conversation degrades.
24
28
 
25
- **Without the plugin:** "Build me a login page." → AI builds it. "Now add password reset." → 400 error, conversation dead.
26
29
  **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
30
 
28
31
  ---
29
32
 
33
+ ## ELI15 — what this thing actually does
34
+
35
+ Imagine you're doing homework with a friend (the AI) over text messages. Your friend is smart but **forgetful between messages**. Every time they answer, they first scribble their thinking on a **sticky note** (that's `reasoning_content`) — but you never see the note, and the note gets **thrown away** before your friend reads the next message.
36
+
37
+ So when you say "ok now change the color," your friend has no memory of *why* they picked the blue button, gets confused, and gives a worse answer (the "dumber on turn 2" feeling).
38
+
39
+ Three facts make this messy:
40
+
41
+ 1. **The sticky notes are non-standard.** Normal chat apps don't have a "thinking note" field. So the tool that carries your messages back and forth (OpenCode, Cursor, Roo, etc.) simply **doesn't know the note exists** and drops it.
42
+ 2. **The teachers (Chinese AI companies: DeepSeek, Kimi, GLM, MiMo, MiniMax) demand the note back.** Their rules say: "if you don't hand me the exact sticky note from last time, I refuse to answer."
43
+ 3. **Some teachers are picky about the note being present**, not missing. Kimi K2.7-Code accepts a present-but-empty note. Others (DeepSeek, Kimi K2.5/2.6, GLM, MiMo) accept a blank one but then they "forget" and do worse.
44
+
45
+ What this repo does about it:
46
+
47
+ - **The plugin** is a tiny note-checker that runs inside OpenCode. It looks at every message and, if a note is missing, it slips a blank note in so the teacher doesn't yell. Cheap, but the teacher still forgets (blank note = no memory).
48
+ - **The proxy** is a smarter middle-man that sits between OpenCode and the teacher. It **reads the real sticky note off each answer, remembers it, and pastes the actual writing back** into the next message. Now the teacher remembers, and your friend stays sharp. (v3 rewrote the proxy so it does this with almost zero slowdown — see below.)
49
+ - **The watchdog** is just a babysitter that restarts the proxy if it ever crashes.
50
+
51
+ Bottom line: **the proxy is what makes the AI actually remember its thinking. The plugin is a safety net. The watchdog keeps the lights on.**
52
+
53
+ ---
54
+
55
+ ## v3 proxy rewrite — performance + correctness
56
+
57
+ The proxy (`proxy/proxy.js`) was rewritten to remove the slowdown you were hitting:
58
+
59
+ - **Raw-byte streaming.** Responses are now forwarded as-is; the stream is parsed *only* to cache the note. No more re-building every token before sending it to you.
60
+ - **Lazy patching.** If OpenCode already hands the notes back correctly (newer builds do), the proxy does **nothing** — zero JSON rewriting, zero overhead.
61
+ - **Correct note placement (the big bug fix).** Earlier versions pasted every note into the *first* slot, so turn 3+ forgot everything. v3 stores each note in its own correct slot, so every turn replays *its own* thinking.
62
+ - **Keep-alive connections + upstream timeout.** Fewer TLS handshakes, no hung requests.
63
+
64
+ ## v3.1 — dialect-aware patching (intel-driven)
65
+
66
+ Provider-specific research showed the field name is **not universal** and the "echo everything" heuristic was
67
+ causing cross-provider poisoning. v3.1 fixes that:
68
+
69
+ - **Echo only the field the upstream expects.** Each route declares a `reasoningKey`:
70
+ `reasoning_content` (DeepSeek/Kimi/Moonshot/GLM/Zhipu/MiMo), `reasoning_details`
71
+ (MiniMax split mode), `reasoning` (OpenCode Go / fixed-upstream). Previously the proxy
72
+ filled all three fields, so a GLM turn stored under `reasoning` could poison a later
73
+ DeepSeek replay that expects `reasoning_content`.
74
+ - **R1 vs V4 split.** `deepseek-reasoner` (R1) must **not** receive reasoning echoed back
75
+ (400 if you do) while V4 must. R1 uses the v3.2 `reasoningKey: 'strip'` sentinel,
76
+ which actively removes reasoning fields before forwarding.
77
+ - **Never fabricate reasoning.** Unknown models and providers that reject echo
78
+ (Qwen, GPT, Claude, Gemini, Llama, Mistral, Cerebras-hosted GLM) default to
79
+ `reasoningKey: null` — the body is forwarded untouched.
80
+
81
+ ### "Another way" — do you even need the plugin now?
82
+
83
+ The reasoning-drop is fixed at the wire layer by the proxy, so you have three options:
84
+
85
+ | Approach | Pros | Cons |
86
+ |----------|------|------|
87
+ | **Proxy-only (recommended)** — keep a *slim* plugin that only tags sessions with `x-session-id`, let the proxy do all note-handling | Real reasoning replay, near-zero overhead, correct across all turns | One extra localhost process to run |
88
+ | **Native / disable thinking** — point at the provider's Anthropic-compatible endpoint (e.g. DeepSeek `/anthropic`) or set `thinking: disabled` | No extra process, simplest | Loses ~20–40% reasoning quality on hard coding tasks |
89
+ | **Full plugin + proxy** (old default) | Maximum safety net | Plugin's per-message transform adds overhead inside OpenCode |
90
+
91
+ **Recommendation:** run the proxy, and slim the plugin down to *just* the `x-session-id` header injection (delete its message-transform hook). That gives you real reasoning replay with the least overhead.
92
+
93
+ ## Plugin optionality and derived sessions
94
+
95
+ As of 3.2.0, the plugin is optional. The shipped npm plugin still contains the transform hook; without it, derived keys keep caching functional; with it, you add exact session IDs + schema padding. The proxy derives session identity from the request when `x-session-id` is absent. Formula: `sha256(authHeader + '||' + modelName + '||' + firstUserMessageText)`, prefixed with `derived:` and truncated to 32 hex characters; header wins when present. The key is fixed at the first user message, so cross-talk is bounded to sessions sharing the same auth header, model, and first user prompt; replayed text is still valid reasoning for that model, so the impact is quality-level, never a 400.
96
+
97
+ ---
98
+
30
99
  ## Quick Install
31
100
 
32
101
  **This is an OpenCode plugin. Install it inside OpenCode, no terminal needed.**
@@ -56,7 +125,7 @@ opencode plugin opencode-thinking-fix
56
125
  For a specific version:
57
126
 
58
127
  ```bash
59
- opencode plugin opencode-thinking-fix@2.0.0
128
+ opencode plugin opencode-thinking-fix@3.2.0
60
129
  ```
61
130
 
62
131
  Restart OpenCode after installing.
@@ -82,31 +151,27 @@ See also: [OpenCode plugin docs](https://opencode.ai/docs/plugins)
82
151
  ---
83
152
 
84
153
  - [What problem this fixes](#what-problem-this-fixes)
85
- - [Option 1: Plugin (stops the crashes)](#option-1-plugin-stops-the-crashes)
154
+ - [Option 1: Plugin (safety net)](#option-1-plugin-safety-net)
86
155
  - [Option 2: Proxy (replays real reasoning)](#option-2-proxy-replays-real-reasoning)
87
156
  - [Option 3: Watchdog (auto-recovery)](#option-3-watchdog-auto-recovery)
88
157
  - [How they work together](#how-they-work-together)
89
158
  - [Affected models](#affected-models)
90
159
  - [Model routing](#model-routing)
91
160
  - [Is it working?](#is-it-working)
92
- - [Running tests](#running-tests)
93
161
  - [This bug is everywhere](#this-bug-is-everywhere)
94
162
  - [Files in this repo](#files-in-this-repo)
95
- - [Changelog](#changelog)
96
163
 
97
164
  ---
98
165
 
99
166
  ## What problem this fixes
100
167
 
101
- You ask DeepSeek a question. It picks a tool, calls it, works fine. Then you ask a follow-up and you get this:
168
+ You ask DeepSeek a question. It picks a tool, calls it, works fine. Then you ask a follow-up — and the AI has lost the reasoning it produced on every earlier turn.
102
169
 
103
- ```
104
- HTTP 400: The reasoning_content in the thinking mode must be passed back to the API
105
- ```
170
+ The client/SDK dropped the field before it reached the API — the providers are doing exactly what their docs say. The drop happens in SDK serializers and client transforms.
106
171
 
107
- This is OpenCode dropping the field before it reaches the API — the providers are doing exactly what their docs say.
172
+ > **Deprecated:** the historical symptom of this drop — `HTTP 400: The reasoning_content in the thinking mode must be passed back to the API` — is **resolved** by this fix. This repo is about the drop itself, not the error it used to cause.
108
173
 
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:
174
+ 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 rejects the request. All five providers confirm this in their official documentation:
110
175
 
111
176
  - **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.
112
177
  - **Z.AI / GLM**: "[Key: return reasoning_content to keep the reasoning coherent](https://docs.z.ai/en/api/thinking)."
@@ -114,13 +179,12 @@ DeepSeek V4 (and Kimi K2.7, GLM 5.x, MiMo V2.5) require that `reasoning_content`
114
179
  - **MiniMax**: "[The complete model response must be append to the conversation history](https://platform.minimaxi.com/document/ChatCompletion%20v2)."
115
180
  - **Xiaomi MiMo**: "[Any assistant message with tool calls... must preserve its full reasoning_content field, otherwise the API will return a 400 error](https://dev.mi.com/doc/llm-api). Affected frameworks include TRAE, Cursor, Roo Code, Codex, GitHub Copilot CLI, Zed, AutoGen."
116
181
 
117
- OpenCode's provider layer drops this field. Three upstream PRs ([#24250](https://github.com/anomalyco/opencode/pull/24250), [#24428](https://github.com/anomalyco/opencode/pull/24428), [#24895](https://github.com/anomalyco/opencode/pull/24895)) tried to fix it. None merged. The field is non-standard per OpenAI, so both OpenCode and the AI SDK ignore it.
118
-
119
- This repo fixes it. Three layers, pick what you need.
182
+ The field is non-standard per OpenAI, so SDKs and clients ignore it — the drop is
183
+ systemic, not a single tool's bug. This repo fixes it. Three layers, pick what you need.
120
184
 
121
185
  ---
122
186
 
123
- ## Option 1: plugin (stops the crashes)
187
+ ## Option 1: plugin (safety net)
124
188
 
125
189
  ### Install via npm (recommended)
126
190
 
@@ -141,7 +205,7 @@ It also handles `reasoning` for the OpenCode Go provider, and patches empty `con
141
205
 
142
206
  No config file changes. No build step. OpenCode compiles `.ts` plugins when it starts.
143
207
 
144
- **The catch:** the plugin fills in empty strings, not your model's actual prior thinking. DeepSeek, Kimi K2.5/K2.6, GLM, and MiMo accept empty strings fine, your conversation works but the model does not see its earlier reasoning. Kimi K2.7 Code rejects empty strings entirely, it needs the real text.
208
+ **The catch:** the plugin fills in empty strings, not your model's actual prior thinking. DeepSeek, Kimi K2.5/K2.6, GLM, and MiMo accept empty strings fine, your conversation works but the model does not see its earlier reasoning. Kimi K2.7 Code requires the field to be present; present-but-empty is accepted.
145
209
 
146
210
  ---
147
211
 
@@ -160,7 +224,7 @@ The proxy runs on **two ports**:
160
224
  | **3457** | Direct providers (DeepSeek, Kimi, GLM, MiMo, GPT, Claude, Qwen, Gemini, etc.) | `PORT=3457` |
161
225
  | **3458** | OpenCode Go provider | `PORT=3458` `UPSTREAM_URL=https://opencode.ai/zen/go/v1` |
162
226
 
163
- 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.
227
+ 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. It handles the provider's supported chat and Anthropic message dialects, while passing unsupported response formats through unchanged. Both are handled by the same `proxy.js` binary, just different environment variables.
164
228
 
165
229
  ```bash
166
230
  # Linux / macOS / Windows (Node.js required)
@@ -172,6 +236,44 @@ PORT=3458 UPSTREAM_URL=https://opencode.ai/zen/go/v1 node proxy/proxy.js
172
236
 
173
237
  > **Windows PowerShell:** use `$env:PORT=3457; node proxy/proxy.js` (PowerShell) or `set PORT=3457 && node proxy/proxy.js` (CMD).
174
238
 
239
+ ### OpenCode Go setup (explicit and credentials-safe)
240
+
241
+ The npm package intentionally does **not** run a `postinstall` script. It never
242
+ reads `auth.json`, edits your OpenCode configuration, starts a process, or
243
+ enables a service without your explicit action.
244
+
245
+ 1. In OpenCode, run `/connect` and select **OpenCode Go**. Keep the credential
246
+ in OpenCode's own local auth store; never paste it into this repository,
247
+ `opencode.json`, a shell script, or a public issue.
248
+ 2. Install the package and start its Go proxy manually:
249
+
250
+ ```bash
251
+ npm install opencode-thinking-fix
252
+ PORT=3458 UPSTREAM_URL=https://opencode.ai/zen/go/v1 \
253
+ node node_modules/opencode-thinking-fix/proxy/proxy.js
254
+ ```
255
+
256
+ 3. Point only the OpenCode Go provider at the local proxy. The `baseURL` must
257
+ be under `provider.<id>.options`:
258
+
259
+ ```json
260
+ {
261
+ "$schema": "https://opencode.ai/config.json",
262
+ "provider": {
263
+ "opencode-go": {
264
+ "options": {
265
+ "baseURL": "http://127.0.0.1:3458/v1"
266
+ }
267
+ }
268
+ }
269
+ }
270
+ ```
271
+
272
+ The proxy forwards the authorization header supplied by OpenCode to the
273
+ configured upstream and does not persist the credential. Stop the proxy when
274
+ it is not needed. The systemd and watchdog options below are deliberately
275
+ opt-in alternatives for operators who want automatic restarts.
276
+
175
277
  ### Install as systemd services (auto-start at boot)
176
278
 
177
279
  ```bash
@@ -189,10 +291,14 @@ Then point OpenCode at it, in your `opencode.json`:
189
291
  {
190
292
  "provider": {
191
293
  "deepseek-v4-pro": {
192
- "baseURL": "http://127.0.0.1:3457/v1"
294
+ "options": {
295
+ "baseURL": "http://127.0.0.1:3457/v1"
296
+ }
193
297
  },
194
298
  "opencode-go": {
195
- "baseURL": "http://127.0.0.1:3458/v1"
299
+ "options": {
300
+ "baseURL": "http://127.0.0.1:3458/v1"
301
+ }
196
302
  }
197
303
  }
198
304
  }
@@ -228,7 +334,7 @@ OpenCode → [plugin patches missing reasoning_content/reasoning]
228
334
  → API
229
335
  ```
230
336
 
231
- The plugin is the safety net. If the proxy goes down, the plugin still injects empty strings so you do not get 400s. If the proxy is up, its cached text takes priority because the plugin sees the field is already filled in. Either way, your conversation does not break.
337
+ The plugin is the safety net. If the proxy goes down, the plugin still injects empty strings so reasoning is never missing from the request. If the proxy is up, its cached text takes priority because the plugin sees the field is already filled in. Either way, your conversation keeps its thinking.
232
338
 
233
339
  ---
234
340
 
@@ -236,28 +342,29 @@ The plugin is the safety net. If the proxy goes down, the plugin still injects e
236
342
 
237
343
  | Model | Plugin helps | Proxy helps | What it needs |
238
344
  |---|---|---|---|
239
- | DeepSeek V4 Pro / Flash | Yes | Nice to have | Accepts `""` |
345
+ | DeepSeek V4 Pro / Flash | Yes | Nice to have | Accepts `""` (tool-call turns need real text) |
240
346
  | Kimi K2.5 / K2.6 | Yes | Nice to have | Accepts `""` |
241
- | **Kimi K2.7 Code** | **Not enough alone** | **Required** | Needs real text |
347
+ | **Kimi K2.7 Code** | **Not enough alone** | **Required** | Field must be *present*; real text keeps it coherent |
242
348
  | GLM-5.x / Zhipu | Yes | Nice to have | Accepts `""` |
243
- | MiMo V2.5 / MiniMax | Yes | Nice to have | Accepts `""` (default mode embeds `<think>` in `content`) |
349
+ | MiMo V2.5 | Yes | Nice to have | `reasoning_content` on `api.xiaomimimo.com/v1` |
244
350
  | **MiniMax-M3** | Yes | **Recommended** | `reasoning_details[]` array; ~40% quality loss if stripped. Proxy injects `reasoning_split:true` to keep thinking separate from content. |
245
- | OpenCode Go | Yes | Required | Uses `reasoning` field |
351
+ | OpenCode Go | Yes | Recommended for chat/message routes | Chat uses `reasoning`; Anthropic messages are handled; unsupported response formats pass through |
246
352
  | Qwen, GPT, Claude, Gemini, Llama, Mistral | No | No | No reasoning_content |
247
353
 
248
354
  ---
249
355
 
250
356
  ## Model routing (proxy port 3457)
251
357
 
252
- The proxy auto-routes by model name prefix. All 15 supported prefixes:
358
+ The proxy auto-routes by model name prefix. All routes:
253
359
 
254
360
  | Prefix | Upstream | Reasoning |
255
361
  |---|---|---|
256
- | `deepseek-v4-pro` | `https://api.deepseek.com` | Yes |
257
- | `deepseek` | `https://api.deepseek.com` | Yes |
258
- | `kimi`, `moonshot` | `https://api.moonshot.ai/v1` | Yes |
259
- | `glm`, `zhipu` | `https://open.bigmodel.cn/api/paas/v4` | Yes |
260
- | `minimax`, `mimo` | `https://api.minimax.io/v1` | Yes |
362
+ | `deepseek-v4-pro`, `deepseek-v4-flash`, `deepseek-chat` | `https://api.deepseek.com` | Yes (`reasoning_content`) |
363
+ | `deepseek-reasoner` | `https://api.deepseek.com` | **No — actively stripped** (R1 contract: reasoning must NOT be echoed) |
364
+ | `kimi`, `moonshot` | `https://api.moonshot.ai/v1` | Yes (`reasoning_content`) |
365
+ | `glm`, `zhipu` | `https://open.bigmodel.cn/api/paas/v4` | Yes (`reasoning_content`) |
366
+ | `minimax` | `https://api.minimax.io/v1` | Yes (`reasoning_details`, `reasoning_split:true`) |
367
+ | `mimo` | `https://api.xiaomimimo.com/v1` | Yes (`reasoning_content`) |
261
368
  | `gpt`, `o1` | `https://api.openai.com` | No |
262
369
  | `claude`, `anthropic` | `https://api.anthropic.com` | No |
263
370
  | `qwen` | `https://dashscope-intl.aliyuncs.com/compatible-mode/v1` | No |
@@ -278,8 +385,8 @@ The plugin writes a structured JSON log: `~/.local/share/opencode/thinking-fix.l
278
385
  Before and after, from a real session:
279
386
 
280
387
  ```
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
388
+ Before: reasoning dropped on every turn → AI forgets its thinking
389
+ After: 34 fields patched across a 104-message session → reasoning replays correctly
283
390
  ```
284
391
 
285
392
  Here is a live excerpt from that session:
@@ -309,23 +416,6 @@ journalctl --user -u reasoning-cache.service -f
309
416
  journalctl --user -u reasoning-cache-go.service -f
310
417
  ```
311
418
 
312
- ---
313
-
314
- ## Running tests
315
-
316
- ```bash
317
- npm test
318
- # or directly:
319
- node tests/test-plugin.js
320
- node tests/test-proxy.js
321
- ```
322
-
323
- The plugin tests cover 12 cases: native reasoning model detection, OpenCode Go `reasoning` field detection, non-reasoning model passthrough, mixed messages, multiple assistant turns, already-complete messages, wrapper format (`{ info: Message }`), empty `reasoning_content`, empty arrays, tool_calls with reasoning and without, and null/undefined wrappers.
324
-
325
- The proxy tests cover 15 cases: route resolution for all model prefixes, `patchRequestBody` injection from cache for both `reasoning_content` and `reasoning`, no-cache fallback to empty strings, user message isolation, multi-turn caching, and SSE stream parsing for `delta.reasoning_content`, `delta.reasoning`, content-triggered flush, and `finish_reason` flush.
326
-
327
- ---
328
-
329
419
  ## This bug is everywhere
330
420
 
331
421
  OpenCode is not the only tool that drops `reasoning_content`. Here is a partial list of places this same bug shows up:
@@ -354,23 +444,26 @@ OpenCode is not the only tool that drops `reasoning_content`. Here is a partial
354
444
 
355
445
  ```
356
446
  plugins/
357
- opencode-thinking-fix-universal.ts # self-detection plugin (92 lines)
447
+ opencode-thinking-fix-universal.ts # self-detection plugin
358
448
  proxy/
359
- proxy.js # reasoning cache proxy (422 lines, 1 dep)
360
- tests/
361
- test-plugin.js # plugin unit tests (228 lines, 12 cases)
362
- test-proxy.js # proxy unit tests (359 lines, 15 cases)
449
+ core.js # pure logic: routes, cache, patching, parser
450
+ proxy.js # HTTP server + side effects (1 dep)
363
451
  watchdog/
364
- watchdog.sh # auto-recovery watchdog (64 lines)
452
+ watchdog.sh # auto-recovery watchdog
365
453
  systemd/
366
454
  reasoning-cache.service # proxy systemd unit (port 3457)
367
455
  reasoning-cache-go.service # OpenCode Go proxy unit (port 3458)
368
456
  reasoning-proxy-watchdog.service # watchdog systemd unit
369
457
  ```
370
458
 
371
- ## Changelog
459
+ ## Release highlights
372
460
 
373
- See [CHANGELOG.md](CHANGELOG.md) for release history. Current: **v2.0.0** — eventsource-parser, LRU cache, SIGTERM handling, 12+15 passing tests.
461
+ - **v3.2.0:** R1 `strip` sentinel (actively remove reasoning for `deepseek-r1`/`deepseek-reasoner`), multibyte-safe SSE decoding (StringDecoder), response hop-by-hop header stripping, oversized-reasoning skip-not-truncate, MiniMax replay shape behind `MINIMAX_REASONING_DETAILS_SHAPE` (default `minimal`), a real-core test suite (95 assertions), glm-5.2 go-mode `reasoning_content` key (F11, live-verified), derived session keys (Option C), and `x-session-id` no longer forwarded upstream. See the changelog.
462
+ - **v3.1.4:** proxy-owned structured JSONL logging with session identifiers truncated in logs.
463
+ - **v3.1.3:** Anthropic-wire dialect detection for OpenCode Go routes.
464
+ - **v3.1.2:** bounded cache/session memory, raw-stream preservation, hop-by-hop header removal, and safer parser failure handling.
465
+ - **v3.1.1:** corrected MiMo routing, non-streaming reasoning caching, and fixed partial-turn patching.
466
+ - **v3.1:** provider-aware reasoning fields, including the DeepSeek R1 no-echo route and safe passthrough for unknown models.
374
467
 
375
468
  ---
376
469
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-thinking-fix",
3
- "version": "2.0.1",
4
- "description": "Fix reasoning_content 400 errors for DeepSeek/Kimi/GLM/MiMo/MiniMax in OpenCode",
3
+ "version": "3.2.0",
4
+ "description": "Restores reasoning content dropped from multi-turn OpenCode conversations (DeepSeek, Kimi, GLM, MiMo, MiniMax, OpenCode Go). Plugin + proxy + watchdog.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "oc-plugin": [
@@ -26,10 +26,9 @@
26
26
  "thinking-mode",
27
27
  "tool-calls",
28
28
  "multi-turn",
29
- "400-error",
30
- "http-400",
31
29
  "proxy",
32
30
  "plugin",
31
+ "cli",
33
32
  "cursor",
34
33
  "cline",
35
34
  "aider",
@@ -44,7 +43,9 @@
44
43
  "chinese-llm",
45
44
  "agent",
46
45
  "mcp",
47
- "api-fix"
46
+ "reasoning-preservation",
47
+ "thinking-blocks",
48
+ "context-restoration"
48
49
  ],
49
50
  "repository": {
50
51
  "type": "git",
@@ -61,20 +62,15 @@
61
62
  },
62
63
  "files": [
63
64
  "plugins/opencode-thinking-fix-universal.ts",
65
+ "proxy/core.js",
64
66
  "proxy/proxy.js",
65
67
  "systemd/reasoning-cache.service",
66
68
  "systemd/reasoning-cache-go.service",
67
69
  "systemd/reasoning-proxy-watchdog.service",
68
70
  "watchdog/watchdog.sh",
69
- "tests/test-plugin.js",
70
- "tests/test-proxy.js",
71
71
  "README.md",
72
- "CHANGELOG.md",
73
72
  "LICENSE.md"
74
73
  ],
75
- "scripts": {
76
- "test": "node tests/test-plugin.js && node tests/test-proxy.js"
77
- },
78
74
  "dependencies": {
79
75
  "eventsource-parser": "^3.1.0"
80
76
  },
@@ -90,6 +86,7 @@
90
86
  "node": ">=18"
91
87
  },
92
88
  "devDependencies": {
89
+ "@types/node": "^18.19.130",
93
90
  "typescript": "^6.0.3"
94
91
  }
95
92
  }