agy-cli 0.1.21: text that names a notice tag it never closes is routed by who wrote it, not refused (PolarizingLight on X)

A tool turn answered with text beside the result that merely mentions a
notice tag it does not close ("<system-reminder", "<channel") threw "text
beside a live tool_result; send it after the tool response completes". In
a long Codex thread (ChatGPT desktop) that text comes from a developer
message magpie wraps in <system-reminder> whose own text quotes a reminder
tag (the wrapper then leaves a stray close tag), a hook's context, or the
user typing the tag. Now: a wrapped developer or system message is a
notice (broken up with cloak), a user's text steers and is replayed whole,
other roles ride as a notice. A notice that opens and is cut short
("<system-update>not a complete...") is still turned away.

Not found: a real failing request. magpie's logs on this Mac hold none, and
Codex's rollouts here hold no tag of this kind after a tool output, so the
exact bytes the reporter's thread carries are inferred, not seen.

Run: test/compat.mjs (new case red on 0.1.20, green now), agy-cli.test.mjs
whole on mote (12 pass). Broken by hand: old index.mjs makes the new case
fail. Not tried: a real ChatGPT desktop thread against agy-cli.
This commit is contained in:
yetone
2026-11-12 07:07:29 +08:00
parent 01eaa6dda4
commit 52e31c4a1f
3 changed files with 50 additions and 3 deletions
+23 -2
View File
@@ -4027,7 +4027,26 @@ function inspectToolTurn(results, body) {
}
const rest = withoutNotices.replace(SYSTEM_REMINDER_RE, "").trim()
if (UNCLOSED_NOTICE_RE.test(rest)) {
throw new UnsupportedContent("text beside a live tool_result; send it after the tool response completes")
// Text that merely names a notice tag it does not close (a developer
// message that quotes <system-reminder>, a user typing one, a hook's
// context) is routed by who wrote it, never refused and never dropped.
// A notice that opens and is cut short is still turned away.
const wrapped = /^<system-reminder(?:\s[^>]*)?>\s*([\s\S]*?)\s*<\/system-reminder>$/.exec(trimmed)
if (!wrapped && PROTOCOL_NOTICE_START_RE.test(rest)) {
// a protocol notice that starts and is cut short: not a mention
throw new UnsupportedContent("text beside a live tool_result; send it after the tool response completes")
}
if (wrapped || message.role === "system" || message.role === "developer") {
// the gateway's wrapper for a developer message, or a system one
const inner = wrapped ? wrapped[1] : rest
if (extractQueuedPrompt(inner) !== null || userInterruption.test(inner)) userSteered = true
else if (!isNoise(inner)) notices.push(cloak(inner))
} else if (message.role === "user") {
userSteered = true
} else if (!isNoise(rest)) {
notices.push(cloak(rest))
}
continue
}
if (message.role === "system" || message.role === "developer") {
if (extractQueuedPrompt(rest) !== null || userInterruption.test(rest)) {
@@ -4042,7 +4061,9 @@ function inspectToolTurn(results, body) {
notices.some((item) => hookStoppedContinuation.test(item))) {
userSteered = true
} else {
throw new UnsupportedContent("text beside a live tool_result; send it after the tool response completes")
// text from neither the user nor the system (an assistant message
// that landed after the result): the model is told it, as a notice
notices.push(cloak(rest))
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.20",
"version": "0.1.21",
"description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI",
"type": "module",
"main": "./opencode.mjs",
+26
View File
@@ -246,3 +246,29 @@ test("execOnce still collects synchronous and asynchronous spawn failures", asyn
}, mode)
}
})
test("text that names a notice tag it never closes is routed by its writer, not refused", () => {
const call = result("call_shell", "shell", "done")
const wrap = text => ({ type: "text", text: `<system-reminder>\n${text}\n</system-reminder>` })
// the gateway wraps a Codex developer message, which here quotes a reminder tag
const developer = wrap("Hook context: output is wrapped in <system-reminder> blocks.")
const nested = wrap("<system-reminder>earlier note</system-reminder> and more")
for (const block of [developer, nested]) {
const inspected = inspectToolTurn([call], bodyFor([call.block, block]))
assert.equal(inspected.userSteered, false, "a developer message is not the user steering")
const text = inspected.results[0].result.content.map(part => part.text || "").join("\n")
assert.ok(text.includes("earlier note") || text.includes("Hook context"), "the developer text reaches the model")
}
// a user typing the tag name steers, and the replay carries the words
const typed = { type: "text", text: "why does the <system-reminder tag show up in my chat?" }
for (const blocks of [[call.block, typed], [typed, call.block]]) {
const body = bodyFor(blocks)
const inspected = inspectToolTurn([call], body)
assert.equal(inspected.userSteered, true)
assert.deepEqual(inspected.results[0].result.content, call.result.content)
const replay = renderInitialPromptParts(body, null, true).map(part => part.text || "").join("")
assert.ok(replay.includes("why does the"), "the user's words are replayed")
}
// a notice that opens and is cut short is still turned away
assert.throws(() => inspectToolTurn([call], bodyFor([call.block, { type: "text", text: "<system-update>cut short" }])), /text beside a live tool_result/)
})