Files
magpie/docs/subsystems
yetone e5b57794e2 routing: a rule's agent picker lists agents heard from and takes a typed User-Agent name (raikyou on Discord)
A rule can match a client magpie doesn't know, such as SillyTavern or
someone's own app with its own User-Agent. The gateway already names such a
client by its User-Agent's product name (usage.AgentOf), and a rule compares
agents in lower case (cleanRules, MatchesBesidesIntent, Pauses). Until now
the editor's agent picker listed only the agents magpie knows.

The picker now lists the agents magpie knows, then the agents
/api/usage?period=30d heard from that it doesn't know, leaving out "other"
and magpie. The note on those reads "heard from in the last 30 days". The
usage call is made once per editor and reads the cached SummarizeTop. A name
typed in the filter is read the way the gateway reads a User-Agent: the text
before the first "/", space or comma, in lower case. "MyApp/2.0 (Linux)" is
myapp. A typed name that is already an agent's id is that agent. The
picked name shows in the chip as the others do and is saved in agents:[…].
app.js's openPicker gains field.placeholder and field.typed for this; other
pickers are unchanged.

zh label: 筛选,或输入 Agent 名称… (notes: User-Agent 开头的名称, 近 30 天有请求).
Strings are added in en, zh, zh-TW, ja and de.

No backend change. The TUI takes rules as text (agents=…), so it already
accepts any name. A typed alias of a known agent (claude-cli) isn't mapped
to its id in the picker. Only an exact id is.

Run at 224ea7d5b plus this change, in a worktree with a sandbox HOME:
- routing-rule-agent-typed.test.cjs (new): 20/20, chromium and webkit, 5
  languages, at 1100px and at 390px. With app.js and client.js reverted it
  is red: the placeholder reads 'Filter agent…', and the phone test never
  sees the typed row.
- whole GUI suite (concurrency 4, load 160-380 from other sessions): 11170
  tests, 11062 pass, 108 fail across 27 files. Rerun alone at concurrency 2
  on this tree and on base 224ea7d5b, the same files are red on both (87
  here, 93 on base). The only extra red here is gateway-key-groups, once, a
  load flake (#1974, commented; it passes alone 3/3). Also red on base:
  codex-predictions (#2624), routing-bodies (#2559), lightweight (#2638,
  commented), segs-glide (#2683), and routing-keys-fold/-model-rest/
  -request-metrics/-wb-restricted, usage-*, quota-*, s3-sync (#1544, #2658).
- set -o pipefail; go test -timeout 45m ./...: exit=0, every package ok.
- gofmt -l: nothing (no Go files changed). go vet ./... on darwin,
  GOOS=linux go vet -tags nogui ./..., and GOOS=windows go vet ./...: clean.

- Rebased onto ef655acb4. b0b076421 had added warn() to the agents
  onPick, and the new onPick keeps it. After the rebase:
  routing-rule-agent-typed, routing-rule-remove, routing-pause and
  routing-pause-folder: 74/74 in both engines.
2026-10-20 00:40:08 +08:00
..

Subsystem design references

These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.

Subsystem Reference
Built-in subscriptions moving to plugins Provider and plugin ownership
Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) Plugin runtime
Plugins that run on the gateway's requests and replies Gateway middleware
Tools that plugins give, offered to every agent as an MCP server Plugin tools
Plugins that await context recall and observe completed replies Asynchronous gateway request hooks
Claude subscription turns across Claude Code runs Claude subscription bridge
How the gateway picks a provider, key or account, and falls back Gateway routing and fallback
Gateway Session Aggregation Gateway Session Aggregation
Connecting an agent's config to the gateway, drift, disconnect, WSL twins Agent wiring
Providers, keys, subscription accounts, refresh and allowance Providers and accounts
Instructions, MCP servers, skills and RTK written into agents Library
Tray, panel, window, magpie web and the page's JSON API GUI app shell
Encrypted backups and setup synchronization over WebDAV, S3 or GitHub Sync and backup

A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.

Maintain a reference

Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.

Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.

For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.

Describe a PR's semantic changes

For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.

For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.

This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.

Review a change

  1. Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
  2. Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
  3. Check that changed contracts appear in the owning reference and that source links still resolve.
  4. Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.

A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.