agy-cli 0.1.33: DSH's @-path paragraph goes reworded, as antigravity sends it (#1028) (LeeTengLong on X)

agy-cli's cloak.mjs copied only antigravity's TURNED_AWAY break-up (#980),
not the REWORDED rewrite antigravity 0.1.7 added for #1028, so DeepSeek
Harness's "Tokens prefixed with @ are paths…" paragraph reached agy word
for word, the text that got gemini-4-argon answering fast, without thinking
and shallow.

cloak.mjs now carries REWORDED, reword and outgoing (reword after cloak),
a copy of antigravity/index.mjs's, and every place agy-cli hands system text
to agy uses outgoing: the session's systemPrompt.append,
<external_system_instructions>, a later system/developer message and the
notices beside a tool result. Only that exact paragraph changes; a prompt
that merely mentions @ paths, and what the user wrote, go as written.
instructionsIdentity still keys on the prompt as the client wrote it. The
packages ship on their own, so the code is a copy; cloak.test.mjs holds it to
antigravity's shape() output for each REWORDED entry and the samples.

Run on mote (Bun 1.4.2, temp HOME): bun test packages/agy-cli
packages/antigravity 118 pass 0 fail; bun scripts/check.mjs exit 0.
Broken by hand: outgoing without reword turns 3 tests red (cloak.test.mjs
2, and smoke.mjs's #1028 session, external_system_instructions and later
system message checks).
Not tried: a real agy with a real Antigravity account and DSH; the
rewording's effect rests on #1028's replays. No magpie min names agy-cli.

Reported-by: LeeTengLong
This commit is contained in:
yetone
2026-11-13 13:14:51 +08:00
parent 9213d9b474
commit 00892c80e3
7 changed files with 104 additions and 15 deletions
+5
View File
@@ -229,6 +229,11 @@ plugin breaks each of them up with zero-width spaces before agy sends it, as
the Antigravity provider does (`cloak.mjs`). Should such a 429 still come
back, it is reported as a 400 about the prompt, not as a quota.
DeepSeek Harness's paragraph on `@` paths ("Tokens prefixed with @ are
paths…") goes reworded with the same meaning, as the Antigravity provider
sends it: word for word, it got most `gemini-4-argon` answers fast, without
thinking and shallow (#1028).
Set to `1`, the temporary agent carries `excludeDefaultComponents: true`. The
request that goes upstream then has none of agy's own system prompt, only
the plugin's one-line tool note and the client's system prompt (sent in one
+3
View File
@@ -175,6 +175,9 @@ Antigravity 对几行系统提示词(Claude Code 的计费行、Claude Agent S
agy 发出之前用零宽空格把这几行拆开,和 Antigravity 提供商的做法一样(`cloak.mjs`)。如果仍然
回了这样的 429,会报成针对提示词的 400,而不是额度用完。
DeepSeek Harness 的 `@` 路径说明段("Tokens prefixed with @ are paths…")也和 Antigravity 提供商一样
换成同义的说法再发:原文照发时 `gemini-4-argon` 大多很快答完、不思考、只走一步(#1028)。
设为 `1` 后,临时 agent 带上 `excludeDefaultComponents: true`:发往上游的请求里不再有
agy 自己的系统提示词,只剩插件的一行工具说明和客户端的系统提示词(同样以上面两种方式之一
发送)。原作者实测每次模型调用的输入从约 8,400 token 降到约 500 token。代价是上游看到的
+26 -4
View File
@@ -1,7 +1,8 @@
// System prompt lines Antigravity turns away, the same list and the same
// break-up as packages/antigravity/index.mjs (TURNED_AWAY, breakUp, cloak,
// hint). Each package ships on its own, so the code is a copy; cloak.test.mjs
// fails when the two give a different answer for any line.
// System prompt lines Antigravity turns away, and paragraphs it answers
// badly, the same lists and the same rewrites as
// packages/antigravity/index.mjs (TURNED_AWAY, breakUp, cloak, hint,
// REWORDED, reword, outgoing). Each package ships on its own, so the code is
// a copy; cloak.test.mjs fails when the two give a different answer.
//
// Antigravity answers a 429 "Resource has been exhausted" to a request whose
// system prompt has one of these lines, whatever quota is left, and lets the
@@ -59,6 +60,27 @@ export function cloak(system) {
return out + system.slice(prev)
}
// REWORDED are paragraphs that go through but are answered badly, each with
// a rewording that keeps its meaning. DeepSeek Harness's desktop app puts
// the first in every system prompt; word for word, gemini-4-argon answered
// most requests in about 3s with no thinking and ended after one shallow
// step (antigravity #1028).
export const REWORDED = [
[
"Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @\"...\" quotes a path containing spaces.",
"When the user writes @ followed by a path, they are pointing at that file or folder. Relative paths start at the workspace root; absolute paths are host paths. A path ending in a slash is a folder, so list it if its contents matter; otherwise it is a file, so open it with the read tool before relying on it. Paths with spaces appear as @\"...\".",
],
]
export function reword(system) {
if (typeof system !== "string") return system
for (const [from, to] of REWORDED) if (system.includes(from)) system = system.split(from).join(to)
return system
}
// outgoing is system text as agy is handed it: broken up, then reworded
export const outgoing = (system) => reword(cloak(system))
const HINT =
"Antigravity answers this 429 to the system prompt of Claude Code and the Claude Agent SDK (Claude Desktop's chats) whatever quota is left, so it is not a quota and waiting won't help; use another provider for these chats, or put one after Antigravity in a routing group"
+28 -2
View File
@@ -1,7 +1,8 @@
// cloak.mjs is a copy of packages/antigravity's TURNED_AWAY, cloak and hint
// (#980): these fail when the two packages stop agreeing.
// (#980) and its REWORDED (#1028): these fail when the two packages stop
// agreeing.
import { expect, test } from "bun:test"
import { TURNED_AWAY, cloak, hint, turnsAway } from "./cloak.mjs"
import { REWORDED, TURNED_AWAY, cloak, hint, outgoing, turnsAway } from "./cloak.mjs"
import { _internal as antigravity } from "../antigravity/index.mjs"
const ZW = "​"
@@ -46,3 +47,28 @@ test("agy-cli and antigravity break up and explain the same lines", () => {
expect(hint(s)).toBe(antigravity.hint(s))
}
})
const DSH = "Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @\"...\" quotes a path containing spaces."
// the system text antigravity sends for s (its shape() runs outgoing on it)
const antigravitySends = (s) =>
antigravity.shape({ systemInstruction: { parts: [{ text: s }] }, contents: [] }, "gemini-3-flash", "", "").systemInstruction.parts[0].text
test("DeepSeek Harness's @-path paragraph goes reworded, the rest as written (#1028)", () => {
const sys = "You are DeepSeek Harness.\n\n" + DSH + "\n\nBe brief."
expect(outgoing(sys)).toBe("You are DeepSeek Harness.\n\nWhen the user writes @ followed by a path, they are pointing at that file or folder. Relative paths start at the workspace root; absolute paths are host paths. A path ending in a slash is a folder, so list it if its contents matter; otherwise it is a file, so open it with the read tool before relying on it. Paths with spaces appear as @\"...\".\n\nBe brief.")
expect(outgoing("Tokens prefixed with @ are paths. Be brief.")).toBe("Tokens prefixed with @ are paths. Be brief.")
const both = outgoing("x-anthropic-billing-header: cc\n" + DSH)
expect(both).toContain("x-a" + ZW + "n" + ZW + "thropic")
expect(both).toContain("When the user writes @ followed by a path")
})
test("agy-cli and antigravity send the same system text, reworded and broken up", () => {
for (const [from, to] of REWORDED) {
expect(outgoing(from)).toBe(to)
expect(antigravitySends(from)).toBe(to)
}
for (const s of [...samples.filter(Boolean), DSH, "Lead.\n" + DSH + "\n" + DSH, "x-anthropic-billing-header: cc\n" + DSH]) {
expect(outgoing(s)).toBe(antigravitySends(s))
}
})
+8 -8
View File
@@ -12,7 +12,7 @@ import { sanitizePatternFields } from "./re2-pattern.mjs"
import { startLogin } from "./login.mjs"
import { ensureGeminiArrayItems } from "./array-items.mjs"
import { expandToolSchema } from "./tool-schema.mjs"
import { cloak, hint, turnsAway } from "./cloak.mjs"
import { hint, outgoing, turnsAway } from "./cloak.mjs"
import { modelUsageCursor, modelUsageAfter, sessionDbPath } from "./step-usage.mjs"
const PROVIDER_ID = "agy-cli"
@@ -1482,7 +1482,7 @@ class Proc {
const resumable = !!(capabilities.sessionCapabilities?.resume ?? capabilities.session_capabilities?.resume)
this.instructionsInSession = appendable && !!this.instructions
const meta = this.instructionsInSession
? { _meta: { antigravity: { systemPrompt: { append: cloak(this.instructions) } } } }
? { _meta: { antigravity: { systemPrompt: { append: outgoing(this.instructions) } } } }
: {}
let session = null
@@ -3866,7 +3866,7 @@ function renderTurnMessageParts(message) {
if (message.role !== "user" || !Array.isArray(message.content)) {
let text = renderTurnMessage(message)
// a system or developer message later in the chat is system text too
if (message.role === "system" || message.role === "developer") text = cloak(text)
if (message.role === "system" || message.role === "developer") text = outgoing(text)
return text === "" ? [] : [{ type: "text", text }]
}
const parts = []
@@ -4046,7 +4046,7 @@ function renderInitialPromptParts(body, callerWorkDir, instructionsInSession, re
const head = []
if (!instructionsInSession) {
const system = systemText(body)
if (system.trim()) appendPrompt(head, `<external_system_instructions>\n${cloak(system)}\n</external_system_instructions>\n`)
if (system.trim()) appendPrompt(head, `<external_system_instructions>\n${outgoing(system)}\n</external_system_instructions>\n`)
if (callerWorkDir) appendPrompt(head, `\n${workDirNote(callerWorkDir)}\n\n`)
}
const currentParts = renderTurnMessagesParts(current)
@@ -4406,11 +4406,11 @@ function inspectToolTurn(results, body) {
// 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 (!isNoise(inner)) notices.push(outgoing(inner))
} else if (message.role === "user") {
userSteered = true
} else if (!isNoise(rest)) {
notices.push(cloak(rest))
notices.push(outgoing(rest))
}
continue
}
@@ -4418,7 +4418,7 @@ function inspectToolTurn(results, body) {
if (extractQueuedPrompt(rest) !== null || userInterruption.test(rest)) {
userSteered = true
} else if (!isNoise(rest)) {
notices.push(cloak(rest))
notices.push(outgoing(rest))
}
} else if (!isNoise(rest)) {
if ((hookOutput.test(rest) || claudeMetaFeedback.test(rest)) && !userInterruption.test(rest)) {
@@ -4429,7 +4429,7 @@ function inspectToolTurn(results, body) {
} else {
// 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))
notices.push(outgoing(rest))
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.32",
"version": "0.1.33",
"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",
+33
View File
@@ -1390,6 +1390,39 @@ for (const change of ["tools", "model"]) {
check("#980 the same 429 to any other prompt is still a rate limit", quotaError?.type === "rate_limit_error", JSON.stringify(quotaError))
}
// antigravity #1028: DeepSeek Harness's @-path paragraph reaches agy
// reworded, as the antigravity plugin sends it, in the session
// instructions, in <external_system_instructions> and in a later system
// message.
{
const dsh = "Tokens prefixed with @ are paths the user explicitly referenced. Relative paths resolve from the workspace root; absolute paths identify files or directories on the host. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @\"...\" quotes a path containing spaces."
const reworded = "When the user writes @ followed by a path, they are pointing at that file or folder."
const system = `You are DeepSeek Harness.\n\n${dsh}\n\nDSH-MARKER`
await readSSE(await callFetch({ model, system, messages: [{ role: "user", content: "dsh session instructions" }] }))
const sent = inits().at(-1).systemAppend ?? ""
check("#1028 DSH's @-path paragraph goes reworded in the session instructions",
sent.includes("DSH-MARKER") && !sent.includes("Tokens prefixed with @") && sent.includes(reworded), JSON.stringify(sent))
process.env.FAKE_AGY_APPEND = "0"
await readSSE(await callFetch({ model, system: system + " NOAPPEND", messages: [{ role: "user", content: "dsh in the prompt" }] }))
const prompted = lastOf("user").text
check("#1028 DSH's @-path paragraph goes reworded in <external_system_instructions>",
prompted.includes("<external_system_instructions>") && prompted.includes("DSH-MARKER") && !prompted.includes("Tokens prefixed with @") && prompted.includes(reworded),
JSON.stringify(prompted))
delete process.env.FAKE_AGY_APPEND
const later = { model, system: "DSH-LATER", messages: [{ role: "user", content: "dsh later system" }] }
const laterEvents = (await readSSE(await callFetch(later))).events
const next = nextTurn(later, laterEvents, "after the dsh note")
next.messages.splice(next.messages.length - 1, 0, { role: "system", content: dsh })
await readSSE(await callFetch(next))
const laterText = lastOf("user").text
check("#1028 a later system message with the paragraph goes reworded", !laterText.includes("Tokens prefixed with @") && laterText.includes(reworded), JSON.stringify(laterText))
await readSSE(await callFetch({ model, system: "DSH-USER", messages: [{ role: "user", content: `user wrote ${dsh}` }] }))
check("#1028 what the user wrote goes as written", lastOf("user").text.includes(dsh), JSON.stringify(lastOf("user").text))
}
{
process.env.AGY_BRIDGE_START_TIMEOUT_MS = "40"
process.env.FAKE_AGY_INIT_MODE = "slow"