agent: omp 18.1.6 and later name themselves; magpie's User-Agent only for an older omp (Zyvaletta on X)

magpie wrote `headers: {User-Agent: omp}` into omp's models.yml for every
omp. A newer omp sends `omp/<version>` itself, and the header put that
version out of sight.

From omp's own source: pi-ai 18.1.6 (CHANGELOG 2026-09-03, "Inference
requests now identify as omp by default") wraps fetch in
withInferenceUserAgent, later transportFetch, which sets User-Agent
omp/<VERSION> only when none is set. Real omp runs against a stand-in
gateway on mote, sandbox HOME, `bun add @oh-my-pi/pi-coding-agent@<v>`,
every API (Chat, Responses, Messages, Gemini):
  16.3.5 and 18.1.5: Bun/1.4.2
  18.1.6 and 18.4.4: omp/<version>
18.15+ needs Bun >= 1.4.4 (mote has 1.4.2); its source (18.15.0,
18.22.2) has the same transportFetch.

Now (ompUserAgent): no header from 18.1.6 on; omp/<installed version>
before; plain omp when the version isn't known. The version comes from
the installed package.json (InstalledVersion), never the network.
ompKept takes a User-Agent of magpie's own (omp, or omp/<version>) for
magpie's, so an old `User-Agent: omp` is replaced or removed on the next
sync, and any other value, under any casing, is the user's and stays
alone. usage.AgentOf cuts at "/", so omp, omp/16.3.5 and omp/18.4.4 all
count as omp; nothing reads omp's version from the UA.

Tests (internal/agent/omp_useragent_test.go): TestOmpUserAgentByVersion,
TestOmpOldMagpieUserAgentSynced, TestOmpUsersOwnUserAgentStays.

Broken by hand: origin's omp.go with a stub ompOwnUserAgent, all three
red; ompKept returning yamlKept's result unchanged, the last two red.

Real omp with the new header (mica, same stand-in): 16.3.5 and 18.1.5
with `User-Agent: omp/<v>` send omp/<v> on all four APIs.

Docs: docs/subsystems/agent-wiring.md row "omp's User-Agent"; site
omp.html en/zh/ja.

