library: Hermes folds its context with billion-context through its /bili/ prefix (Duckb7si on X)

Library › billion-context said no agent could use it on a machine where
Hermes was connected to magpie. Hermes was left out of the lanes on
purpose: bili's native Hermes plugin (hermes-plugin/__init__.py,
apply_env, billion-context 0.1.213) only sets HTTPS_PROXY, HERMES_CA_BUNDLE
and SSL_CERT_FILE. magpie's Hermes provider is http://127.0.0.1:3425/v1,
plain http on loopback, so that proxy never sees it: the plugin would add
its tools and fold nothing.

Hermes now takes the route Zed takes, bili's documented /bili/ prefix.
Turned on, magpie runs `bili start --port 8787` and sets base_url of the
magpie and magpie-anthropic providers to http://127.0.0.1:8787/bili/<gw>,
in config.yaml and in every profile that has magpie's provider
(agent.HermesThrough). Each later Sync or pick keeps a loopback prefix
with a path (hermesPrefix), and drops anything else back to the gateway.
Turning it off puts the gateway back. The empty-list string, docs (en, zh,
ja), llms-full.txt and docs/subsystems/library.md name Hermes.

The other agents bili supports that magpie wires (dsh, Kimi, ZCode, Codex,
Gemini, Qwen, ...) are #5915.

Run (mote, at the rebased head unless said):
- go test -tags nogui ./internal/library: ok (252s) at the rebased head
- go test -run 'TestHermes|TestZed|TestProxy|TestBili|Kept'
  ./internal/agent ./internal/library: ok before the rebase (base
  2219fdd49); the whole internal/agent at the rebased head was still
  running at push (mote load ~60), result goes on #5915
- GUI library-bili, library-all, i18n-keys, i18n-en-no-cjk (chromium and
  webkit, every language): 84, 26, 4, 4 pass, 0 fail (before the rebase)
- site node --test: 107 pass (llms-full.txt regenerated with llms-full.mjs)
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows on agent and
  library: clean; gofmt -l clean
Broken by hand:
- hermesEntries without the prefix: TestHermesThroughBili red (a pick
  drops the prefix)
- no "hermes" URL lane: TestBiliHermesThroughPrefix red (Hermes not
  offered)
Not tried:
- a real Hermes and a real `bili start`; tests fake bili and the probe
- a profile created after turning it on goes to the gateway until Hermes
  is turned on again
