diff --git a/internal/gateway/prompt.go b/internal/gateway/prompt.go index 50854569c..3a2069fcd 100644 --- a/internal/gateway/prompt.go +++ b/internal/gateway/prompt.go @@ -725,6 +725,7 @@ var ( injected = []string{ "", "", "", "", "", "", "", "", "", "Available agent types for the Agent tool:", "Available agent types and the tools they have access to:", "New agent types are now available for the Agent tool:", diff --git a/internal/gateway/user_said_test.go b/internal/gateway/user_said_test.go index a676e4454..39c4e7ca6 100644 --- a/internal/gateway/user_said_test.go +++ b/internal/gateway/user_said_test.go @@ -30,6 +30,9 @@ const ( envContext = "\n /Users/me/app\n zsh\n 2026-10-12\n" codexAgents = "# AGENTS.md instructions for /Users/me/app\n\n\nRun the tests.\n" inAppBrowser = "# Context from my IDE setup:\n\n# In app browser:\n\nhttps://example.test/ — Example\n\n\n" + codexPage = `{"page_id":null}` + pastedRequest = "# Files pasted by the user:\n\n## \"Fix a race...\": /tmp/fixture/task.txt\n\n" + + "Pasted text contains the user's request.\n\n## My request:\n" ) func userMsg(texts ...string) Message { @@ -107,6 +110,9 @@ func TestUserTextSkipsWhatTheAgentPutIn(t *testing.T) { {"a todo nudge after the turn", []Message{userMsg(q), saidAnswer, userMsg(zcodeTodo)}, q}, {"Codex", []Message{userMsg(codexAgents, envContext, "fix the bug")}, "fix the bug"}, {"the Codex app", []Message{userMsg(inAppBrowser + "## My request for Codex:\nwhat is this page?")}, "what is this page?"}, + {"the Codex app's page state", []Message{userMsg(codexPage)}, ""}, + {"page state, pasted files and an empty request", []Message{userMsg(codexPage), userMsg(pastedRequest)}, ""}, + {"page state beside the request", []Message{userMsg(codexPage, pastedRequest+"fix the race")}, "fix the race"}, {"a reminder with a source", []Message{userMsg(goalContinuation + "\nship it")}, "ship it"}, } { if got := userText(&Request{Messages: tc.ms}); got != tc.want { @@ -176,9 +182,24 @@ func TestIntentHoldsPastWhatTheAgentPutIn(t *testing.T) { } } +// The Codex app's page state is not words of the user's: alone, or beside +// pasted files when "My request" is empty, it asks the classifier nothing +// (#3418) — there is nothing of the user's to classify. +func TestIntentSkipsWhatTheCodexAppPutIn(t *testing.T) { + s, _, _, c := intented(t, provider.Rule{Use: "b/big", Intent: "complex tasks"}) + c.set("1", 0) + body := `{"model":"group/r","messages":[` + + `{"role":"user","content":` + quote(codexPage) + `},` + + `{"role":"user","content":` + quote(pastedRequest) + `}]}` + _, r := postOK(t, s, "s1", body) + if n := c.n(); n != 0 { + t.Fatalf("classifier asked %d time(s): %.120q (%+v)", n, c.last(), r.Rule.Classified) + } +} + func TestUserSaysPastAReminderWithASource(t *testing.T) { for _, s := range []string{goalContinuation, taskNotification, pluginRef, agentList, zcodeAgentList, zcodeTodo, envContext, codexAgents, - "\nThe user interrupted.\n", inAppBrowser + "## My request:\n"} { + "\nThe user interrupted.\n", inAppBrowser + "## My request:\n", codexPage} { if userSays(s) { t.Errorf("said: %.40q", s) }