Run at this tree (base ed405d1d7, mica):
  gofmt -l on changed files: nothing
  go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok
  go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok
  go test -count=1 -timeout 45m ./... (sandbox HOME, mote, at the pre-rebase head): every package ok but
  gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (red on origin/main be400389b too, #7117) and gui
  TestSetPortServesWhenTheOldOneWasTaken (TempDir cleanup race under load 48; 5 of 5 ok alone).
  After the rebase onto 352b124b3..be400389b: internal/agent (45m timeout), fx, usage ok.
No GUI files touched; GUI suite not run.
Not tried: omp 18.15+ run for real (needs Bun >= 1.4.4); a WSL omp.
This commit is contained in:
yetone
2026-11-19 23:03:32 +08:00
parent be400389ba
commit fa52741ebc
12 changed files with 257 additions and 16 deletions
File diff suppressed because one or more lines are too long
+95 -6
View File
@@ -11,6 +11,7 @@ package agent
import (
"fmt"
"maps"
"os"
"path/filepath"
"slices"
@@ -632,9 +633,8 @@ type ompProviderEntry struct {
// key the gateway is shared on the network with
Auth string `yaml:"auth,omitempty"`
APIKey string `yaml:"apiKey,omitempty"`
// Headers name omp to the gateway: omp 16.x asks with Bun's User-Agent
// and only a later one with its own (omp/18.4.4), so its requests went
// to "Bun" in usage and past omp's own rules and stand-ins
// Headers name omp to the gateway where omp doesn't itself
// (ompUserAgent)
Headers map[string]string `yaml:"headers,omitempty"`
// Compat names the header omp sends its session in. omp names the
// conversation on Anthropic's Messages API (X-Claude-Code-Session-Id),
@@ -655,6 +655,44 @@ const ompSessionSince = "16.0.6"
// file away over a max.
const ompMaxSince = "16.4.0"
// ompNamedSince is the first omp that names itself to every provider: its
// requests carry User-Agent omp/<version> (pi-ai 18.1.6, transportFetch's
// withInferenceUserAgent: "Inference requests now identify as omp by
// default"). 18.1.5 and older, 16.x among them, ask with Bun's (Bun/1.4.2),
// on Chat, Responses, Messages and Gemini alike; each run against a stand-in
// gateway, 16.3.5, 18.1.5, 18.1.6 and 18.4.4.
const ompNamedSince = "18.1.6"
// ompUserAgent is the User-Agent magpie's provider names omp by, "" for
// none. Before ompNamedSince omp asks with Bun's, so its requests went to
// "Bun" in usage and past omp's own rules and stand-ins: magpie names it,
// with its version. One that names itself is left to, as a header would
// put its own version out of sight (Zyvaletta on X). One whose version
// isn't known is named plain omp: a newer one loses its version to it, an
// older one unnamed would be Bun's.
func ompUserAgent(version string) string {
switch {
case version == "":
return "omp"
case Newer(ompNamedSince, version):
return "omp/" + version
}
return ""
}
// ompOwnUserAgent says whether a User-Agent in magpie's provider is one
// magpie writes (ompUserAgent): plain omp, as every magpie before wrote,
// or omp/<version> (a pre-release's too). Any other is the user's.
func ompOwnUserAgent(v string) bool {
if v == "omp" {
return true
}
ver, ok := strings.CutPrefix(v, "omp/")
return ok && ompVersionRe.MatchString(ver)
}
var ompVersionRe = lazyre.New(`^v?[0-9]+(\.[0-9]+)*([-+][0-9A-Za-z.+-]*)?$`)
// ompVersion is the version of the omp on PATH, "" when not known; a var so
// tests can fake it.
var ompVersion = func() string { return (&Agent{ID: "omp", Bin: "omp"}).InstalledVersion() }
@@ -748,8 +786,10 @@ func ompProviderAt(gw, version string) ompProviderEntry {
}
images := ompImageModels(version, ms)
ms = append(ms, images...)
e := ompProviderEntry{BaseURL: gw + "/v1", API: "openai-completions", Auth: "none",
Headers: map[string]string{"User-Agent": "omp"}, Models: ms}
e := ompProviderEntry{BaseURL: gw + "/v1", API: "openai-completions", Auth: "none", Models: ms}
if ua := ompUserAgent(version); ua != "" {
e.Headers = map[string]string{"User-Agent": ua}
}
if version != "" && !Newer(ompSessionSince, version) {
e.Compat = map[string]string{"promptCacheSessionHeader": "x-session-affinity"}
}
@@ -824,8 +864,57 @@ func ompGeminiMode(id string) string {
// ProviderConfigSchema). Each stays; the address, API, auth, key and model
// list are magpie's, an auth or key it no longer writes gone with it, so a
// loopback's auth: none never sits beside the key a WSL omp needs (#2030).
//
// A User-Agent header is magpie's while it is one magpie writes
// (ompOwnUserAgent): the one it writes now takes its place, or none, so an
// omp that names itself is no longer named plain omp by an older magpie's
// header. Any other is the user's and stays, in place of magpie's.
func ompKept(path string, e ompProviderEntry) any {
return yamlKept(path, "providers."+magpieID, e, "baseUrl", "api", "auth", "apiKey", "models")
kept := yamlKept(path, "providers."+magpieID, e, "baseUrl", "api", "auth", "apiKey", "models")
out, ok := kept.(map[string]any)
if !ok {
return kept
}
var have map[string]any
if raw, err := edit.Read(path); err == nil {
var doc struct {
Providers map[string]struct {
Headers map[string]any `yaml:"headers"`
} `yaml:"providers"`
}
if yaml.Unmarshal(raw, &doc) == nil {
have = doc.Providers[magpieID].Headers
}
}
theirs := map[string]any{}
for k, v := range have {
if s, _ := v.(string); strings.EqualFold(k, "User-Agent") && !ompOwnUserAgent(s) {
theirs[k] = v
}
}
headers, _ := out["headers"].(map[string]any)
for k := range headers {
if strings.EqualFold(k, "User-Agent") {
delete(headers, k)
}
}
if len(theirs) > 0 {
if headers == nil {
headers = map[string]any{}
}
maps.Copy(headers, theirs)
} else if ua := e.Headers["User-Agent"]; ua != "" {
if headers == nil {
headers = map[string]any{}
}
headers["User-Agent"] = ua
}
if len(headers) == 0 {
delete(out, "headers")
} else {
out["headers"] = headers
}
return out
}
// ompOwnOptions lists the models of the providers the user added to omp's
+6
View File
@@ -208,6 +208,9 @@ task:
// tell for omp's; magpie's provider names it, and the gateway knows that
// name for omp.
func TestOmpNamedToTheGateway(t *testing.T) {
was := ompVersion
ompVersion = func() string { return "16.3.5" }
t.Cleanup(func() { ompVersion = was })
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
@@ -718,6 +721,9 @@ func TestOmpOwnModels(t *testing.T) {
// magpie's. The address, API, auth and model list stay magpie's, and a key
// magpie doesn't write goes.
func TestOmpKeepsTheUsersSettings(t *testing.T) {
was := ompVersion
ompVersion = func() string { return "" } // named plain omp
t.Cleanup(func() { ompVersion = was })
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
+145
View File
@@ -0,0 +1,145 @@
package agent
import (
"os"
"path/filepath"
"testing"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/usage"
"gopkg.in/yaml.v3"
)
// An omp that names itself (omp/<version>, from 18.1.6) is left to it: a
// User-Agent of magpie's would put its version out of sight (Zyvaletta on
// X). An older one, which asks with Bun's, is named with its version, and
// one whose version isn't known plain omp; the gateway takes each for omp.
func TestOmpUserAgentByVersion(t *testing.T) {
for _, c := range []struct{ version, want string }{
{"16.3.5", "omp/16.3.5"},
{"18.1.5", "omp/18.1.5"},
{"18.1.6", ""},
{"18.4.4", ""},
{"18.22.2", ""},
{"", "omp"},
} {
e := ompProviderAt("http://127.0.0.1:3425", c.version)
got := e.Headers["User-Agent"]
if got != c.want || c.want == "" && len(e.Headers) > 0 {
t.Errorf("omp %q: headers %v, want User-Agent %q", c.version, e.Headers, c.want)
}
if c.want == "" {
continue
}
if usage.AgentOf(got) != "omp" {
t.Errorf("omp %q: %q is taken for %q", c.version, got, usage.AgentOf(got))
}
if !ompOwnUserAgent(got) {
t.Errorf("omp %q: magpie's own %q read back as the user's", c.version, got)
}
}
// what omp sends itself is omp's to the gateway too
if a := usage.AgentOf("omp/18.4.4"); a != "omp" {
t.Errorf("omp/18.4.4 is taken for %q", a)
}
}
// magpie's provider entry in a sandbox's models.yml after a sync, with the
// omp on PATH at version.
func ompSyncedHeaders(t *testing.T, version string) (map[string]string, string) {
t.Helper()
was := ompVersion
ompVersion = func() string { return version }
defer func() { ompVersion = was }()
home := os.Getenv("HOME")
if err := omp(home).Sync(); err != nil {
t.Fatal(err)
}
raw, _ := os.ReadFile(filepath.Join(home, ".omp", "agent", "models.yml"))
var doc struct {
Providers map[string]struct {
Headers map[string]string `yaml:"headers"`
} `yaml:"providers"`
}
if err := yaml.Unmarshal(raw, &doc); err != nil {
t.Fatalf("%v\n%s", err, raw)
}
return doc.Providers[magpieID].Headers, string(raw)
}
func ompUASandbox(t *testing.T) string {
t.Helper()
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
for _, k := range []string{"PI_CODING_AGENT_DIR", "PI_CONFIG_DIR", "OMP_PROFILE", "PI_PROFILE"} {
t.Setenv(k, "")
}
if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro"}}); err != nil {
t.Fatal(err)
}
was := ompVersion
ompVersion = func() string { return "" }
defer func() { ompVersion = was }()
if err := omp(home).Field("model").Set("magpie/deepseek/pro"); err != nil {
t.Fatal(err)
}
return filepath.Join(home, ".omp", "agent", "models.yml")
}
// The User-Agent: omp an older magpie wrote is magpie's: the next sync puts
// the one it writes now in its place, none for an omp that names itself,
// and a header of the user's own beside it stays.
func TestOmpOldMagpieUserAgentSynced(t *testing.T) {
models := ompUASandbox(t)
if err := edit.SetYAML(models,
edit.KV{Path: "providers.magpie.headers.User-Agent", Value: "omp"},
edit.KV{Path: "providers.magpie.headers.X-Mine", Value: "1"},
); err != nil {
t.Fatal(err)
}
h, raw := ompSyncedHeaders(t, "18.9.1")
if _, ok := h["User-Agent"]; ok || h["X-Mine"] != "1" {
t.Fatalf("omp 18.9.1 names itself, yet:\n%s", raw)
}
h, raw = ompSyncedHeaders(t, "16.3.5")
if h["User-Agent"] != "omp/16.3.5" || h["X-Mine"] != "1" {
t.Fatalf("omp 16.3.5:\n%s", raw)
}
// magpie's omp/<version> is magpie's too: an omp updated takes its own
h, raw = ompSyncedHeaders(t, "18.1.5")
if h["User-Agent"] != "omp/18.1.5" {
t.Fatalf("omp 18.1.5 after 16.3.5:\n%s", raw)
}
h, raw = ompSyncedHeaders(t, "18.1.6")
if _, ok := h["User-Agent"]; ok || h["X-Mine"] != "1" {
t.Fatalf("omp 18.1.6 after 18.1.5:\n%s", raw)
}
h, raw = ompSyncedHeaders(t, "")
if h["User-Agent"] != "omp" {
t.Fatalf("an omp of no known version:\n%s", raw)
}
}
// A User-Agent the user set on magpie's provider is theirs, under any
// casing: no sync writes magpie's over it or beside it, for an omp of any
// version.
func TestOmpUsersOwnUserAgentStays(t *testing.T) {
for _, key := range []string{"User-Agent", "user-agent"} {
t.Run(key, func(t *testing.T) {
models := ompUASandbox(t)
if err := edit.SetYAML(models, edit.KV{Path: "providers.magpie.headers." + key, Value: "my-proxy/2"}); err != nil {
t.Fatal(err)
}
for _, v := range []string{"16.3.5", "18.9.1", ""} {
h, raw := ompSyncedHeaders(t, v)
if h[key] != "my-proxy/2" || len(h) != 1 {
t.Fatalf("omp %q: the user's User-Agent not kept alone:\n%s", v, raw)
}
}
})
}
}
+3 -3
View File
@@ -125,7 +125,7 @@ cf5c6a3d327b4dbf3ad0bee9859aae089c2bf1cfae30267225464e3e702f15bc docs/ja/nanobo
991a5ee17e7700cc2d2cf4b4a1bca63c003392b11db2b76fb6ebf96668238e80 docs/ja/nvidia.html
e8278f541c3bc6a04ce0f70d86b1027c9a654ff14d7873197beb61256a83e0ab docs/ja/obsidian.html
69317826319a39d0fcdd9177bc9137e7890338b1bb892c7578e010cd690143ab docs/ja/ollama.html
0baee36f9d11137baaeff0671da2dbc4b3ad686110e3dbaa5a4c87be69fb04b8 docs/ja/omp.html
3c7e6a6e00acb7647a23ba0690dfcb3f7ea342c191e80039da740bdac8087a78 docs/ja/omp.html
f44fd434090e72224b8c8b57db5b9cc793dc5a339f52129a2a62937627fb6b11 docs/ja/openai.html
a2a0612ba194839e6cc44ff674508b6a3c0ed3cdcd9611ce4f7121e60ec33464 docs/ja/openbot.html
949f83634465dd386745fd234e559c838e90d2e8922569ee80f4c8f44993d9b8 docs/ja/openchamber.html
@@ -200,7 +200,7 @@ b633a180341ca14eccb9b3e1fec223659be8f959f0aa7f19cbd178c5fed6c430 docs/nanobot.h
6fb0debc2c1a133a8fd8a0672ee288ee1cddb5f657c6bf38c895106dcfd8dff1 docs/nvidia.html
d6c6fcf9b9f7911ce2f1528c2d57a31f0ea10bfb78c4010d55b53dca7be72cd1 docs/obsidian.html
cd12a9296e191e5feaa2fd93e307498d8706054bae8054ae0a5fea1eaa21f2c2 docs/ollama.html
d9ab1ad5f2aeea0b03d02f1d67cdc173d0436fad8b5aaa6b5cb48605b49a45a7 docs/omp.html
bda25b5a98ac6666898040cdebbb06e07d049a33a32822151fe2e4a4aaacc5b4 docs/omp.html
373d59c1a98fe787b5d249a2ac1afab262de1a99ab06be3c6772b2c020108e14 docs/openai.html
39cfdd19ac25be0f5d26e497f4aa3d1ba77b87edb20cabde5261e47b3f66d87c docs/openbot.html
cc1e9cb94478f7d11ff26dd20b400747894cc86406a51988cb2bb3279b9ff084 docs/openchamber.html
@@ -325,7 +325,7 @@ b9c2428afd18069de546fef49d54e10563c10db9a43f7ddf8e489430c9212207 docs/zh/nanobo
c389fcf6022c91d749e2410e90c9f05ad6795a6b386ad8920dd465cf0c3a5db7 docs/zh/nvidia.html
9e166805cd0952a1c9f5dd99cb8fcc6ab00dd6bfab8b83058f7adb5c6d0e8b81 docs/zh/obsidian.html
0615951d480cd0c1aeab6656cdf8ce8e3035f801924e2a91b4560cd19aae6a31 docs/zh/ollama.html
2ff88bd2b3cbad3f81613ffc91319ab4315891f06dc19a0c3fc8da6b783c3263 docs/zh/omp.html
251c7ef72de7185dfff3abc511e7c5d6d609700489ebe7892c255741b12bf1fb docs/zh/omp.html
ddd7e7d1ac8ae3ee035a025f6d411120edc21bcf1235951cdfdb24cac3af40c2 docs/zh/openai.html
c9451778181c711df5e840af23bb3e1d56d3b4b68c232c93e55d42459f27db52 docs/zh/openbot.html
74ee415f8db926ed0f48d16e1a5715c4dca2fec7b72c0be4078a1b80d7645e2c docs/zh/openchamber.html
+1 -1
View File
@@ -212,7 +212,7 @@ providers:
<h2 id="scope"><a class="anchor" href="#scope">enabledModels</a></h2>
<p><code>enabledModels</code> にモデルがある間、新しいセッションはそのリストに縛られます。default のモデルがリストになければ始まらず、omp はリストから別のモデルを選びます。そこでリストがあるときは magpie が <code>magpie/**</code> を加え、omp のピッカーと Ctrl+P にも magpie の全モデルが出るようにします。リストは自分のものです。magpie は既存のエントリ、順序、コメントを残し、リストがなければ作らず、フォルダーに限ったエントリには触れません。ほかのロールはこのリストに縛られません。</p>
<h2 id="api"><a class="anchor" href="#api">モデルごとに自分の API</a></h2>
<p>Pi と同じく、各モデルはプロバイダー本来の API で呼ばれ、ゲートウェイは翻訳せずにそのまま中継します。OpenAI の Responses、Anthropic の Messages、Gemini の <code>/v1beta</code> です。Chat 経由だと、Claude はツール呼び出しの間で思考の署名を失っていました。Chat にはそれを置く場所がないからです。magpie は omp にセッション id と自分の名前をヘッダーで送らせるので、使用量では omp として数え、「ゲートウェイの会話を記録」も omp の会話を残します。</p>
<p>Pi と同じく、各モデルはプロバイダー本来の API で呼ばれ、ゲートウェイは翻訳せずにそのまま中継します。OpenAI の Responses、Anthropic の Messages、Gemini の <code>/v1beta</code> です。Chat 経由だと、Claude はツール呼び出しの間で思考の署名を失っていました。Chat にはそれを置く場所がないからです。magpie は omp にセッション id をヘッダーで送らせるので、「ゲートウェイの会話を記録」も omp の会話を残します。omp 18.1.6 以降は自分の名前(<code>omp/&lt;バージョン&gt;</code>)を名乗ります。それより古い omp には magpie が User-Agent で名前を補うので、使用量ではどちらも omp として数えます。magpie のプロバイダーに自分で設定した User-Agent はそのまま残ります。</p>
<h2 id="profiles"><a class="anchor" href="#profiles">プロファイルと WSL</a></h2>
<p><code>~/.omp/profiles/&lt;名前&gt;/agent</code> の各プロファイルはそれぞれ別の omp で、エージェントページに <code>omp#&lt;名前&gt;</code> として、自分の config.yml と models.yml を持って並びます。<code>OMP_PROFILE</code> が選ぶものは既定の行です。WSL のディストリビューションの omp はそちらの <code>~/.omp/agent</code> を使い、NAT 越しに Windows のアドレスへ届くときは、ゲートウェイをネットワークで共有するキーをプロバイダーに付けます。</p>
<h2 id="off"><a class="anchor" href="#off">元に戻す</a></h2>
+1 -1
View File
@@ -212,7 +212,7 @@ providers:
<h2 id="scope"><a class="anchor" href="#scope">enabledModels</a></h2>
<p>While <code>enabledModels</code> lists models, a new session is held to it: a default model outside the list never starts, and omp picks another from the list. So when you have one, magpie adds <code>magpie/**</code> to it, which also keeps all of magpie's models in omp's picker and Ctrl+P. The list is yours: magpie keeps its entries, order and comments, never makes one where there is none, and leaves entries scoped to folders as they are. The other roles aren't held to it.</p>
<h2 id="api"><a class="anchor" href="#api">Each model on its own API</a></h2>
<p>As with Pi, each model is asked on its provider's native API, and the gateway relays it as it is: OpenAI's Responses, Anthropic's Messages, Gemini's <code>/v1beta</code>. Over Chat, a Claude lost its thinking's signatures between tool turns, since Chat has no place for them. magpie also has omp send its session id and its own name in headers, so Usage counts it as omp and Record gateway conversations keeps its turns.</p>
<p>As with Pi, each model is asked on its provider's native API, and the gateway relays it as it is: OpenAI's Responses, Anthropic's Messages, Gemini's <code>/v1beta</code>. Over Chat, a Claude lost its thinking's signatures between tool turns, since Chat has no place for them. magpie also has omp send its session id in a header, so Record gateway conversations keeps its turns. omp 18.1.6 and later name themselves (<code>omp/&lt;version&gt;</code>); for an older omp magpie adds the name as its User-Agent, so Usage counts it as omp either way. A User-Agent you set on magpie's provider yourself stays.</p>
<h2 id="profiles"><a class="anchor" href="#profiles">Profiles and WSL</a></h2>
<p>Each profile in <code>~/.omp/profiles/&lt;name&gt;/agent</code> is an omp of its own, shown on the Agents page as <code>omp#&lt;name&gt;</code> with its own config.yml and models.yml; the one <code>OMP_PROFILE</code> picks is the default row. omp in a WSL distro uses <code>~/.omp/agent</code> there; when it reaches Windows' address from behind NAT, the provider carries the key the gateway is shared on the network with.</p>
<h2 id="off"><a class="anchor" href="#off">Switching back</a></h2>
+1 -1
View File
@@ -212,7 +212,7 @@ providers:
<h2 id="scope"><a class="anchor" href="#scope">enabledModels</a></h2>
<p><code>enabledModels</code> 列了模型时,新会话只能用列表里的:default 角色的模型不在列表里,omp 就从列表里另挑一个。所以你有这个列表时,magpie 会在里面加一条 <code>magpie/**</code>,让 magpie 的所有模型都能在 omp 的选择器和 Ctrl+P 里出现。列表本身是你的:magpie 保留原有条目、顺序和注释,没有列表时不新建,限定在某些文件夹的条目也不动。其他角色不受这个列表限制。</p>
<h2 id="api"><a class="anchor" href="#api">每个模型走自己的接口</a></h2>
<p>和 Pi 一样,每个模型都走它供应商原生的接口,网关原样转发,不做翻译:OpenAI 的 Responses、Anthropic 的 Messages、Gemini 的 <code>/v1beta</code>。走 Chat 的话,Claude 在工具调用之间会丢掉思考的签名,Chat 里没有放它们的地方。magpie 还让 omp 在请求头里带上会话 id 和 omp 自己的名字,用量页按 omp 统计,“记录网关对话”也能记下 omp 的对话。</p>
<p>和 Pi 一样,每个模型都走它供应商原生的接口,网关原样转发,不做翻译:OpenAI 的 Responses、Anthropic 的 Messages、Gemini 的 <code>/v1beta</code>。走 Chat 的话,Claude 在工具调用之间会丢掉思考的签名,Chat 里没有放它们的地方。magpie 还让 omp 在请求头里带上会话 id,“记录网关对话”也能记下 omp 的对话。omp 18.1.6 起会自己报上名字(<code>omp/&lt;版本&gt;</code>);更早的 omp 由 magpie 在 User-Agent 里补上,所以用量页都按 omp 统计。你自己给 magpie 供应商设的 User-Agent 会保留。</p>
<h2 id="profiles"><a class="anchor" href="#profiles">profiles 和 WSL</a></h2>
<p><code>~/.omp/profiles/&lt;名字&gt;/agent</code> 里的每个 profile 都是一个单独的 omp,在 Agent 页显示为 <code>omp#&lt;名字&gt;</code>,有自己的 config.yml 和 models.yml;<code>OMP_PROFILE</code> 选中的那个就是默认那一行。WSL 发行版里的 omp 用那边的 <code>~/.omp/agent</code>;它在 NAT 后面要访问 Windows 的地址时,供应商改带网关在局域网共享用的 Key。</p>
<h2 id="off"><a class="anchor" href="#off">切回</a></h2>
+1 -1
View File
@@ -7450,7 +7450,7 @@ While `enabledModels` lists models, a new session is held to it: a default model
## Each model on its own API
As with Pi, each model is asked on its provider's native API, and the gateway relays it as it is: OpenAI's Responses, Anthropic's Messages, Gemini's `/v1beta`. Over Chat, a Claude lost its thinking's signatures between tool turns, since Chat has no place for them. magpie also has omp send its session id and its own name in headers, so Usage counts it as omp and Record gateway conversations keeps its turns.
As with Pi, each model is asked on its provider's native API, and the gateway relays it as it is: OpenAI's Responses, Anthropic's Messages, Gemini's `/v1beta`. Over Chat, a Claude lost its thinking's signatures between tool turns, since Chat has no place for them. magpie also has omp send its session id in a header, so Record gateway conversations keeps its turns. omp 18.1.6 and later name themselves (`omp/<version>`); for an older omp magpie adds the name as its User-Agent, so Usage counts it as omp either way. A User-Agent you set on magpie's provider yourself stays.
## Profiles and WSL
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long