ac4af582301a4e8a29245dbba767eba31334ddf9
13
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7a56c83e72 |
gateway: a compaction Copilot sealed stays out of Codex's auto-review
echo_ts (Discord #feedback) runs Codex Desktop's turns on GitHub Copilot
through magpie, with Copilot's native compaction on, and Codex's
auto-review on its built-in codex-auto-review through the ChatGPT
sign-in. The guardian's review carries the conversation's history, so
after the first compaction it carried Copilot's sealed compaction item
too. A request for one of Codex's own models with no magpie Codex
account to route it is relayed to the sign-in as it came, and
codexInputAs keeps any non-magpie1: compaction ("OpenAI's own, for
OpenAI"), so OpenAI was sent Copilot's ciphertext and refused every
review: 400 invalid_encrypted_content "The encrypted content P4ih...bDU
could not be verified". After the next compaction, the new ciphertext.
The siblings: a side call routed through magpie (the auto-review set to
a magpie model, a subagent or a title on another provider's model)
met checkpointReaders, found no writer among its candidates and was
refused with checkpointError, so the review failed there too. A turn or
a /responses/compact on one of Codex's own models relayed to the sign-in
sent the seal to OpenAI to be refused (sealedCompact took a Copilot
writer for the sign-in's own and relayed it).
Now:
- compactionAside names the calls Codex makes beside the conversation
with its history in them: the guardian (or anything asked on
codex-auto-review), memory, subagent, title, description, thread
summary, prediction and suggestion. In serve, when the writer of the
sealed compaction isn't among such a call's candidates, it goes on
without the compaction item (withoutCompaction, body and plain);
instructions, developer/user messages, the turns since and their tool
calls and outputs stay. The conversation's own turns are still held
to the writer or refused saying why (#1099), unchanged.
- foreignToSignin: on the relay to Codex's own sign-in (codexBackend), a
compaction magpie recorded as sealed by a provider other than the
Codex subscription is never relayed. A side call goes without it; a
turn or a /responses/compact is answered checkpointError, magpie's
own explanation, with nothing sent to OpenAI. A seal with no record
(OpenAI's own, compacted on the sign-in), one the codex provider
sealed, and one whose provider can't be read are left as before.
No portable plaintext summary exists for a native compaction (only the
writer can read it), so the side call goes without it rather than with
a summary.
Run (on mote, through mote-run, at
|
||
|
|
7a6211d047 |
providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own. A key's provider (built-in or custom) can give each model headers (settings.ModelHeaders["pid/model"]). They go on that provider's requests for that model alone, after the provider's headers and after auth: a name both have is sent once, as the model's, so a user's value is never overridden by the provider's or magpie's key header. The gateway names the model (provider.WithModel) on every route that asks one: chat on each API, translated and streamed, count_tokens, System One's decision, embeddings, images, videos and the model test. A fallback provider serving the same model id gets its own headers only. Accounts and plugins carry their sign-in's headers and take none. The editor's "Name, price and reasoning level" panel is now "Model settings" (every language), with + Add header per model, staged and made with the Save; Restore default takes them away. The rows being typed are kept out of the draft's compare, so an untouched editor still closes without asking. Broken by hand: dropping WithModel from gateway.go turns TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider id check in modelOf turns TestModelHeadersStayWithTheirProvider red. Run, on this stack over origin/main |
||
|
|
d10f377657 |
providers: Names & levels is Names, prices & levels, where a model's own price at one provider is set (ferock4669)
ferock4669 asked on Discord whether magpie has a screen to price each model, since one model can cost differently on each provider. It has: each row in a provider's per-model list has a price box (input, output, cache read, cache write, 1h cache write, long-context tier, $ / 1M tokens), saved in settings' ModelPrices under pid/model. It wins over the list price in Usage (usage.Pricer through provider.BasePriceIn) and in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to be built; the button opening it said only "Names & levels", so nobody finds a price there. What changed: - The button, its panel's heading and fold, and every note that sends the user there say "Names, prices & levels" (zh 名称、价格与推理档位, zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen, Preise & Stufen"); the gateway's vision and compaction notes, the provider package's text, the subsystem pages and the site's start docs (en, zh, ja) follow. - The button's tooltip says it sets what each model costs at this provider; Usage's "estimated" tooltip says where a provider's own price is set and that it counts over the list price. Both in en, zh, zh-TW, ja and de. - Not changed: the Codex model description text in internal/codexcat (it goes to Codex, so a vendor sees it) and core_budget_test's history comment. - app.js: a comment above the price box is shortened so the core script stays under its budget, not raised (app.js 116 bytes under origin/main). Run at the pushed head (rebased on origin/main |
||
|
|
b4267de595 |
gateway: a provider's fallback can be a routing group, routed as the group
01huadalang on Discord: "还有备用模型增加路由组的选择,现在只能选模型". A
provider's Fallback list held models only; a "group/<id>" entry resolved
to the group's first member alone. Now such an entry is served through the
group, as a request to the group would be:
- plan → planPaused: a fallback naming a group (provider.FallbackGroup,
the group as routed, Live) hands its members to planLevel
(planFallbackGroup): the group's own routing, its sink and asides, and
its pause rules (serve passes provider.PausedOut for the agent's folder).
Its trace rows are marked Fallback with the group in Via.
- No loop, each provider/model once a round: a member that is the primary,
a model named earlier, or another fallback group's member is left out
where it comes second. Groups have no fallbacks of their own and a
member's fallbacks are not followed, so nothing leads back. A group that
is gone or off is passed over, as a model none serves is.
- Every sibling that reads p.Fallback now reads a group's members through
provider.FallbackModels: redaction (unredactedRoute: an unmasked
provider with a fallback group holding a remote model is masked),
careful accounts (carefulOf), native compaction, Codex's own turns
(codexFallsBack) and Claude's auto-mode review (claudeReviewed, which
moves from provider.Resolve to ResolveRoute, as the gateway reads
fallbacks).
- CLI: `magpie provider fallback` already took group/<id> (Resolve knows
groups); its usage and error now say so. Pinned by
TestFallbackCmdTakesGroup.
- GUI: the provider editor's Fallback picker lists the routing groups
(providers.gateway.groups) beside the models as chips with the Routing
fan and a muted "routing group" tell; a picked group's row has the same
fan and tell, and a gone one says "No routing group {id} now; it is
skipped". A filter matches a group's name, id and its members'
providers. New strings in zh, zh-TW, ja and de.
- app.js budget raised 187 bytes on main (1,311,922; core 1,531,060), the core's
own editor, no room added; the addition was cut from ~900 bytes first.
- docs/subsystems/gateway-routing.md: the Candidates row says all this.
Not done: a fallback group's turn rules (ruleFor/ruleOver, which can ask
a classifier) are not applied. The plan is made before the primary is
tried, so they would cost a classifier call on every request the primary
answers. Its routing order, sink and pause rules are applied.
Run (at f6e7214af; after the rebase, the last bullet):
- gofmt -l: clean. mote: go build ./...; go vet on the touched packages;
GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...: ok.
- mote: go test -timeout 45m ./...: every package ok except internal/gui:
TestCoreScriptBudget (fixed above, then ok) and ten AppKit window tests
(TestDockJoinLeadsCommandTab, TestPanelCloseHidesIt, TestMainWindowCorners
…) killed at their 30s bars while four other sessions' GUI suites held
mote at load 70-110. Run alone, all ten
pass (TestDockJoinLeadsCommandTab skips) except TestMainWindowCorners,
red at base
|
||
|
|
56d26f0bba |
gateway: a conversation's list is looked at where it sits in the body, not copied (#4004)
gjson.GetBytes copies the value it finds. For "input" or "messages" that is the conversation, so tailOf, the effort, deferred-tools and refs-only checks, Cline's images, Codex's images, the compaction lookups and the title digest each copied a 44 MiB Codex turn once per request to look at it. getIn reads it in place (gjson.Get over the body's bytes). None of the nine sites changes the body while a result is held, and none keeps a string past the request: Codex's image jobs read url.Str and write a new buffer, the compaction encs are lookups, the title keeps a digest. Together with the masked-record copy, a 44 MiB Responses turn sent on as Chat allocates ~89 MB less (1,068 to 1,005 MB over the turn) and runs fewer GCs. Peak live heap is unchanged (282 MB at GOGC=10 with gctrace, before and after): the body, the parsed request and the outgoing Chat body are what is held at the peak. This is less allocation and GC CPU, not a lower RSS peak. TestTailOfReadsInPlace: a 4 MiB conversation's last 64 items come back right, allocating under the tail plus a quarter of the body. Red with GetBytes put back (5,480,048 bytes for a 1.3 MB tail of a 4.1 MB body). Run (mote-run at aa8ded04e, both commits, on |
||
|
|
25fc92d59a |
fallback: a model unchecked in its provider's list is not a fallback to go to (#3911)
The sibling of the group fix before this: a provider's Fallback list
resolved each entry with Resolve, so a fallback the user unchecked in
its own provider's list was still sent to, while the fallback editor
says "No provider serves {id} now; it is skipped". plan's fallbacks,
and the places that read the same list (carefulOf, native compaction's
carrier check, unredactedRoute, codexFallsBack), now resolve through
provider.ResolveRoute, which skips it. ResolveRoute scans the entries
once for the one model rather than building a map per request.
Test: fallback_unpicked_test.go, plan/m answering 429 with fallbacks
a/x (unchecked) and b/x goes to b and never to a.
Run (mote): red on the previous commit's tree ("from ka", a tried
[ka]); green with this one. Full suite as recorded in the previous
commit, which ran at this tree: 76 packages ok, internal/plugin's
TestGatewayHookMixedPiPackage red at load ~134 (#2865), passing alone.
go vet darwin/linux/windows clean.
Not tried: a real provider with a fallback in the app.
Co-authored-by: timonwong <timon86.wang@gmail.com>
|
||
|
|
fff05e55d8 |
gateway: Codex's compaction trigger is summarised, not refused, when no key that lists the model can carry it (#2725)
nativeCompactionFor kept Codex's compaction_trigger whenever the
provider asked had native compaction on and could be asked it on
Responses. When the vendor's lists held the model to a key that speaks
no Responses there (a key set to Chat), compactionCarriers then cleared
every candidate and Codex got 400 carrierError, with no upstream asked:
the dead end #2725 reports. The trigger is now kept only when a key or
account the request would go over (the provider's and its fallbacks',
or a group's members', held and capped ones too, not one whose own
list lacks the model) carries it (plannedCarrier). Otherwise
codexCompact gives magpie's summary through the listed key, as with
native compaction off.
Patch by ggbdpq (#2725): route (a) and both tests are theirs. Changed
from it: their planCarries ran s.plan / s.planGroup, which weighs the
keys, and a provider routed in turn moves its turn along there
(routes.Rotate). nativeCompactionFor runs on every Codex turn (handle,
codexBackend), so each decision would have skipped a key. plannedCarrier
reads perKeyBarred without weighing. Doc sentence in
docs/subsystems/gateway-routing.md.
Run (worktree at
|
||
|
|
ff16f6c552 |
gateway: a remote magpie's providers are each a vendor of their own to a conversation (fremontdango)
fremontdango on Discord ran two magpies. On the local one, a routing
group held one model from two providers of the remote magpie
(office/first/m, office/second/m). Its conversations were kept as if the
two were one vendor, because both are the one remote-magpie key here
(candidate.who()). The same group made on the remote behaved
differently:
- strict: when the first provider ran out, the conversation failed over
to the second, though strict means it never moves
- session/auto: with the first gone, the "same account, other model"
match kept the conversation on the second as "session", though nothing
of it was cached there
- the second's refusal of the first's sealed reasoning was recorded
against the whole remote, so the first's own seals were then taken out
of requests to it
- a native compaction one sealed went to the other too
There is now a vendor identity for these: candidate.vendor() and
sameVendor(who, model). Behind a remote magpie it is the key plus the
remote's provider, the model id's first part (remoteUpstream). A remote
group is one vendor by its whole id, and a model named without a
provider is the key alone. It is used by:
- affine's widest match
- strictOnly and strictKeep
- unanswered
- refused/withoutRefused
- checkpointReaders (native compaction)
- Codex leadFirst
Lanes, requests a minute and leastHeld's per-model seat stay on who(),
the limits the user set on the key here. Sticks and compaction writers
are stored as before (who plus model), so the sticks saved on disk still
match after the update. Only the local magpie (the one with the group)
needs this version.
Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
(559s) at 040a4ec29. After rebasing onto
|
||
|
|
717b69f78a |
routing: a conversation held to its native compaction's account says so, not "the only account on" (#2639)
A turn carrying a native compaction goes only to the account that
sealed it, so the route's order has one account, and Routing's first
line read "{who} is the only account on for {model}". On #2639 that
read as the other account not serving the model. The route now names
the sealer (Route.Compaction, compactionWho), and Routing says the
conversation stays on it because only it can read the compaction, and
that a new conversation uses the others. Translated in zh, zh-TW, ja
and de.
Run on origin/main
|
||
|
|
bf931f82c3 |
gateway: a Codex conversation compacted natively is held to its account only when native compaction is on, and told why when it can't go there (#2642, #2582)
ScarfQian (#2642, still on v0.1.1279): after a native compaction by one Codex account, routing to another answered 400 "only that key or account can read the compaction it sealed ... switched off, removed, or no longer serves". Three causes, one fix each: - #2582 (Dony2050, ump45nose's patch): one of Codex's own models asked on the backend path through magpie's accounts (codexAccounts) kept the compaction_trigger whatever the codex provider's native compaction setting, so every compaction was sealed by and recorded to one account. It is now decided as a magpie model's is: codexInputAs with nativeCompactionFor("codex/<model>"); off (the default) gives codexCompact's magpie1: summary, which any account reads, and records no writer. Unlike ump45nose's branch, /responses/compact and Codex's own single sign-in relay are left as they were: the legacy endpoint's body has no trigger for codexCompact to answer, and a lone sign-in has no other account to move to. - ggbdpq's fix (0ab41eba0, e1646488d, ported as is): a writer whose own model list has since dropped the model sat in planned.left, out of the candidates, so checkpointReaders never found it and refused although it was on. It is now taken back from planned.unlisted (plan, planLevel and the nested weighted plan), its row moved from left to order. sealedReaders, run before it for a sealed subagent task, narrows unlisted too (sibling). - A request carrying a recorded seal while only Codex's own sign-in is on was relayed as it came (codexAccounts false), so with the writer switched off the one account left was sent it. codexSealedFor routes it through serve, where checkpointReaders holds it to the writer. - checkpointError now says the reason magpie's settings give (checkpointGone: provider removed, account signed out, sign-in lapsed, paused while others are on, switched off, kept from the model in Names & levels, key off or gone, model disabled, or the model/group asked for not routing to it), the fix for that reason, and whether native compaction is on for the writer's provider now. The old catch-all sentence is gone. The seal is still treated as readable only by the account that wrote it, as #1099 and #2271 found; chestnutLeeeee's report that another account read one in a direct canary was not tried here (no real accounts). Tests (fake ChatGPT backend, sandbox HOME, nothing on the network): TestCodexOwnModelCompactionHonoursTheToggle (off: summary, no trigger upstream, no writer; on: native seal kept, writer recorded), TestNativeCompactionWriterGoneSaysWhy (spare switched off, own paused, Names & levels, signed out), ggbdpq's TestNativeCompactionWriterWhoseListLacksTheModel and ...ThroughAGroupWhoseListLacksTheModel. All four are red on |
||
|
|
440f66701f |
gateway: a 429 for native compaction's one account says the compaction pinned it, not that every account is capped (#2517)
When a conversation was compacted natively, only the key or account that sealed the compaction can read it (#1099), so checkpointReaders keeps the candidates to that one. When that account was at its usage cap, the 429 and the call record said "every account that serves X is held at the usage cap", although the other accounts were never candidates. That sent lm0711 looking at routing modes, which can't change it. checkpointHeld tells this case apart: the plan held only the sealer's account(s), and others were left out for the checkpoint. The error then names the account and its window, says the compaction it sealed is what keeps the conversation there, that routing mode and stays don't change that, and to raise the cap / spend credits or start a new conversation. The record reads "native compaction's account at its usage cap" (or its credits / both variants). cappedError and cappedRecord are unchanged for every other 429; their text is split into heldReasons and heldAdvice so both share it. docs/subsystems/gateway-routing.md says so. Test: TestNativeCompactionWriterAtItsCap seals a checkpoint on one account, caps it, and checks the 429 body and the record. Broken by hand (checkpointHeld returning nil), it fails with the old "every account" text. Run on origin/main |
||
|
|
4ad929fd4d |
gateway: a native compaction a fallback seals is recorded to it, and its next turn goes there with the compaction, not answered 200 without it (#2271, JasonBuildAI)
With native compaction on for a provider, Codex's compaction_trigger
goes to any candidate whose wire carries it, a fallback included. The
compaction watcher recorded the writer only when the candidate that
answered had native compaction on itself (`if s.compactsNatively(...)
{ sealedBy = &c }`), so a fallback's seal went unrecorded. The next turn
carrying it then either went to another provider, which refused the
foreign item, and magpie dropped it (withoutCompaction, guarded only by
`checkpoint == nil`) and answered 200 without the compacted history; or
went to the fallback translated, since keepsCompaction kept a sealed
compaction only for a provider set to compact natively, and the
translation left the item out.
Fix:
- the writer is recorded whoever answered: the watcher exists only when
the trigger was kept, so whoever answered sealed it;
- keepsCompaction also relays a sealed compaction to the provider
recorded as its writer (checkpointOf), whatever its own setting;
- checkpointError no longer says "native compaction is on for <writer>",
which isn't so for a fallback;
- docs/subsystems/gateway-routing.md says so.
Test: TestNativeCompactionFallbackSealStaysWithItsWriter (fa native,
falls back to fb, native off, which seals; a third provider). Broken by
hand, each part fails it:
- recording only native writers: the other provider answers 200 with
the seal dropped;
- keepsCompaction ignoring the record: the writer's next turn (Codex's
shape, offering web_search) goes translated without the seal;
- the old wording: the error says native compaction is on.
Run on the rebased head (origin/main plus #2274 and this):
go test ./internal/gateway/ -count=1, gofmt -l, go vet -tags nogui for
GOOS=darwin/linux/windows ./internal/gateway: see the ready note; all
green before this was handed over.
Full suite: SUITE_LINE
|
||
|
|
82f48f0935 |
gateway, provider, gui: a provider set to compact natively is asked Codex's compaction_trigger as sent and its sealed compaction goes back unchanged; a checkpoint stays with its writer (#1099)
A new per-provider option, off by default. With it on, Codex's compaction_trigger reaches the provider as Codex sent it, and the provider's encrypted compaction item goes back to Codex unchanged instead of magpie's magpie1: summary. Off, nothing changes. Where it can be on (provider.CarriesCompaction): a provider with a Responses API (Sub2API and other OpenAI relays, a remote magpie), a ChatGPT (codex) account, and the built-in GitHub Copilot on its GPT Responses path. Copilot's Claude models are asked on chat completions, so they still get magpie's summary (CompactsOn). A group compacts natively only when every member does. No silent downgrade: - A turn carrying a sealed compaction goes only to the key or account that wrote it (compactions.json beside affinity.json, 0600, 1024 entries / 30 days). With none left, Codex gets a 400 saying the conversation was compacted natively on <who>, not a summarised or dropped context. - A provider whose request would have to be translated (not relayed) is refused with a 400 instead of losing the item. - The upstream's own refusal goes back to Codex as it came, one call. - base_instructions and Codex's identity are untouched. Turning it on: - GUI: the provider editor's Compaction row, "Codex compacts on this provider" (shown only where the wire can carry it; zh, zh-TW, ja, de). - CLI: magpie provider set <id> compaction=native|magpie. A provider that can't carry it is refused. Run on origin/main |