Commit Graph
5 Commits
Author SHA1 Message Date
yetone f63ea1d5b2 agent: omp asks a Gemini model on Gemini's own API at /v1beta (#4277)
omp gave a model served on Gemini's API the provider's openai-completions,
so the gateway translated Chat for it. ompProviderAt now writes such a
model as OmO does: api google-generative-ai, baseUrl <gateway>/v1beta.

Checked in omp's source (pi-ai providers/google.ts, 16.0.0, 16.3.5,
18.9.1, 18.14.0): it posts to baseUrl/models/<id>:streamGenerateContent
?alt=sse with x-goog-api-key, and throws only when the key is empty. The
issue's claim that auth: none breaks it is wrong: under auth: none omp's
model registry hands the client its no-auth key "N/A" (kNoAuth), which
loopback takes, so the provider stays keyless; a WSL omp under NAT sends
its apiKey there as before. Unlike pi-ai, omp's Google client takes a
custom fetch, so the Raft reason Pi stays on Chat doesn't apply.

Thinking: a Gemini 3+ model gets mode google-level (thinkingLevel; xhigh
and max go as HIGH, pi-catalog model-thinking.ts), a Gemini 1.x/2.x one
mode budget, since 2.5 refuses a level; omp sends that as
thinkingBudget -1 (custom models.yml has no effortBudgets).

Run:
- TestOmpGeminiModelsAskedOnGeminisAPI, TestOmpGeminiMode (new), and
  TestOmp*/TestPi* on mote: ok.
- Broken by hand (Gemini case taken out): the new test is red on api,
  baseUrl and thinking mode for gem/gemini-3-flash, gem/gemini-2.5-pro and
  hybrid/gemini-3-flash; TestOmpGeminiMode doesn't build on the old code.
- go vet ./internal/agent for darwin, linux, windows: ok; gofmt clean.
- Real omp 18.14.0 (Bun 1.4.4) in a sandbox HOME on mote: magpie built
  from this tree, `magpie provider add gem gemini=<fake>/v1beta`, `magpie
  serve`, `magpie omp gem/gemini-3-flash`, then `omp -p`. omp answered
  with the fake upstream's text through the gateway's /v1beta. Pointed
  straight at a fake server, omp sent POST
  /v1beta/models/gem/gemini-3-flash:streamGenerateContent?alt=sse with
  x-goog-api-key: N/A and User-Agent: omp, and thinkingConfig.thinkingLevel
  HIGH for --thinking high (MINIMAL for off).
- Full suite (go test -timeout 45m -count=1 ./...) on mote at c9b5fbb04
  (origin/main cf9ea977c): every package ok except internal/gui, whose ten
  real-window AppKit tests (panel, dock, tray, titlebar, plugin page) were
  killed at their 20-80s deadlines, #2645 and #4125 (mote's AppKit/launchd
  hang). This change touches no GUI code.

Not tried: a real Gemini account (the upstream was a fake); a Gemini 2.5
model through omp; a WSL omp.
2026-10-30 20:01:38 +08:00
yetone 81a24cf8fe groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.

What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
  public one). Every old form is still accepted as input forever:
  provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
  gateway (validateModel), keys, stats, affinity and usage, so both ids
  route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
  (allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
  exists, found groups are listed by their old id (AutoRefsOn) and
  auto/<x> means that provider's model. Documented in
  docs/subsystems/gateway-routing.md.

Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).

Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.

Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
  nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
  gateway, whose failures were the tests' expected ids (updated here)
  and two regressions now fixed (bare ids; desktop models hiding groups
  by prefix). Every failing test passes on rerun. Load average was
  ~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
  TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
  10.19s), and it fails the same in a git-archive export of 33dbdcc52.
- agent and gateway in full, -p 2 -timeout 120m: gateway ok (2996s).
  agent failed four tests that still expected the old ids
  (TestOmp/PiModelsAskedOnTheirNativeAPI, TestReseatFoundGroupsOff,
  TestReseatKeepsAFoundGroupWithAProviderOff); updating them showed the
  Reseat bug above. After the fix, go test -count=1 -timeout 120m
  ./internal/agent/: ok (1000s, load ~160-220).
- GUI files the change reaches, chromium and webkit: group-found-off and
  the routing files pass, except routing-bodies, routing-model-rest,
  routing-keys-fold and routing-request-metrics, which fail the same with
  33dbdcc52's JS.

