gateway: a Codex subagent sealed to ChatGPT's backend says to turn on Settings › Codex subagents on any model, or to start a new thread when it is on (#2245, qikairo7)

TestSealedTaskNamesSubagentsOnAnyModel.

Run at this head (on 6485056e1, with the #2245/#2246/#2247 fixes together): gofmt -l clean; go vet ./... for darwin and windows, and linux -tags nogui; the full go test ./... in a sandbox HOME, all green. The new test fails on the old code and passes with the fix.
This commit is contained in:
yetone
2026-10-15 04:46:57 +08:00
parent 91c4705e39
commit 8d2a4a7da3
2 changed files with 73 additions and 3 deletions
+17 -3
View File
@@ -22,6 +22,7 @@ import (
"github.com/yetone/magpie/internal/catalog"
"github.com/yetone/magpie/internal/codexcat"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/settings"
"github.com/yetone/magpie/internal/usage"
)
@@ -206,12 +207,25 @@ func (s *Server) codexBackend(w http.ResponseWriter, r *http.Request) {
// itself, which fork_turns="none" doesn't change (#1855).
func sealedTaskError(model, lead, earlier string) string {
if earlier != "" {
return fmt.Sprintf("This subagent's task was sealed by the ChatGPT backend, which answered the agent that sent it on one of Codex's own models (a subagent of this thread put there, or the lead after a switch), and only a ChatGPT account can open it. %s can't. %s answered the lead's earlier turns, but it neither seals a task nor opens one. "+sealedTaskItself+" Set Codex's subagent model on magpie's Agents page to a model of a ChatGPT account added in magpie, or to one that isn't served by the ChatGPT backend, so subagents get tasks they can read. To go on with this task, have it spawned again from an agent that isn't on Codex's own models.", model, earlier)
return fmt.Sprintf("This subagent's task was sealed by the ChatGPT backend, which answered the agent that sent it on one of Codex's own models (a subagent of this thread put there, or the lead after a switch), and only a ChatGPT account can open it. %s can't. %s answered the lead's earlier turns, but it neither seals a task nor opens one. "+sealedTaskItself+" Set Codex's subagent model on magpie's Agents page to a model of a ChatGPT account added in magpie, or to one that isn't served by the ChatGPT backend, so subagents get tasks they can read. To go on with this task, have it spawned again from an agent that isn't on Codex's own models."+sealedWayOut(), model, earlier)
}
if lead != "" {
return fmt.Sprintf("This subagent's task was sealed by the server that answered its lead (%s), and only that server can open it; %s can't. "+sealedTaskItself+" Give the subagent the lead's model, or a lead model that isn't served by the ChatGPT backend, so its subagents get a task they can read. To go on with this task, use a model on %s for the lead and the subagent, or have the lead spawn the subagent again.", lead, model, lead)
return fmt.Sprintf("This subagent's task was sealed by the server that answered its lead (%s), and only that server can open it; %s can't. "+sealedTaskItself+" Give the subagent the lead's model, or a lead model that isn't served by the ChatGPT backend, so its subagents get a task they can read. To go on with this task, use a model on %s for the lead and the subagent, or have the lead spawn the subagent again."+sealedWayOut(), lead, model, lead)
}
return fmt.Sprintf("This subagent's task was sealed by the ChatGPT backend that answered its lead, and only that backend can open it: a ChatGPT account, or the Responses API provider that answered the lead. %s is neither: magpie has no record of it answering the lead in the last 30 days. "+sealedTaskItself+" Give the subagent the lead's model, or a lead model that isn't served by the ChatGPT backend, so its subagents get a task they can read. To go on with this task, use the lead's model, or have the lead spawn the subagent again.", model)
return fmt.Sprintf("This subagent's task was sealed by the ChatGPT backend that answered its lead, and only that backend can open it: a ChatGPT account, or the Responses API provider that answered the lead. %s is neither: magpie has no record of it answering the lead in the last 30 days. "+sealedTaskItself+" Give the subagent the lead's model, or a lead model that isn't served by the ChatGPT backend, so its subagents get a task they can read. To go on with this task, use the lead's model, or have the lead spawn the subagent again."+sealedWayOut(), model)
}
// sealedWayOut is the way to subagents on any model from a lead on
// Codex's own models (#2245): Settings' "Codex subagents on any model"
// (settings.CodexAgentsV1, #141) has the lead hand its subagents their
// tasks as text. Off, the refusal names it; on, a thread still sealing
// its tasks is on V2 all the same: begun before it was on, or held there
// by Codex's own features.multi_agent_v2.
func sealedWayOut() string {
if settings.Load().CodexAgentsV1 {
return ` "Codex subagents on any model" is on in magpie's Settings, but this thread runs Codex's multi-agent V2, whose tasks are sealed: it began before the setting was turned on, or Codex's own features.multi_agent_v2 is on in its config. Start a new thread, with features.multi_agent_v2 off.`
}
return ` For subagents on any model while the lead is on a ChatGPT model, turn on "Codex subagents on any model" in magpie's Settings and start a new thread: the lead then hands its subagents their tasks as text.`
}
// sealedTaskItself says what a sealed task is (#1855): spawn_agent's
+56
View File
@@ -7,6 +7,8 @@ import (
"net/http/httptest"
"strings"
"testing"
"github.com/yetone/magpie/internal/settings"
)
// forkNoneTask is the first request Codex 0.162 (rust-v0.162.0-alpha.17.2)
@@ -69,3 +71,57 @@ func TestSealedTaskWithForkTurnsNoneSaysTheTaskItselfIsSealed(t *testing.T) {
t.Fatalf("the refusal doesn't say the task itself is sealed whatever fork_turns says: %s", msg)
}
}
// #2245 (qikairo7): a lead on gpt-6.1-sol, a ChatGPT account, spawns a
// subagent on a group of DeepSeek only. The subagent is turned away as
// before, and the refusal now names the way to subagents on any model:
// Settings' "Codex subagents on any model" (#141), which has the lead
// hand its tasks on as text. With it on, a thread still sealing its tasks
// is told why: begun before it, or Codex's own multi_agent_v2.
func TestSealedTaskNamesSubagentsOnAnyModel(t *testing.T) {
fresh(t)
chatgpt(t, func(w http.ResponseWriter, r *http.Request) {
io.ReadAll(r.Body)
w.Header().Set("Content-Type", "text/event-stream")
io.WriteString(w, sse(`data: {"type":"response.completed","response":{"id":"r1","status":"completed","output":[]}}`))
})
asked := chatOnlyOn(t, "ag")
s := New()
if rec := codexSubTurn(s, "gpt-6.1-sol", "lead-2245", "", leadAsk); rec.Code != 200 {
t.Fatalf("lead on a ChatGPT model: %d %s", rec.Code, rec.Body.String())
}
refusal := func() string {
t.Helper()
body := strings.ReplaceAll(forkNoneTask, "ag/gemini-3.8-flash", "ag/dfmodel")
req := httptest.NewRequest("POST", CodexPath+"/responses", strings.NewReader(body))
req.Header.Set("Authorization", "Bearer chatgpt-token")
req.Header.Set("chatgpt-account-id", "acct-1")
req.Header.Set("User-Agent", "Codex Desktop/0.162.0-alpha.17.2 (Windows 10.0.26300; x86_64) unknown (Codex Desktop; 26.1007.71326)")
req.Header.Set("session_id", "worker-2245")
req.Header.Set("x-codex-parent-thread-id", "lead-2245")
req.Header.Set("x-openai-subagent", "collab_spawn")
rec := httptest.NewRecorder()
s.Handler().ServeHTTP(rec, req)
var got struct {
Error struct {
Message string `json:"message"`
} `json:"error"`
}
json.Unmarshal(rec.Body.Bytes(), &got)
if rec.Code != 400 || *asked != 0 {
t.Fatalf("subagent: %d %s (ag asked %d times)", rec.Code, rec.Body.String(), *asked)
}
return got.Error.Message
}
if msg := refusal(); !strings.Contains(msg, `turn on "Codex subagents on any model" in magpie's Settings and start a new thread`) {
t.Fatalf("the refusal doesn't name the setting: %s", msg)
}
st := settings.Load()
st.CodexAgentsV1 = true
if err := settings.Save(st); err != nil {
t.Fatal(err)
}
if msg := refusal(); !strings.Contains(msg, `"Codex subagents on any model" is on`) || !strings.Contains(msg, "features.multi_agent_v2") || strings.Contains(msg, "turn on") {
t.Fatalf("with the setting on, the refusal doesn't say why the thread is still sealed: %s", msg)
}
}