- bili's native Hermes plugin installed at the same time
- Windows run (vet only)
This commit is contained in:
yetone
2026-11-10 16:16:11 +08:00
parent d3f8623408
commit 00e8242e85
13 changed files with 242 additions and 21 deletions
File diff suppressed because one or more lines are too long
+4
View File
@@ -341,6 +341,10 @@ type Agent struct {
// that is known yet, and the proxy and where it is set; ok with no
// proxy when it sends them straight there (see codex_proxy.go).
viaProxy func() (ok, known bool, proxy, from string)
// through, when set, puts magpie's provider in the agent's config at
// the gateway behind a proxy's prefix ("" for the gateway itself):
// Hermes's, through billion-context's /bili/ (HermesThrough)
through func(prefix string) error
// dirShared says Dir is a folder another agent keeps its files in too
// (omp's, when PI_CODING_AGENT_DIR points it at Pi's): that it is there
// says nothing of this agent.
+73 -2
View File
@@ -33,6 +33,7 @@ package agent
import (
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
"slices"
@@ -245,9 +246,77 @@ func hermesIn(at place) *Agent {
}},
}
a.Fields = append(a.Fields, hermesProfileFields(at, dir)...)
a.through = func(prefix string) error { return hermesThrough(at, dir, path, prefix) }
return a
}
// HermesThrough points magpie's providers in Hermes's configs (a, Hermes)
// at the gateway through prefix, an address a local proxy takes the
// gateway's after (billion-context's http://127.0.0.1:8787/bili/), "" for
// the gateway itself. Hermes must be on magpie already. bili's own plugin
// for Hermes (bili plugin install hermes) sets HTTPS_PROXY in Hermes's
// process and nothing else, so a provider at http://127.0.0.1 (magpie's)
// never passes it; its docs' /bili/ prefix, which bili start answers,
// takes any client whose address can be edited.
func HermesThrough(a *Agent, prefix string) error {
if a == nil || a.ID != "hermes" || a.through == nil {
return fmt.Errorf("not Hermes")
}
return a.through(prefix)
}
// HermesURL is the base_url of magpie's provider in Hermes's connected
// config (a, Hermes), "" without one.
func HermesURL(a *Agent) string {
u, _ := edit.GetYAML(a.Path, "providers."+magpieID+".base_url")
return u
}
// hermesPrefix is the prefix magpie's entries in the config at path reach
// the gateway behind: a local proxy's route on loopback before the
// gateway's address (billion-context's http://127.0.0.1:8787/bili/,
// HermesThrough), which a sync and a pick keep; "" when they go to the
// gateway itself or anywhere else.
func hermesPrefix(at place, path string) string {
gw := at.gw()
for _, name := range []string{magpieID, hermesAnthropicID} {
v, ok := edit.GetYAML(path, "providers."+name+".base_url")
if !ok {
continue
}
mode, _ := hermesModeIn(path, name)
p, ok := strings.CutSuffix(strings.TrimSuffix(strings.TrimSpace(v), "/"), hermesBase(gw, mode))
if ok && p != "" && loopbackWithPath(strings.TrimSuffix(p, "/")) {
return p
}
}
return ""
}
// hermesThrough is HermesThrough for Hermes at a place, connected in the
// config at path (in dir): magpie's entries there and in every other
// profile's config that has them go to the gateway through prefix.
func hermesThrough(at place, dir, path, prefix string) error {
if edit.GetYAMLMap(path, "providers."+magpieID) == nil {
return fmt.Errorf("connect Hermes to magpie first: pick one of magpie's models for it on the Agents page")
}
var errs []error
for _, p := range append([]string{path}, hermesOthers(at, dir)...) {
var kvs []edit.KV
for _, name := range []string{magpieID, hermesAnthropicID} {
if edit.GetYAMLMap(p, "providers."+name) == nil {
continue
}
mode, _ := hermesModeIn(p, name)
kvs = append(kvs, edit.KV{Path: "providers." + name + ".base_url", Value: prefix + hermesBase(at.gw(), mode)})
}
if len(kvs) > 0 {
errs = append(errs, edit.SetYAML(p, kvs...))
}
}
return errors.Join(errs...)
}
// hermesProfileKey begins the key of a profile's model field
// (hermesProfileFields): "profile:<name>"
const hermesProfileKey = "profile:"
@@ -735,10 +804,12 @@ func hermesRoute(path, ref string) string {
// entry's api_mode the user set stays, and its address follows it.
func hermesEntries(at place, path string) [][2]any {
gw := at.gw()
// a local proxy's prefix the entries go through stays (HermesThrough)
pre := hermesPrefix(at, path)
anth, split := hermesSplit(path)
chat := hermesProviderAt(gw)
mode, _ := hermesModeIn(path, magpieID)
chat.APIMode, chat.BaseURL = mode, hermesBase(gw, mode)
chat.APIMode, chat.BaseURL = mode, pre+hermesBase(gw, mode)
if split {
chat.Models = slices.DeleteFunc(chat.Models, func(id string) bool { return slices.Contains(anth, id) })
}
@@ -748,7 +819,7 @@ func hermesEntries(at place, path string) [][2]any {
}
mode, _ = hermesModeIn(path, hermesAnthropicID)
e := hermesProviderAt(gw)
e.Name, e.APIMode, e.BaseURL, e.Models = hermesAnthropicID, mode, hermesBase(gw, mode), anth
e.Name, e.APIMode, e.BaseURL, e.Models = hermesAnthropicID, mode, pre+hermesBase(gw, mode), anth
// the key as "magpie" has it: a reference to a variable the user
// keeps there goes into this one too
e.APIKey = hermesKeptKey(at, path, magpieID, e.APIKey)
+72
View File
@@ -4,6 +4,7 @@ import (
"os"
"path/filepath"
"slices"
"strings"
"testing"
"github.com/yetone/magpie/internal/appdir"
@@ -224,3 +225,74 @@ func TestHermesKeepsTheUsersAPIMode(t *testing.T) {
t.Fatalf("openai alias:\n%s", raw)
}
}
// Duckb7si on X: Hermes was on magpie, and billion-context's Library page
// had no Hermes to switch on. bili's own plugin for Hermes sets
// HTTPS_PROXY alone, which magpie's http://127.0.0.1 provider never takes,
// so Hermes goes through bili's /bili/ prefix: HermesThrough puts both of
// magpie's entries, in every bot that has them, behind it; a pick and a
// sync keep it (each rewrites base_url), Check takes it as magpie's, and
// off puts the gateway back.
func TestHermesThroughBili(t *testing.T) {
home, path := hermesAnthropicHome(t)
os.WriteFile(path, []byte("model:\n default: kimi-k3\n provider: moonshot\n"), 0o644)
bot := filepath.Join(filepath.Dir(path), "profiles", "coder", "config.yaml")
os.MkdirAll(filepath.Dir(bot), 0o755)
os.WriteFile(bot, []byte("model:\n default: kimi-k3\n provider: moonshot\n"), 0o644)
const prefix = "http://127.0.0.1:8787/bili/"
gw := gateway.URL()
fakeMagpieAt(t, map[string]bool{prefix + gw: true})
a := hermes(home)
if err := HermesThrough(a, prefix); err == nil {
t.Fatal("put a Hermes not on magpie through bili")
}
setUpInMagpie("hermes")
if err := a.Apply("model", "magpie/relay/claude-opus-5-5"); err != nil {
t.Fatal(err)
}
if err := HermesThrough(a, prefix); err != nil {
t.Fatal(err)
}
through := func(when string, want string) {
t.Helper()
for _, p := range []string{path, bot} {
c, raw := readHermes(t, p)
if c.Providers[magpieID] == nil || c.Providers[hermesAnthropicID] == nil ||
c.Providers[magpieID].BaseURL != want+gw+"/v1" || c.Providers[hermesAnthropicID].BaseURL != want+gw {
t.Fatalf("%s: %s:\n%s", when, p, raw)
}
}
if HermesURL(a) != want+gw+"/v1" {
t.Fatalf("%s: HermesURL %q", when, HermesURL(a))
}
if c := a.Check(); c != "" {
t.Fatalf("%s: %s", when, c)
}
}
through("on", prefix)
// a pick, onto the other entry, and a sync keep it
if err := a.Apply("model", "magpie/deepseek/pro"); err != nil {
t.Fatal(err)
}
through("after a pick", prefix)
if err := a.Sync(); err != nil {
t.Fatal(err)
}
through("after a sync", prefix)
// one at an address that isn't a local proxy's route goes back to the
// gateway on a sync, as before
for _, wrong := range []string{"http://127.0.0.1:9999", "https://elsewhere.example/bili/"} {
os.WriteFile(path, []byte(strings.ReplaceAll(readFile(path), prefix, wrong)), 0o644)
if err := a.Sync(); err != nil {
t.Fatal(err)
}
if c, raw := readHermes(t, path); c.Providers[magpieID].BaseURL != gw+"/v1" {
t.Fatalf("%s kept:\n%s", wrong, raw)
}
HermesThrough(a, prefix)
}
if err := HermesThrough(a, ""); err != nil {
t.Fatal(err)
}
through("off", "")
}
@@ -1699,7 +1699,7 @@ magpie.plugin("library", (ctx) => {
row.append(sw);
list.append(row);
}
if (!rows.length) list.append(el("div", "lib-none", t("None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.")));
if (!rows.length) list.append(el("div", "lib-none", t("None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.")));
body.append(list);
}
// What billion-context saved, in its own count: what its running proxy
+4 -4
View File
@@ -910,7 +910,7 @@ magpie.strings({
"Not whole": "不完整",
"bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list 显示:{status}。关闭此开关可移除已有的部分。",
"{agent} folds its context with billion-context": "{agent} 用 billion-context 折叠上下文",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "你的 Agent 里没有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code 或 Zed。",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "你的 Agent 里没有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code、Hermes 或 Zed。",
"billion-context is on for {agent} — restart it to use it": "{agent} 已打开 billion-context — 重启后生效",
"billion-context is off for {agent} — restart it to see it": "{agent} 已关闭 billion-context — 重启后生效",
"billion-context is installed — switch it on for your agents below": "billion-context 已安装 — 在下方为你的 Agent 打开它",
@@ -1831,7 +1831,7 @@ magpie.strings({
"Not whole": "不完整",
"bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list 顯示:{status}。關閉此開關可移除已有的部分。",
"{agent} folds its context with billion-context": "{agent} 用 billion-context 摺疊上下文",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "你的 Agent 裡沒有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code 或 Zed。",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "你的 Agent 裡沒有能配合 magpie 使用 billion-context 的:Pi、omp、OpenCode、Claude Code、Hermes 或 Zed。",
"billion-context is on for {agent} — restart it to use it": "{agent} 已開啟 billion-context — 重啟後生效",
"billion-context is off for {agent} — restart it to see it": "{agent} 已關閉 billion-context — 重啟後生效",
"billion-context is installed — switch it on for your agents below": "billion-context 已安裝 — 在下方為你的 Agent 開啟它",
@@ -2752,7 +2752,7 @@ magpie.strings({
"Not whole": "不完全",
"bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list の表示:{status}。オフにすると残っている部分を取り除きます。",
"{agent} folds its context with billion-context": "{agent} のコンテキストを billion-context で畳み込む",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "billion-context を magpie と使えるエージェントがありません:Pi、omp、OpenCode、Claude Code、Zed。",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "billion-context を magpie と使えるエージェントがありません:Pi、omp、OpenCode、Claude Code、Hermes、Zed。",
"billion-context is on for {agent} — restart it to use it": "{agent} で billion-context をオンにしました — 再起動すると使えます",
"billion-context is off for {agent} — restart it to see it": "{agent} で billion-context をオフにしました — 再起動すると反映されます",
"billion-context is installed — switch it on for your agents below": "billion-context をインストールしました — 下でエージェントごとにオンにしてください",
@@ -3673,7 +3673,7 @@ magpie.strings({
"Not whole": "Unvollständig",
"bili plugin list says: {status}. Switch it off to take out what is there.": "bili plugin list sagt: {status}. Schalte es aus, um zu entfernen, was da ist.",
"{agent} folds its context with billion-context": "{agent} faltet seinen Kontext mit billion-context",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code or Zed.": "Keiner deiner Agenten kann billion-context mit magpie nutzen: Pi, omp, OpenCode, Claude Code oder Zed.",
"None of your agents can use billion-context with magpie: Pi, omp, OpenCode, Claude Code, Hermes or Zed.": "Keiner deiner Agenten kann billion-context mit magpie nutzen: Pi, omp, OpenCode, Claude Code, Hermes oder Zed.",
"billion-context is on for {agent} — restart it to use it": "billion-context ist für {agent} an — starte ihn neu, um es zu nutzen",
"billion-context is off for {agent} — restart it to see it": "billion-context ist für {agent} aus — starte ihn neu, damit es wirkt",
"billion-context is installed — switch it on for your agents below": "billion-context ist installiert — schalte es unten für deine Agenten ein",
+6 -5
View File
@@ -37,12 +37,13 @@ import (
// bili's local proxy, which forwards to the gateway (ANTHROPIC_BASE_URL
// .../bili/<magpie's address>). Codex's lane is an MCP server only, ZCode's
// routes only its own provider, Kimi Code's renames the default model in
// config.toml at each start (bili-kimi), dsh's installs through dsh's
// package manager, and Hermes' can't be tried without touching its
// launcher: none of those is offered.
// config.toml at each start (bili-kimi) and dsh's installs through dsh's
// package manager: none of those is offered.
//
// Zed has no plugin of bili's: its magpie provider goes through bili's
// /bili/ prefix with bili start answering there (biliURLLanes, bili_url.go).
// Zed has no plugin of bili's, and Hermes' sets HTTPS_PROXY alone, which
// magpie's http://127.0.0.1 provider never takes: their magpie provider
// goes through bili's /bili/ prefix with bili start answering there
// (biliURLLanes, bili_url.go).
//
// bili's remove doesn't put a file back as it was: it leaves "packages": []
// in Pi's settings.json and "extensions:" in omp's config.yml, and after
+60
View File
@@ -13,6 +13,7 @@ import (
"time"
"github.com/yetone/magpie/internal/agent"
"github.com/yetone/magpie/internal/appdir"
"github.com/yetone/magpie/internal/gateway"
"github.com/yetone/magpie/internal/proc"
"github.com/yetone/magpie/internal/testenv"
@@ -542,6 +543,65 @@ func TestBiliZedThroughPrefix(t *testing.T) {
}
}
// TestBiliHermesThroughPrefix (Duckb7si on X): Hermes on magpie had no
// row on billion-context's page. bili's plugin for Hermes sets HTTPS_PROXY
// alone, which magpie's http://127.0.0.1 provider never takes, so Hermes
// goes through the /bili/ prefix as Zed does: switched on, bili start
// answers and magpie's provider's base_url is behind the prefix; off, it is
// on the gateway again and magpie's bili start ends. bili's plugin
// installer never runs for it.
func TestBiliHermesThroughPrefix(t *testing.T) {
h := sandbox(t)
f := newFakeBili(t, h)
t.Setenv("HERMES_HOME", "")
holdCLI(t, h, "hermes")
cfg := filepath.Join(appdir.HermesHome(), "config.yaml")
gw := gateway.URL() + "/v1"
write(t, cfg, "# mine\nmodel:\n default: deepseek/pro\n provider: magpie\nproviders:\n magpie:\n name: magpie\n base_url: "+gw+"\n api_key: magpie\n api_mode: chat_completions\n")
serving, served, stopped := false, 0, 0
was := []any{biliServe, biliStop, biliServing}
biliServe = func(string) error { served++; serving = true; return nil }
biliStop = func() { stopped++; serving = false }
biliServing = func() bool { return serving }
t.Cleanup(func() {
biliServe = was[0].(func(string) error)
biliStop = was[1].(func())
biliServing = was[2].(func() bool)
})
if on, ok := biliOnFor(t)["hermes"]; !ok || on {
t.Fatalf("Hermes offered %v, on %v", ok, on)
}
v, err := SetBili("hermes", true)
if err != nil {
t.Fatal(err)
}
if !slices.Equal(v.Restart, []string{"hermes"}) || v.Backup == "" {
t.Fatalf("restart %v, backup %q", v.Restart, v.Backup)
}
if !strings.Contains(read(t, cfg), "base_url: "+biliPrefix+gw+"\n") || !strings.Contains(read(t, cfg), "# mine") || served != 1 {
t.Fatalf("served %d, config:\n%s", served, read(t, cfg))
}
if !biliOnFor(t)["hermes"] {
t.Fatal("Hermes isn't shown on")
}
serving = false
keepBiliServe(context.Background())
if served != 2 {
t.Fatalf("bili start run %d times, want 2", served)
}
if _, err := SetBili("hermes", false); err != nil {
t.Fatal(err)
}
if !strings.Contains(read(t, cfg), "base_url: "+gw+"\n") || stopped != 1 || biliOnFor(t)["hermes"] {
t.Fatalf("stopped %d, config:\n%s", stopped, read(t, cfg))
}
if len(filter(f.runs, "plugin install", "plugin remove")) != 0 {
t.Fatalf("ran %v", f.runs)
}
}
// TestBiliVersionPastItsWarnings: `bili --version` is read with stderr,
// and bili 0.1.213 on mote wrote a config warning before the version; the
// card said "2026-11-09T23:44:06.211" for the version.
+13
View File
@@ -48,11 +48,24 @@ type biliURLLane struct {
// zedThrough is agent.ZedThrough; a var for tests, which save no key.
var zedThrough = agent.ZedThrough
// Hermes has a plugin of bili's (bili plugin install hermes), but it
// routes Hermes's traffic by setting HTTPS_PROXY in Hermes's process
// alone (hermes-plugin/__init__.py apply_env), and magpie's provider is at
// http://127.0.0.1, which that never takes: the plugin would add its
// tools while nothing folds. So Hermes goes through the /bili/ prefix as
// Zed does: agent.HermesThrough puts the base_url of magpie's entries, in
// every profile that has them, behind it, which a sync and a pick keep
// (Duckb7si on X).
var biliURLLanes = map[string]biliURLLane{
"zed": {
on: func(a *agent.Agent) bool { return strings.HasPrefix(agent.ZedURL(a), biliPrefix) },
set: func(a *agent.Agent, prefix string) error { return zedThrough(a, prefix) },
},
"hermes": {
on: func(a *agent.Agent) bool { return strings.HasPrefix(agent.HermesURL(a), biliPrefix) },
set: agent.HermesThrough,
},
}
// biliServing says bili start answers at biliOrigin: its health is
+2 -2
View File
@@ -237,9 +237,9 @@ magpie library sync # エージェントに書き直す</pre>
<p>RTK タブでは <a href="https://www.rtk-ai.app/">RTK</a> をエージェントごとにオンにします。エージェントのシェルコマンドが RTK を通り、出力が短くなってトークンを節約します。magpie は RTK をインストールでき、RTK がなくてもオフにできます。</p>
<h2 id="billion-context"><a class="anchor" href="#billion-context">billion-context</a></h2>
<p>billion-context タブでは <a href="https://github.com/ranxianglei/billion-context">billion-context</a> のプラグインをエージェントごとにオンにします。長いセッションの古いやり取りを、モデルが再び開ける要約に畳み込み、セッションをモデルのコンテキストウィンドウに収めます。対象は Pi、omp、OpenCode、Claude Code、Zed で、オンにしてもリクエストは magpie を通ります。magpie はインストールでき(<code>npm install -g billion-context --prefix=~/.local</code>)、billion-context 自身のインストーラーとリムーバーを実行します。オフにすると、インストールで変わったエージェントの設定を元に戻します。ここでオンにしたエージェントでは billion-context-pi や opencode-acp を併用できません。</p>
<p>billion-context タブでは <a href="https://github.com/ranxianglei/billion-context">billion-context</a> のプラグインをエージェントごとにオンにします。長いセッションの古いやり取りを、モデルが再び開ける要約に畳み込み、セッションをモデルのコンテキストウィンドウに収めます。対象は Pi、omp、OpenCode、Claude Code、Hermes、Zed で、オンにしてもリクエストは magpie を通ります。magpie はインストールでき(<code>npm install -g billion-context --prefix=~/.local</code>)、billion-context 自身のインストーラーとリムーバーを実行します。オフにすると、インストールで変わったエージェントの設定を元に戻します。ここでオンにしたエージェントでは billion-context-pi や opencode-acp を併用できません。</p>
<p>Claude Code では、billion-context のインストールが Claude Code 自身の自動コンパクトをオフにします。magpie はそれをオンに戻すので、billion-context が畳み込まないセッション(Claude デスクトップアプリの Code タブなど)は「Prompt is too long」で止まらずにコンパクトされます。自分で設定した <code>DISABLE_AUTO_COMPACT</code> はそのままです。</p>
<p>Zed には billion-context のプラグインがありません。オンにすると、magpie は <code>bili start</code> を実行し、Zed の magpie プロバイダーのアドレスを <code>http://127.0.0.1:8787/bili/</code> に magpie のアドレスを続けたものにします。billion-context があらゆるクライアント向けに案内している接続方法です。先に Agents ページで Zed に magpie のモデルを選んでください。オン・オフの後は Zed を再起動します。</p>
<p>Zed には billion-context のプラグインがなく、Hermes のプラグインは HTTPS の通信しか扱いませんが、magpie のローカルアドレスは HTTPS ではありません。オンにすると、magpie は <code>bili start</code> を実行し、エージェントの magpie プロバイダーのアドレスを <code>http://127.0.0.1:8787/bili/</code> に magpie のアドレスを続けたものにします。billion-context があらゆるクライアント向けに案内している接続方法です。Hermes では magpie のプロバイダーがあるすべてのプロファイルが対象です。先に Agents ページでそのエージェントに magpie のモデルを選んでください。オン・オフの後はエージェントを再起動します。</p>
<p>カードには billion-context が節約したトークン数を、billion-context 自身の集計で表示します。ダッシュボードと同じ純節約量(折りたたみ後の再構築と要約のコストを差し引いた値)に、折りたたみ回数とセッション数を添え、このコンピューターで動いたすべてのセッションが対象です。magpie は動いている billion-context から読み取ります(<code>/__bili/overview</code>)。動いていないときは、最後に読んだ数と時刻を表示します。billion-context がエージェントで動くまでは数は表示されません。</p>
<h2 id="touch"><a class="anchor" href="#touch">magpie が触るもの</a></h2>
+2 -2
View File
@@ -237,9 +237,9 @@ magpie library sync # write it into the agents again</pre>
<p>The RTK tab turns on <a href="https://www.rtk-ai.app/">RTK</a> per agent: the agent’s shell commands run through RTK, which shortens their output to save tokens. magpie can install RTK for you; turning it off works with RTK gone.</p>
<h2 id="billion-context"><a class="anchor" href="#billion-context">billion-context</a></h2>
<p>The billion-context tab turns on <a href="https://github.com/ranxianglei/billion-context">billion-context</a>’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code and Zed, whose requests still go through magpie with it on. magpie can install it for you (<code>npm install -g billion-context --prefix=~/.local</code>) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp.</p>
<p>The billion-context tab turns on <a href="https://github.com/ranxianglei/billion-context">billion-context</a>’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code, Hermes and Zed, whose requests still go through magpie with it on. magpie can install it for you (<code>npm install -g billion-context --prefix=~/.local</code>) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp.</p>
<p>For Claude Code, billion-context’s install turns Claude Code’s own auto-compaction off. magpie turns it back on, so a session billion-context doesn’t fold, such as one in the Claude desktop app’s Code tab, compacts instead of stopping at “Prompt is too long”. A <code>DISABLE_AUTO_COMPACT</code> you set yourself is left as it is.</p>
<p>Zed has no billion-context plugin. Turned on, magpie runs <code>bili start</code> and points Zed’s magpie provider at <code>http://127.0.0.1:8787/bili/</code> followed by magpie’s address, the route billion-context documents for any client. Pick one of magpie’s models for Zed on the Agents page first, and restart Zed after turning it on or off.</p>
<p>Zed has no billion-context plugin, and Hermes’ plugin only catches HTTPS traffic, which magpie’s local address isn’t. Turned on, magpie runs <code>bili start</code> and points the agent’s magpie provider at <code>http://127.0.0.1:8787/bili/</code> followed by magpie’s address, the route billion-context documents for any client; for Hermes, in every profile that has magpie’s provider. Pick one of magpie’s models for the agent on the Agents page first, and restart it after turning it on or off.</p>
<p>The card shows how many tokens billion-context saved, in its own count: the net savings its dashboard shows, after the rebuilds a fold causes and the summaries’ cost, with how many folds and sessions, over every session it ran on this computer. magpie asks a running billion-context for it (<code>/__bili/overview</code>); when none runs, the card shows the last count it read and when. It shows nothing until billion-context has run for an agent.</p>
<h2 id="touch"><a class="anchor" href="#touch">What magpie touches</a></h2>
+2 -2
View File
@@ -237,9 +237,9 @@ magpie library sync # 重新写进各个 Agent</pre>
<p>RTK 标签可以按 Agent 打开 <a href="https://www.rtk-ai.app/">RTK</a>:Agent 的 shell 命令经过 RTK 运行,输出被压短以节省 token。magpie 可以帮你安装 RTK;RTK 卸掉后也能关闭。</p>
<h2 id="billion-context"><a class="anchor" href="#billion-context">billion-context</a></h2>
<p>billion-context 标签可以按 Agent 打开 <a href="https://github.com/ranxianglei/billion-context">billion-context</a> 的插件:它把长会话里较早的对话折叠成模型可以再展开的摘要,让会话始终留在模型的上下文窗口内。支持 Pi、omp、OpenCode、Claude Code 和 Zed,打开后它们的请求仍经过 magpie。magpie 可以帮你安装(<code>npm install -g billion-context --prefix=~/.local</code>),并运行它自己的安装和卸载命令;关闭时会把安装改动过的 Agent 设置恢复原样。在这里打开的 Agent 不能再同时使用 billion-context-pi 或 opencode-acp。</p>
<p>billion-context 标签可以按 Agent 打开 <a href="https://github.com/ranxianglei/billion-context">billion-context</a> 的插件:它把长会话里较早的对话折叠成模型可以再展开的摘要,让会话始终留在模型的上下文窗口内。支持 Pi、omp、OpenCode、Claude Code、Hermes 和 Zed,打开后它们的请求仍经过 magpie。magpie 可以帮你安装(<code>npm install -g billion-context --prefix=~/.local</code>),并运行它自己的安装和卸载命令;关闭时会把安装改动过的 Agent 设置恢复原样。在这里打开的 Agent 不能再同时使用 billion-context-pi 或 opencode-acp。</p>
<p>对 Claude Code,billion-context 的安装会关掉 Claude Code 自带的自动压缩。magpie 会把它重新打开,这样 billion-context 没有折叠的会话(比如 Claude 桌面版 Code 标签里的会话)会自动压缩,而不是停在 “Prompt is too long”。你自己设置的 <code>DISABLE_AUTO_COMPACT</code> 保持不变。</p>
<p>Zed 没有 billion-context 插件。打开后,magpie 会运行 <code>bili start</code>,并把 Zed 里 magpie 提供方的地址改成 <code>http://127.0.0.1:8787/bili/</code> 加上 magpie 的地址,这是 billion-context 为任意客户端给出的接法。请先在 Agents 页给 Zed 选一个 magpie 的模型;打开或关闭后重启 Zed。</p>
<p>Zed 没有 billion-context 插件;Hermes 的插件只接管 HTTPS 流量,而 magpie 的本机地址不是 HTTPS。打开后,magpie 会运行 <code>bili start</code>,并把 Agent 里 magpie 提供方的地址改成 <code>http://127.0.0.1:8787/bili/</code> 加上 magpie 的地址,这是 billion-context 为任意客户端给出的接法;Hermes 的每个配置了 magpie 提供方的 profile 都会改。请先在 Agents 页给这个 Agent 选一个 magpie 的模型;打开或关闭后重启它。</p>
<p>卡片会显示 billion-context 节省了多少 token,用的是它自己的统计:它的面板上的净节省,已扣除折叠后的重建和摘要的开销,并附上折叠次数和会话数,覆盖这台电脑上它运行过的所有会话。magpie 向正在运行的 billion-context 读取这些数字(<code>/__bili/overview</code>);它没在运行时,卡片显示上次读到的数字和时间。billion-context 为 Agent 运行过之前,这里不显示数字。</p>
<h2 id="touch"><a class="anchor" href="#touch">magpie 会改什么</a></h2>
+2 -2
View File
@@ -2916,11 +2916,11 @@ The RTK tab turns on [RTK](https://www.rtk-ai.app/) per agent: the agent’s she
## billion-context
The billion-context tab turns on [billion-context](https://github.com/ranxianglei/billion-context)’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code and Zed, whose requests still go through magpie with it on. magpie can install it for you (`npm install -g billion-context --prefix=~/.local`) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp.
The billion-context tab turns on [billion-context](https://github.com/ranxianglei/billion-context)’s plugin per agent: it folds older turns of a long session into summaries the model can open again, so the session stays inside the model’s window. It is offered for Pi, omp, OpenCode, Claude Code, Hermes and Zed, whose requests still go through magpie with it on. magpie can install it for you (`npm install -g billion-context --prefix=~/.local`) and runs its own installer and remover; turning it off puts back what the install changed in the agent’s settings. An agent turned on here can’t also run billion-context-pi or opencode-acp.
For Claude Code, billion-context’s install turns Claude Code’s own auto-compaction off. magpie turns it back on, so a session billion-context doesn’t fold, such as one in the Claude desktop app’s Code tab, compacts instead of stopping at “Prompt is too long”. A `DISABLE_AUTO_COMPACT` you set yourself is left as it is.
Zed has no billion-context plugin. Turned on, magpie runs `bili start` and points Zed’s magpie provider at `http://127.0.0.1:8787/bili/` followed by magpie’s address, the route billion-context documents for any client. Pick one of magpie’s models for Zed on the Agents page first, and restart Zed after turning it on or off.
Zed has no billion-context plugin, and Hermes’ plugin only catches HTTPS traffic, which magpie’s local address isn’t. Turned on, magpie runs `bili start` and points the agent’s magpie provider at `http://127.0.0.1:8787/bili/` followed by magpie’s address, the route billion-context documents for any client; for Hermes, in every profile that has magpie’s provider. Pick one of magpie’s models for the agent on the Agents page first, and restart it after turning it on or off.
The card shows how many tokens billion-context saved, in its own count: the net savings its dashboard shows, after the rebuilds a fold causes and the summaries’ cost, with how many folds and sessions, over every session it ran on this computer. magpie asks a running billion-context for it (`/__bili/overview`); when none runs, the card shows the last count it read and when. It shows nothing until billion-context has run for an agent.