e4e9eb0928becfa4e48484dde85ef5032671d582
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
683265e867 |
gateway: spawn_agent names every model in Codex 0.169's Lite and catalog requests
@m0eaki on X (Codex 0.169): spawn_agent listed only Codex's first five models, though a remote magpie's model could be spawned by its full slug. In Codex 0.169 a lead on one of OpenAI's own models (the Codex App's default) sends Lite requests (use_responses_lite), with no top-level tools: in multi-agent V2 spawn_agent sits in an additional_tools input item, and with features.model_catalog_in_context the models are in a <model_catalog> developer message, spawn_agent pointing there. magpie widened only tools and tool_search_output, so neither was reached. spawnAgentModels now widens additional_tools like a tool_search_output, and adds the rest of the catalog to a <model_catalog> listing ahead of its closing tag, under the same neutral spawnMore line (no magpie, Codex or count named). The listing is found escaped too (<model_catalog>): on CodexPath a followed or moved subagent's body goes through withModel, whose encoder escapes angle brackets, before spawnAgentModels sees it. Fixtures are real Codex 0.169.0 captures (second request of a turn, sandbox CODEX_HOME, gpt-5.6-luna): V2 Lite, model_catalog_in_context, Lite with a tool search, and a plain tool search. TestSpawnAgentNamesEveryModelInCodex0169 posts each at CodexPath with a lead on OpenAI's model, and calls spawnAgentModels with a lead on magpie's at CodexPath and /v1, the body as Codex wrote it and as withModel writes it again. Sibling left alone, filed: #6639 (a Lite request reshaped for a provider that takes neither Lite's items nor a tool search drops the tools its lead searched for). Run: - Old codex_spawn_models.go: V2 and model_catalog red on all 5 routes each (10 subtests); the two tool-search shapes passed before too. - Broken by hand: hasSpawnCatalog matching only the raw form: the three escaped-body model_catalog subtests go red. Restored, green. - gofmt -l clean. go vet ./internal/gateway and GOOS=windows go vet ./internal/gateway (./... needs Wails' cgo, which the VM lacks), and go test ./internal/gateway -count=1 -timeout 45m: vet clean, gateway ok (861s), at base |
||
|
|
63c91cae5f |
gateway: the body's key checks look for the needle's rarest byte
Each request ran ~45 bytes.Contains over its whole body to ask whether
a key is there at all ("developer", "compaction, "display", the
passthrough key...). Most needles begin with a quote, JSON's commonest
byte, so bytes.Index stopped at every quote, gave up on that and
compared at every byte: on a 2 MB body ~9 ms a request, 36% of the
gateway's CPU in BenchmarkLargeRequest's profile.
bodyHas/bodyIndex find the needle's rarest byte (a static rank of the
bytes JSON, English and code use most) with IndexByte and compare the
needle only there; a needle of common bytes only hands the rest to
strings.Index after 64 misses, so it is never slower than before, and
it allocates nothing (a []byte(sep) of a needle over 32 bytes did).
148 literal and constant needles in internal/gateway use it, and
mayHoldHEIC's "eXB" walk uses bodyIndex.
mayHoldOddBase64 walked every byte through a switch (~2 ms a 2 MB
body); a run it looks for ends a string, so it now looks back from each
quote with a class table and gives the same answer.
Run on mica (Apple M6) at this tree:
- BenchmarkBodyHas, 7 needles over a 2 MB body: 4.43 ms -> 0.38 ms,
0 allocs (was 1).
- BenchmarkLargeRequest -benchtime 200x, before -> after:
anthropic 31.2 -> 28.9 ms, anthropic-group 31.4 -> 27.8,
chat 35.7 -> 32.8, responses 39.8 -> 29.8.
- go vet ./internal/gateway; gofmt -l clean.
- go test ./internal/gateway -count 1 -timeout 45m: ok (858s).
- Broken by hand: bodyIndex's start off by one -> TestBodyIndexIsIndex
red (wrong index on 5 needles and the random bodies); the URL-safe
class never counted -> TestOddBase64LooksAsItWalked red. Both green
again restored.
TestBodyIndexIsIndex holds bodyIndex to bytes.Index on a large
conversation and 3000 random bodies of common and rare bytes;
TestOddBase64LooksAsItWalked holds the new check to the old byte walk
(kept in the test) on 20000 random bodies and the three protocols'
large conversations.
Real account: the built app (mote, sandbox HOME) sent a 6KB request to
DeepSeek on /v1/responses and /v1/messages, both 200 "pong". Not
tried: Codex (the sandbox's sign-in is stale, and renewing it there
would rotate the live refresh token).
|
||
|
|
2f59545d29 |
gateway: a key not given a group listing alone is listed the members it may use (luckymanjc)
luckymanjc on Discord (#general, 11-05): on a second computer, through
Remote magpie, his three Codex accounts offered GPT-6-Luna alone, with
the key his Remote magpie uses held to "Codex 的全部模型" (codex/*),
GPT-6-Luna and the accounts. His screenshot of that key's picker, on the
host, offered GPT-6-Luna alone under Codex too.
Cause: a routing group listing alone (Group.Unlists, "the group alone")
keeps its members out of Catalog(), so out of /v1/models and the key
picker (/api/caller-keys/models), as the group stands in for them there.
Since
|
||
|
|
34116ec012 |
gateway: Codex signed in to one account lists another account's models
bigfisheatsmall on X: Codex was kept signed in to ChatGPT account A, on the Free plan. Account B (Team) was the only account on in magpie. dsh listed B's models and Codex didn't. codexMerged added CodexListed(), which leaves out every ChatGPT account's own models because it assumes the backend lists them. But the backend list is fetched with Codex's own sign-in (A, Free), so B's plan-only models were listed nowhere. Routing already sent codex/<model> to B (codexAccounts). - provider.CodexListedBeside(backend) lists an account's own model by magpie's id (codex/<slug>) when the sign-in's backend list lacks it. codexMerged uses it, and FitOwn keeps those entries. - spawnChoices (spawn_agent's models) had the same gap. It now uses the same rule with the slugs in Codex's models cache. - buildCodexListTag covers the accounts' own models, so another account gaining or losing one has Codex ask for the list again. Every Codex asks once after the update. - TestSyncCatalogAgesCodexCache built its "current" tag by hand from CodexListed(). It now uses provider.CodexListTag(), the tag SyncCatalog compares against. Tests (sandbox HOME, fake backend with per-plan lists): TestCodexListHasAnotherAccountsModels covers the list, routing of codex/gpt-6.1-sol to the Pro account, and spawn_agent's choices. TestCodexListOneAccountNoneTwice checks that a single account gets no codex/ duplicates. Run on mote at this tree: go vet (darwin, windows, linux) on gateway, provider and agent: ok. go test -count=1 on provider, agent and codexcat: ok. go test -run 'Codex|Spawn' on gateway and gui: ok. Run at the tree before the sync_test change and the buildCodexListTag tidy: the full gateway package was ok (1224s). Agent was red only in TestSyncCatalogAgesCodexCache, fixed above. Broken by hand: on the old codexMerged, the new test fails with "Codex's list lacks codex/gpt-6.1-sol: [gpt-6-luna gpt-5.6-terra gpt-5.6-luna]". With only codex_spawn_models.go reverted, it fails with "spawn_agent's models lack codex/gpt-6.1-sol". Not tried: real accounts or a real Codex. Not a full go test ./... run. Not tried: models the backend marks hidden. A Codex here for failover alone (codexOwnOnly) is unchanged. |
||
|
|
a3ee00c05c |
codex: its own GPT models stay in Codex's list when kept for routing groups
士奇 (Discord, 10-28): with a routing group on, the Agents page's Codex list lost its Codex provider section and models, the model dropdown still offered GPT, but the Codex app had none; with the group off they came back. Cause: the codex provider's "Only through routing groups" (Provider.Unlisted, 只通过路由分组使用), or a group that lists itself alone (Group.Unlists), took the ChatGPT account's own models out of Catalog(), so out of Codex's own list too. With no Codex section, the own options were not magpie's, so the own-models switch showed and the picker kept offering GPT; meanwhile #1602 ( |
||
|
|
32f7c4de14 |
provider: Usage only keeps the ChatGPT account's models out of Codex's own picker, spawn_agent and its list's ETag (#2530)
What changed: CodexNativePicked narrows the backend's own list to none of the account's visible models when the codex provider is Usage only (noModels, ServesNone), before the empty-picks fallback that left the list whole. codexModels' existing filter then drops them from /backend-api/codex/models; the hidden entries Codex runs jobs of its own on (codex-auto-review, gpt-reserve) and other providers' models stay. A provider switched off keeps the native list as before. Ported from skygunner's a016fcee (on ggbdpq's diagnosis and proposed ServesNone fix in #2530), with its test TestCodexUsageOnlyCatalog. Two siblings that read the same narrowing were missing it, for picks too: - spawnChoices (spawn_agent's list of the account's models, from models_cache.json) used Hidden and Unlisted but not the picks, so it still named every native model; - buildCodexListTag (the list's ETag and each reply's X-Models-Etag) had no mark of the picks, so a running Codex never asked for the list again after Usage only or a new pick; it now carries ~picked and each slug. The test covers both, and the docs row (providers-accounts.md Model picks) says so. Not changed: codexNativeOff, so a request Codex still sends for a native model is served as it is for an unpicked one today. Run at this head (sandbox HOME, pinned caches): - go test -tags nogui -count=1 ./internal/catalog ./internal/codexcat ./internal/provider ./internal/agent ./internal/gateway before the rebase onto |
||
|
|
b97e0aa2a2 |
gateway: spawn_agent is widened without writing the whole Codex body again (#3394)
Codex sends spawn_agent with every request, so spawnAgentModels ran on each one: it decoded the whole body into a map, decoded every input item into a map, and encoded the body again, so a long conversation was walked three times a request, and went upstream with its keys sorted. It now takes tools (and input, only when it holds a tool_search_output) with topMember, widens them as before, and puts the new values back in place (withMembers); every other byte goes on as Codex sent it. Only a tool_search_output item is decoded and written again (moreSpawnItem); an input with an item that isn't an object no longer stops the others being widened. Run: - A 1.6MB body (Codex 0.162.0's tools from testdata, 300 tool outputs), 30 calls in a scratch test not committed: 16.4ms a call before, 2.3ms after. - Real DeepSeek account in a sandbox HOME, magpie serve on 3482, 12 streamed /v1/responses requests of a synthetic 1.5MB conversation with Codex 0.162.0's real tools and a codex_cli_rs/0.162.1 User-Agent (so the spawn path runs), CPU time from ps, two rounds each: |
||
|
|
125dad5cbb |
gateway: a codex provider used only through routing groups keeps the ChatGPT account's own models out of Codex's list (#1602)
With Codex signed in to ChatGPT, Codex asks magpie's /backend-api/codex/models
for its list, and codexModels passes the backend's own models through,
narrowed only by the codex provider's picks (CodexNativePicked) and the
Agents page's hides (CodexNativeHidden, built from Catalog()). A provider
set to "Only through routing groups" (Provider.Unlisted) has none of its
models in Catalog(), so neither filter saw them: all of the account's
models stayed in Codex's picker, and the Agents page had no Codex group to
hide. Every other agent's list is Catalog-based and already left them out.
provider.CodexNativeUnlisted says which of the account's models are kept
out of agents' lists: every one when the codex provider is Unlisted, and by
slug those a group with Unlists names. codexModels drops them (hidden
entries such as codex-auto-review stay, as with picks; a Codex reached for
failover alone keeps them, as it is handed no groups), spawnChoices drops
the same ones from spawn_agent's list, and CodexListTag carries them so
Codex refetches. gateway-routing.md says so.
Test: TestCodexModelListUnlistedForGroups (a group unlisting gpt-5.5 takes
gpt-5.5 alone; the provider Unlisted takes gpt-6-sol and gpt-5.5 and keeps
codex-auto-review; ETag changes; spawn_agent offers neither; own-only keeps
them). With codex_backend.go and codex_spawn_models.go reverted it fails on
all three checks. Not tried with a real ChatGPT sign-in and Codex app.
Run (sandbox HOME, private GOCACHE, worktree at origin/main
|
||
|
|
403f3845e2 |
gateway: Codex's spawn_agent names every model also when Codex hands it to the lead through a tool search, as it does on 0.162 (Gearclickist on Discord)
Gearclickist, after v0.1.1214: the lead still saw only five models for
its subagents. v0.1.1214 (
|
||
|
|
3c4f8f9aed |
gateway: the models added to Codex's spawn_agent are headed neutrally, naming neither magpie nor Codex's limit (Gearclickist on Discord)
|
||
|
|
5d33f060b7 |
gateway: Codex's spawn_agent names every model a subagent may be put on, not only the first five (Gearclickist on Discord)
Gearclickist turned on "Codex subagents on any model", but when Codex dispatched subagents only a few models could be picked. Codex itself caps the list: spawn_agent's description names only the first five show_in_picker models of its catalog (codex-rs child_config.rs MAX_SPAWN_AGENT_MODEL_OVERRIDES, multi_agents_spec.rs spawn_agent_models_description), Codex's own ahead of magpie's. Yet it takes any catalog model by name (find_spawn_agent_model_name). So the lead saw none of magpie's models. spawnAgentModels (codex_spawn_models.go) adds the rest of the catalog Codex was handed after Codex's own list, under a line of its own, at most 200. It covers spawn_agent at the top level and in Codex's multi_agent_v1 namespace, at CodexPath (codexBackend) and at /v1/responses for Codex (handle). - At CodexPath the list is Codex's own listed models less those hidden on the Agents page, then CodexListed unless Codex is held to its own. - At /v1 it is CodexCatalog under the key's allowance. - A lead the ChatGPT backend answers in multi-agent V2 seals its subagents' tasks for a ChatGPT account (#619), so it is offered Codex's own only. Only the tool's description changes, never base_instructions. With V1 on, it does change in requests to the ChatGPT backend too. Not covered: the model_catalog_in_context feature (under development, off by default) puts a five-model catalog in context, and it is not widened. Run: - go test ./internal/gateway ./internal/agent -count=1 under a sandbox HOME: ok. - TestSpawnAgentNamesEveryModel uses 40 models on a real Codex 0.162.0 request (testdata/workdir/codex-0.162.0.json). Its 4 subtests are CodexPath, /v1, a sealed V2 lead and a V1 lead, and all pass. - With spawnAgentModels returning body by hand: CodexPath, /v1 and V1 go red. - With the sealed rule taken out: V2 goes red. - go vet on darwin, GOOS=linux -tags nogui, and GOOS=windows; gofmt -l is clean. Not verified: a real Codex lead picking one of magpie's models past the fifth from the longer list. |