@vincemakes/kiso-provider-openai 0.1.19 → 0.1.21

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/dist/index.js +16 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -294,20 +294,27 @@ function toOpenAIMessages(messages, systemPrompt) {
294
294
  if (systemPrompt !== undefined) {
295
295
  out.push({ role: "system", content: systemPrompt });
296
296
  }
297
- // 自举 P1/P2: thinking mode is detected by the presence of ANY
298
- // reasoning in the projection (real OpenAI never emits thinking events,
299
- // so its requests never see the field). In thinking mode, ONLY the
300
- // CURRENT turn's assistant messages (after the last user message) carry
301
- // reasoning_content — their own, or "" when the step produced no
302
- // thinking (the field must still be present, or DeepSeek 400s); OLD
303
- // turns' CoT is never echoed (DeepSeek does not need it, and echoing
304
- // it is token waste).
305
- const thinkingMode = messages.some((m) => m.role === "assistant" && m.reasoning !== undefined);
306
297
  let lastUser = -1;
307
298
  for (const [i, m] of messages.entries()) {
308
299
  if (m.role === "user")
309
300
  lastUser = i;
310
301
  }
302
+ // 自举 P1/P2 + 手感批 C7: thinking mode is detected by the presence of
303
+ // reasoning in the CURRENT turn only (messages after the last user
304
+ // message). Real OpenAI never emits thinking events, so its requests
305
+ // never see the field. The current-turn messages carry no source
306
+ // marker, so the simple judgment is "the current session adapter is
307
+ // their source" — their reasoning is THIS family's own and may be
308
+ // echoed. Reasoning in OLDER turns belongs to whatever adapter
309
+ // produced them (an anthropic-thinking history continued by an openai
310
+ // adapter is the case this guards): it must NEVER flip the mode —
311
+ // otherwise this adapter would send `reasoning_content: ""` on a
312
+ // request it has no business tagging as thinking. In thinking mode,
313
+ // ONLY the CURRENT turn's assistant messages carry reasoning_content —
314
+ // their own, or "" when the step produced no thinking (the field must
315
+ // still be present, or DeepSeek 400s); old turns' CoT is never echoed
316
+ // (DeepSeek does not need it, and echoing it is token waste).
317
+ const thinkingMode = messages.slice(lastUser + 1).some((m) => m.role === "assistant" && m.reasoning !== undefined);
311
318
  for (const [i, msg] of messages.entries()) {
312
319
  if (msg.role === "user") {
313
320
  out.push({ role: "user", content: toOpenAIContent(msg.content) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-provider-openai",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "kiso OpenAI-compatible adapter — OpenAI + the compat family (GLM, Kimi, DeepSeek, OpenRouter) via base_url swap, reasoning dialects digested.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  "test": "vitest run"
22
22
  },
23
23
  "dependencies": {
24
- "@vincemakes/kiso-core": "0.1.19",
24
+ "@vincemakes/kiso-core": "0.1.21",
25
25
  "openai": "^7.3.0"
26
26
  },
27
27
  "devDependencies": {