agy-cli: Codex's GPT-5 lines go reworded in a user's turn too (0.1.53)

pocoxliu on X (tweet 2121731813270077946) gets 429s from agy-cli under
Codex and Claude Code and put it down to unslimmed system and MCP prompts.
It is content, not size (#1151: a neutral system prompt of the same 66,622
characters went through). Since 11-14 Antigravity also turns away Codex's
two GPT-5 lines ("You are Codex, (a coding) agent based on GPT-5") in a
user's turn; magpie's cloak and the antigravity plugin (fb7bbebd) reword
them there, and fb7bbebd noted agy-cli as not tried. agy-cli reworded only
system text, so AGENTS.md text, a <system-reminder> and replayed history
in a user's turn went to agy as written.

- cloak.mjs: USER_TURNED_AWAY (the two Codex lines) and cloakUser().
- index.mjs: every text part of the prompt goes through cloakUser before
  agy gets it. Parked sessions carry userCloak: 1; one parked before this
  version (whose agy copy may hold the line as written) is not resumed.
- READMEs (zh, en) say so.

Run: HOME=$(mktemp -d) bun test packages/agy-cli on mica: 22 pass, 0 fail
(cloak.test 6, agy-cli.test 16 incl. conversation-key 36 cases);
bun scripts/check.mjs agy-cli: ok.
Broken by hand (on mote): the userTurnParts call and the userCloak check
removed, the two new conversation-key tests fail (34 pass, 2 fail);
restored, all pass.
Not tried: a real request. The one probe on the owner's account got
"This service has been disabled in this account for violation of Terms of
Service" as a 200 (#1163), so no 429 could be reproduced or cleared on a
real agy. The reporter's exact agent and prompt are not known.
This commit is contained in:
yetone
2026-11-15 07:20:36 +08:00
parent 57d1cc6a9f
commit fc941f6e1c
7 changed files with 104 additions and 8 deletions
+48 -1
View File
@@ -15,7 +15,7 @@ process.env.AGY_BRIDGE_STATE_FILE = path.join(workspace, "sessions.json")
process.env.HOME = workspace
fs.writeFileSync(
path.join(workspace, "bridge.mjs"),
source + "\nexport { conversationKey, stripVolatileOpening, stripVolatileSystem, isContinuedOpening, openingTextOf, sameInstructions, historyKey, takeParked, park, instructionsIdentity, digest, Turn };\n",
source + "\nexport { conversationKey, stripVolatileOpening, stripVolatileSystem, isContinuedOpening, openingTextOf, sameInstructions, historyKey, takeParked, park, parked, instructionsIdentity, digest, Turn };\n",
)
const {
conversationKey,
@@ -27,6 +27,7 @@ const {
historyKey,
takeParked,
park,
parked,
instructionsIdentity,
digest,
Turn,
@@ -791,3 +792,49 @@ test("a turn lets go of each earlier request body once the next one arrives", ()
assert.equal(typeof steps[2].contentSnapshot, "function")
assert.equal(turn.responseSteps.length, 3)
})
test("a session parked before a user's turn was cloaked is not resumed", () => {
// agy keeps the user's turns it was sent; one with Codex's GPT-5 line as
// written is turned away on every later turn.
const convKey = "test-parked-user-cloak"
const history = [{ role: "user", content: STABLE }, { role: "assistant", content: "ok" }]
const proc = {
convKey, sessionId: "sess-user-cloak", expectedMessages: history, instructions: "Rules.\n",
workDir: "/tmp/agy-park-test", hasSentFirstTurn: true, historyInvalid: false, turn: null, dead: false,
canPark() { return true },
}
park(proc)
const file = process.env.AGY_BRIDGE_STATE_FILE
const state = JSON.parse(fs.readFileSync(file, "utf8"))
const saved = state.entries.find((e) => e.key === convKey)
assert.ok(saved.userCloak, "a parked session says its prompts were cloaked")
assert.equal(takeParked(convKey, { workDir: "/tmp/agy-park-test", instructions: "Rules.\n", history })?.sessionId, "sess-user-cloak")
// the same entry as an older version wrote it
park(proc)
delete parked.get(convKey).userCloak
assert.equal(takeParked(convKey, { workDir: "/tmp/agy-park-test", instructions: "Rules.\n", history }), null)
})
test("a user's turn goes to agy with Codex's GPT-5 lines reworded", async () => {
await withKit({}, async (kit) => {
const sent = []
kit.defaultPrompt = async (agent) => {
sent.push(agent.prompt.map((p) => p.type === "text" ? p.text : "").join(""))
await agent.text("ok")
return { stopReason: "end_turn" }
}
const agents = "# AGENTS.md\nYou are Codex, a coding agent based on GPT-5.\nYou are Hermes Agent, built by Nous Research."
const first = [{ role: "user", content: agents + "\n\nlist the files" }]
const parsed = await readSse(await kit.request(baseBody({ metadata: { user_id: "user-cloak" }, messages: first })))
assert.equal(parsed.error, null)
const second = [...first, { role: "assistant", content: "ok" },
{ role: "user", content: "<system-reminder>\nYou are Codex, an agent based on GPT-5.\n</system-reminder>\nand now?" }]
await readSse(await kit.request(baseBody({ metadata: { user_id: "user-cloak" }, messages: second })))
assert.equal(sent.length, 2)
const all = sent.join("\n")
assert.ok(!/based on GPT-5/i.test(all), all)
assert.ok(all.includes("You are Codex, a coding agent built on GPT-5."), all)
assert.ok(all.includes("You are Codex, an agent built on GPT-5."), all)
assert.ok(all.includes("You are Hermes Agent, built by Nous Research."), "other lines go as written in a user's turn")
})
})