Broken by hand and watched red, then restored: CanonicalRef in
validateModel (both-ids routing test), allows() (key tests both ways),
the Save refusal and AutoRefsOn checks in Ref/CanonicalRef (provider
named auto), catalog.Lists' preference (models.dev lookup of the part
after auto/), renameFoundGroups' applied.json check and its SyncCatalog
call (user values kept), PublicRef in visible.go, the codexcat prefix,
samePick in Reseat (TestReseatFoundGroupsOff: opus left on the gone
group).
TestBareModelIDsShared was red before the bare.go fix.

Not verified: no real agent, vendor or models.dev client run; no run on
the Windows box. Settings pickers (vision, title model) holding a saved
group/auto-... value may show it as saved. codexcat can't tell a stored
"auto" provider apart, so its models lose the "text only" hint. The
pre-existing reds above are not filed.
2026-10-20 00:18:51 +08:00
yetone d82985eee1 agent: a routing group whose members are all best on Responses is asked there by Pi, omp, droid and dsh, so its tool-call arguments stream (#1594, ObsidianArch02)
magpieModels gave a routing group no native API, since its members may
each want another. Pi, omp and droid then asked every group on Chat
Completions, and dsh put it on its Chat route, even a group of GPT
members all served on Responses. The gateway translated each answer from
Responses to Chat, and that translation holds a tool call's arguments
until the call ends (#613), so Pi's Code Mode saw no code until the whole
call had been generated.

A group now has APIs ["responses"] when every member, nested groups'
included, is served best on Responses (allResponses over the group's
members, by Provider.Native). Any other group keeps none: one with a Chat
member, and a Messages-only group too, as the gateway knows whether a
Claude thinks adaptively by its own model id, not the group's. dsh moves
a start on such a group to its Responses route (dshStartOnItsRoute); a
dsh session resumed on it asks for the model once, as for any model that
moved routes.

The rest of the request (a protocol picked per group, conversion shown
per request) is not in this commit.

Verified:
- TestPiModelsAskedOnTheirNativeAPI: auto-gpt-5-5, a GPT group and a
  group of that group get openai-responses; a group with a Chat member
  and one of Messages-only members get none. Without the route.go change
  it fails for the three Responses groups.
- TestOmpModelsAskedOnTheirNativeAPI: the same for omp.
- TestGroupOnResponsesRelaysArgumentDeltas (gateway): a group of two
  Responses-only members asked on /v1/responses relays each
  function_call_arguments.delta as the vendor sent it, on /responses.
  It guards what this change relies on, and passed before it too.
- go test ./internal/agent ./internal/provider, gofmt -l, GOOS=linux and
  windows go vet -tags nogui.
- Not tried with a real Pi against a real group.
2026-10-11 21:00:29 +08:00
yetone 7caba10d9c omp: a model's or group's max is offered as max to omp 16.4.0 and later (whqtian on Discord: a routing group with max ticked showed only xhigh in oh-my-pi, while Pi had max) — magpie wrote every model's thinking efforts into omp's models.yml with max taken out and xhigh in its place, since omp 16.3.5's schema stops at xhigh and turns the whole file away over a max; but a group whose levels name both xhigh and max then had no way to max at all, as the gateway keeps an xhigh asked for. omp has taken max since 16.4.0 (pi-ai's changelog; 18.4.8's EffortSchema has it), so an omp on PATH at 16.4.0 or later is now given max as it is; an older one, or one whose version isn't known, keeps xhigh standing in. omp 18.4.8 in a sandbox HOME lists the group's thinking as high,xhigh,max and sends reasoning_effort max with --thinking max. TestOmpGroupOffersMax fails without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 20:18:02 +08:00
yetone 69b366adec omp: each model is asked on its provider's own API (#329) — magpie wrote every model into omp's models.yml as openai-completions, so a Claude's thinking signatures had no place between tool turns. As for Pi, a Responses model now gets api: openai-responses and an Anthropic one api: anthropic-messages at the gateway's /v1/messages, thinking adaptively on Claude 4.6 and later, else on a budget (budget-effort would send output_config.effort, which Sonnet/Haiku 4.5 refuse); groups and the rest stay on Chat. A model offering max made omp 16.3.5 reject the whole file, so every magpie model vanished; max is now offered as xhigh, which the gateway fits to max. Checked with the real omp 16.3.5 in a sandbox HOME against a fake upstream: Claude → POST /v1/messages, deepseek → /v1/chat/completions. TestOmpModelsAskedOnTheirNativeAPI fails without the change; TestOmpMessagesRelayedAsSent guards the relay. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-09-30 22:27:11 +08:00