Files
magpie/internal/provider/codex_seals_test.go
T
yetone 71075af726 codex: "subagents on any model" tells Codex V1 for a relay of the ChatGPT backend too (brethhbbm on X)
brethhbbm on X: lead on relay/gpt-6-astra, subagent model set to
relay/gpt-6.1-terra, "Codex subagents on any model" on. A new session's
subagents still ran on Astra, and Routing said the task was sealed and
only a ChatGPT account could read it. The model's catalog entry still
said multi_agent_version "v2".

Cause: the setting (settings.CodexAgentsV1) stamped V1 only on the
ChatGPT account's own models (codex/) and the groups one is in (Fast).
The relay lists Codex's own entry for gpt-6-astra (a sub2api asked with
Codex's client_version), "v2" included, and a relay offering Ultra is
given "v2" (AgentsV2) besides. In V2 Codex hands the lead the
collaboration namespace (spawn_agent etc.), whose arguments a relay of
the ChatGPT backend seals as the backend does (#1109), so
codexSubagentPick kept the subagent on the lead's model (sealedKept).

Fix: catalog.Model.Seals (provider.CodexSeals) marks a model whose
provider is of no sign-in on the Responses API, as the gateway's
canSeal, or a group with such a member. With the setting on, its entry
says V1 like the ChatGPT account's, listed by its relay or made by
magpie, so the task goes as text and the model set for subagents takes
it. Seals is in the list's tag, so Codex asks for the list again. A
model of an account that seals nothing (Copilot's Ultra, #656) keeps
V2, and with the setting off every entry is as before. No prompt text
or instructions change.

Real Codex (0.165.0, sandbox HOME/CODEX_HOME, fake Responses server,
model_catalog_json with the user's gpt-6-astra entry as
relay/gpt-6-astra): with "v2" the first request carries the
collaboration namespace (spawn_agent, send_message, followup_task,
wait_agent, ...); with "v1" it has none.

Run (Linux box via wsl-run; mote refused SSH for the whole session):
- go vet -tags nogui (linux), GOOS=windows go vet, GOOS=darwin
  CGO_ENABLED=0 go vet -tags nogui on codexcat, provider, agent,
  catalog, settings: ok; gofmt -l clean
- go test -tags nogui -count=1 ./internal/codexcat ./internal/catalog
  ./internal/settings ./internal/provider: ok
- ./internal/agent, and -run 'Codex|Ultra|Subagent|Sealed|Collab|AgentsV1'
  ./internal/gateway, were still running when this was pushed; their
  results go on the release's issue thread if red
- at the pushed head (rebased on c2c2c82ca), Windows box: go vet on the
  five packages, and -run 'CodexSeals|CodexAgentsV1|Ultra' codexcat and
  provider: ok
- earlier on mote: -run 'CodexSeals|CodexAgentsV1|Ultra|CodexListed|Listed'
  ./internal/codexcat ./internal/provider: ok

Broken by hand: dropping m.Seals from both V1 conditions in codexcat
makes TestCodexAgentsV1SealingRelay red ("on: map[... relay/gpt-6-astra:v2]");
CodexSeals setting false makes TestCodexSeals red ("relay/gpt-6-astra:
Seals false, want true").

Tests: TestCodexAgentsV1SealingRelay (a relay's listed v2 entry and a
made Ultra entry say v1 with the setting, Copilot's keeps v2, all as
before with it off), TestCodexSeals.

Not tried: a real relay of the ChatGPT backend end to end with a real
subagent spawn; Codex 0.165 exec showed no V1 spawn tools in its first
request (they are deferred), so the V1 side was checked by the
collaboration namespace being gone. No GUI is reachable from this
change. A thread started before keeps the version it started with; a
new session is needed.
2026-11-10 21:05:34 +08:00

39 lines
1.5 KiB
Go

package provider
import (
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// A model seals a V2 lead's subagent tasks when its provider is of no
// sign-in on the Responses API (a relay of the ChatGPT backend, #1109), or
// a group has such a member; a chat-only key and another account
// (Copilot) seal none (brethhbbm on X).
func TestCodexSeals(t *testing.T) {
relay := Provider{ID: "relay", Chat: "https://relay.example/v1", Responses: "https://relay.example/v1"}
chat := Provider{ID: "ds", Chat: "https://api.deepseek.example/v1"}
copilot := Provider{ID: "copilot", Responses: "https://api.githubcopilot.example", Account: &Account{Agent: "copilot"}}
members := map[string][]Member{
"group/mixed": {{Provider: chat, Model: "deepseek-v4"}, {Provider: relay, Model: "gpt-6-astra"}},
"group/plain": {{Provider: chat, Model: "deepseek-v4"}, {Provider: copilot, Model: "gpt-6.1-sol"}},
}
of := func(id string) []Member { return members[id] }
for _, c := range []struct {
e Entry
want bool
}{
{Entry{ID: "relay/gpt-6-astra", Provider: relay, Model: "gpt-6-astra"}, true},
{Entry{ID: "ds/deepseek-v4", Provider: chat, Model: "deepseek-v4"}, false},
{Entry{ID: "copilot/gpt-6.1-sol", Provider: copilot, Model: "gpt-6.1-sol"}, false},
{Entry{ID: "group/mixed", Group: "mixed"}, true},
{Entry{ID: "group/plain", Group: "plain"}, false},
} {
var m catalog.Model
CodexSeals(&m, c.e, of)
if m.Seals != c.want {
t.Errorf("%s: Seals %v, want %v", c.e.ID, m.Seals, c.want)
}
}
}