Files
plugins/packages
yetone af360a529d workbuddy 0.1.29: a system prompt refused as an unapproved channel goes again as the user's instructions
Wing on Discord (10-21) got 400 11128 "Illegal API invocation from an
unapproved channel" from an agent we couldn't name, and so did others
(miaopasi; itsuki with dsh). FLAGGED rewords the lines we've met, so any
agent with a line not met yet is refused.

What WorkBuddy checks (real accounts on both builds, 2026-10-21, CN
glm-5.3 / deepseek-v4.1-flash, AI gpt-5.5 / glm-5.3):
- Only system and assistant messages are checked. Each refused line
  (Claude Code's identity line, "Main branch (you will usually use this
  for PRs): main", DeepSeek Harness's opening) was served as a user
  message, as a user message's parts and as a tool result, and refused
  again in the system message or an assistant message.
- An identity line is refused only at the start of a message (a leading
  space or "Hi.\n" passes; the line at the end of omp's 10.5K prompt
  passes). It is matched case-insensitively. "Main branch ..." is refused
  anywhere. Whitespace must match exactly: a double space or a ZWSP
  passes.
- With no system message, the AI build answers 11128 "first message is
  not system prompt".

The change: on that refusal, the chat is sent once more with its system
prompt moved into the first user message, inside <instructions> tags,
and "You are a helpful assistant." as the system message. A later system
message becomes a user message where it stands. The refused system prompt
is remembered (up to 256), so that agent's next chats go moved without a
refusal first. FLAGGED stays, so lines we know still go as system. A
refusal that stands after the move still ends in REFUSED_HINT with
X-Magpie-Sign-In: kept, so no account is rested. The added text names no
one.

Run, with FLAGGED emptied in a copy so that only the move could pass:
- probe, the plugin's fetch with real accounts: the CC, Main-branch and
  DeepSeek Harness lines each went 400 then 200 on CN glm-5.3, CN
  deepseek-v4.1-flash, AI gpt-5.5 and AI glm-5.3. The second chat with
  the same prompt was 200 at once.
- OpenCode 2.0.25 on workbuddy-ai glm-5.3 with an agent prompt opening
  with Claude Code's line. Bridge log:
    upstream 400 sys: "You are Claude Code, Anthropic's offici
    upstream 200 sys: "You are a helpful assistant." next: user <instructions>...
  It added power() to calc.py with tool calls.
- omp 18.9.1 on workbuddy deepseek-v4.1-flash with --system-prompt
  opening "You are an AI agent powered by DeepSeek Harness" and holding
  the Main-branch line: one 400, then four 200s moved. It added divide()
  with a zero guard and ran it.
- HOME=$(mktemp -d) bun test in packages/workbuddy: 111 pass, 0 fail.
  bun scripts/check.mjs: ok.
- systemasuser.test.mjs uses WorkBuddy's literal 11128 body. Run against
  the 0.1.28 index.mjs, 7 of its 9 tests fail; the other two are guards
  that nothing is sent again.

Not tried: Wing's own agent (unknown; "omp" by the name is a Discord
server tag), dsh on the CN build through the move, and how well each
model follows instructions from the user turn over a long session. They
followed them in the runs above.
2026-10-21 18:28:06 +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