Files
plugins/packages
yetone 191d94bf6e devin 0.1.41: a Gemini reply goes back with its thought signature, as the CLI sends it
Reported on X (@liuzhengdong99, magpie 0.1.4146): in DSH, Devin's Gemini 4
Hydrogen often fails with "an empty reply ... (502)" or hangs; SWE-2 works.

Diffing the plugin's GetChatMessage against the official devin CLI's
(captured through a proxy, same account, gemini-4-hydrogen-medium, a tool
turn): Devin streams Hydrogen's thought signature (field 10, type
"gemini" in 21) and no visible thinking. The CLI sends it back on the
assistant prompt that carries the call: signature (12), signature_type
"gemini" (18) and the model that wrote it (22). The plugin dropped Gemini
signatures, on the chat wire and the Messages wire, so every later turn
went back to Gemini without them. Google documents thought signatures as
required for Gemini 3-class function calling.

Neither a chat completion nor a Messages tool_use carries a signature, so
the plugin keeps each Gemini reply's signature in memory by its call ids
(or by its words, for a reply with no call), up to 4096, and puts it back
on the matching assistant prompt with field 22. Other models are
unchanged; an unknown call, or one after a restart, goes back unsigned as
before.

Run:
- gemini-thought.test.mjs (7 tests, fixture = a real Hydrogen tool reply
  captured from the CLI, testdata/gemini-tool-reply.bin, no credentials):
  7/7 on mica. Broken by hand: against origin/main's index.mjs the 5
  signature tests fail (Received: undefined); the 2 "goes back unsigned"
  tests pass on both.
- Whole plugins suite on mica, HOME=$(mktemp -d) bun test, as CI:
  8796 pass, 0 fail (8816 tests, 615 files); bun scripts/check.mjs ok.
  packages/devin alone: 220/220.
- Real account (sandbox HOME, plugin through a chat-completions shim):
  a 4-step tool loop on the new code signed every assistant prompt
  (1/1 .. 4/4), all 200, right answer. dsh headless (sandbox HOME) on
  Hydrogen through the shim: a JSON-parser coding task on old and new
  code, both finished with tests passing, every request 200.

Not reproduced: on the old code, 127 Hydrogen requests through dsh
(up to 170 messages, a 434KB request) all answered 200, with no empty
reply. So this restores what the official client sends; it is not proven
to be the reporter's cause. The "hang" is likely Hydrogen's hidden
thinking: the plugin waits for the first real content and Hydrogen
streams no thinking text. No retry was added.
2026-11-14 17:01:05 +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