@liucl on X (11-09): a prompt only for gemini-3.8-flash. `models` was
checked with String(body.model ?? ctx.model).startsWith(m), but an agent
wired to magpie names its model magpie's way, provider first
(google/gemini-3.8-flash, openrouter/google/gemini-3.8-flash), or names a
routing group (group/...). So "models": ["gemini-3.8-flash"] never
matched, though the README said "models whose names begin with one of
these prefixes".
A prefix now matches the whole id or the part after any "/" of it, case
aside; full-id prefixes (google/, deepseek) work as before. magpie's
middleware gets the agent's body at onRequest (ctx.model is modelOf(body),
serveAgent in internal/gateway/middleware.go), so a group request names
the group there. The member is known on each try: onProvider gets
ctx.provider {id, model} and can change that try's body
(docs/subsystems/gateway-middleware.md, triedOn). A request onRequest
didn't match is matched there against the member's model (and id/model),
so only the tries on gemini-3.8-flash get the prompt. ctx.state.given
keeps a try from adding it a second time after onRequest did.
Run on mote: packages/system-prompt bun test, 24 pass 0 fail (13 new
cases); bun scripts/check.mjs, all ok. In magpie's own engine: a
throwaway test in a detached magpie worktree at origin/main (removed, not
committed) loaded this module through internal/middleware's Begin,
Request and Tried in moejs: google/ and openrouter/google/gemini-3.8-flash
got it once, gemini-3.8-pro none, group/fast got it on the google
gemini-3.8-flash try and not on a deepseek try, no failures counted.
Broken by hand: with the old startsWith in onRequest, the 4 name cases go
red; with onProvider not exported, the 2 group-try cases; without
ctx.state.given, the "not given it twice" case.
Not tried: a real agent through a real magpie gateway and Gemini account.
Without override, an agent's own system prompt is kept and none is
added, as before; the README's example sets override.
@magpie-community/middleware-system-prompt
New API's 系统提示词 (a channel's system_prompt and its override switch) as magpie gateway middleware. It gives the requests agents send a system prompt of yours, in each API's own place for one:
| API | Where the prompt goes |
|---|---|
| Anthropic | system |
| Chat | the first system or developer message |
| Responses | instructions |
| Gemini | systemInstruction |
Install it from magpie's Plugins › Discover, or with magpie plugin add @magpie-community/middleware-system-prompt. Set its options under Plugins › Installed › Options, or with magpie plugin options system-prompt '<json>'.
Options
{ "system_prompt": "Reply in the language the user writes in.",
"override": true, "position": "append",
"agents": ["claude"], "models": ["deepseek"] }
-
No system prompt yet. A request without one gets yours.
-
override. A request that has its own prompt keeps it unchanged, unlessoverrideistrue. Then yours goes in as well, placed byposition:"append"(the default) puts yours after it. Agents cache their own prompt, so adding after it keeps that cache."prepend"puts yours before it, as New API does. This makes the provider read the whole prompt again on every turn.
-
agents. When given, the prompt applies only to these agents, by magpie's agent ids:claude,codex,opencode, and so on. -
models. When given, the prompt applies only to models whose names begin with one of these prefixes, case aside. A prefix may begin magpie's whole model id (google/gemini) or the model's own name after its provider (gemini-3.8-flashmatchesgoogle/gemini-3.8-flashandopenrouter/google/gemini-3.8-flash). In a routing group the prompt goes only to the tries on a model inmodels: to give Gemini 3.8 Flash a prompt and no other model, whether it is asked directly or through a group, use (override, since most agents send a prompt of their own){ "system_prompt": "Answer in Chinese.", "override": true, "models": ["gemini-3.8-flash"] }
Codex sends its own model instructions, and changing them can change how its models behave. Use agents to leave Codex out if you don't want that.
中文:New API 的「系统提示词」,作为 magpie 网关中间件。默认把你的提示词加在 agent 自己的提示词之后,这样不会破坏提示缓存。models 按模型名前缀匹配(不分大小写),可以写完整 id(如 google/gemini),也可以只写模型名(如 gemini-3.8-flash,会匹配 google/gemini-3.8-flash、openrouter/google/gemini-3.8-flash);路由组里只有发往这些模型的请求会加上提示词。例如只给 gemini-3.8-flash 加提示词:{"system_prompt": "用中文回答。", "override": true, "models": ["gemini-3.8-flash"]}。