Files
plugins/packages
yetone 1a342edfae devin 0.1.36: another model's reasoning goes back as its thinking (#703)
kamikakushi (#703): swe-2 is conditioned on the assistant turns before
it having thinking (ChatMessagePrompt field 11). The plugin sent field
11 only beside a signature (#665), and no builder handed it a non-Claude
model's reasoning, so swe-2 stopped emitting delta_thinking on a tool
loop's later turns (the reporter's A/B against swe-2-high: no field 11,
0 bytes of thinking; field 11 without 12, thinking on 5 of 5 runs).
Each claim checked against index.mjs at 0.1.35: build() read only
content and tool_calls, v2Chat() dropped reasoning parts, encodeMsg()
gated 11 on the signature.

- encodeMsg: field 11 whenever the thinking has text; 12 and 18 only
  with a signature, as before.
- build (chat completions): reasoning_content (or reasoning, as some
  clients name it) goes on the assistant prompt as unsigned thinking, to
  a model that isn't Claude. joinSplitCalls keeps both halves'.
- v2Chat (OpenCode 2): reasoning parts become reasoning_content, which
  build then handles.
- buildMessages (/v1/messages, the sibling the issue doesn't name): a
  non-Claude model's thinking block goes back as its text alone, never
  with its signature.
- Claude: unchanged. A chat completion still sends Claude no thinking
  (no field for a signature there), and Messages sends only signed
  thinking with its signature and type, as #665 did: Anthropic refuses a
  thinking block without a valid signature, so unsigned text never goes
  to Claude on any path.

Not done: the issue's optional made-up thought for a history turn whose
client sent no reasoning (Pi's openai-completions default). Nothing is
written into the model's history that it didn't say.

Run (mote, bun 1.4.2, HOME a temp dir): packages/devin 208 pass, 0 fail;
repo root bun test 5411 pass, 0 fail, 19 skip; bun scripts/check.mjs ok.
Broke it by hand:
- index.mjs from origin/main: 7 red (the 6 new non-Claude tests and the
  updated "another model's goes without a signature"); the Claude tests
  pass both ways.
- only encodeMsg's old gate put back: the same 7 red.
- build's Claude gate removed: "Claude gets no unsigned thinking from a
  chat completion", "a chat completion's request is the same as before"
  and the v2 Claude check red.
Not tried: a real Devin account; frames are built from the proto's
field numbers, and swe-2's behaviour rests on the reporter's A/B.
2026-11-04 13:49:17 +08:00
..
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00