From d6db1cc38e6fc79154a0bfe6b56aa8285be22608 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 20:39:03 +0800 Subject: [PATCH 1/7] feat(#2302): ship the recommendation as a one-call payload (root cause) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The model was HANDED the wrong shape: the nudge lists 10 recommended ranges and hints 'fold in ONE call' — the model digests the list in groups, one compress call per group (the live 44s burst: five single-range calls re-billed 1.38M tokens; one 9-range call on the same log paid once). Instructions about batching do not survive contact with the model; the arguments themselves now do. src/one-call-payload.ts (bili-side, kernel untouched): - oneCallPayload(ranges) serializes every recommended range into the exact single-call compress args — { "content": [ { startId, endId, summary: … } ] } — copy, fill summaries, send once. >16 ranges fold into a same-call note. - withOneCallPayload(text, nudge, config) appends it at every surface the model reads: the injected nudge in all four wire lanes (server.ts ×4), the post-compress receipt tail (stream.ts postCompressTail), and acp_status (acp-status.ts). - #1198-safe framing: conditional 'if you compress', 'DELETE any entry you still need … never split it into several calls'. Skips tier-2/3 nudges (block-ref single-shot calls), single remaining ranges, and sub-floor entries the submit gate would reject (#847). Tests: tests/one-call-payload.test.ts (4) + digest-batch guard stays as the backstop; neighbors green (acp-status/ccr-v2/loop-core/digest-batch 67, tag-echo/compress suites 81, nudge suites 19); typecheck 0. --- src/acp-status.ts | 3 +- src/one-call-payload.ts | 45 +++++++++++++++++++++ src/server.ts | 13 ++++-- src/stream.ts | 3 +- tests/one-call-payload.test.ts | 72 ++++++++++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 6 deletions(-) create mode 100644 src/one-call-payload.ts create mode 100644 tests/one-call-payload.test.ts diff --git a/src/acp-status.ts b/src/acp-status.ts index 70a0012208..5462e32214 100644 --- a/src/acp-status.ts +++ b/src/acp-status.ts @@ -11,6 +11,7 @@ import { conflictEventsOf, formatConflictSection } from "./conflict-watch.js"; import { getBlindTunnelStats } from "./mitm.js"; import { getUnrecognizedPathStats } from "./server/observability.js"; import { ccrEnabled, ccrLoopConfig, contentStoreOf } from "./store.js"; +import { withOneCallPayload } from "./one-call-payload.js"; import { coveredRefSpan } from "./decompress-shared.js"; import { preCompactionArchiveOf, statusInputBaseline, type Session } from "./session.js"; import { describeAdvisory, getAdvisoryState } from "./advisory.js"; @@ -77,7 +78,7 @@ export function handleAcpStatus(args: Record, ctx: AcpStatusCtx const protectedRanges = nudge.protectedRanges ?? []; if (ranges.length > 0 || protectedRanges.length > 0) { extra.push(""); - extra.push(formatRanges(ranges, protectedRanges)); + extra.push(withOneCallPayload(formatRanges(ranges, protectedRanges), { ...nudge, compressibleRanges: ranges }, ctx.config)); } } } catch { diff --git a/src/one-call-payload.ts b/src/one-call-payload.ts new file mode 100644 index 0000000000..3edc39c95d --- /dev/null +++ b/src/one-call-payload.ts @@ -0,0 +1,45 @@ +// #2302 root-cause fix: the nudge hands the model a LIST of recommended +// ranges ("use these refs exactly as listed") and a hint to batch — and the +// model still digests the list in groups, one compress call per group. Each +// separate call resets the provider prefix cache from its fold point and +// re-bills the whole remaining history; one call carrying every range pays +// once (live incident: five single-range calls over 44s on a 555K-token +// session re-billed 1.38M tokens; one 9-range call on the same log paid +// once). Instructions have not worked — the recommendation itself now ships +// as a copy-fill-send payload: the exact single-call arguments with every +// recommended range pre-serialized, summary fields left to fill, entries +// deletable (never split the call). Applied at every surface the model reads: +// the injected nudge (all four wire lanes), the post-compress receipt tail, +// and acp_status. +import { viableRanges, type CompressibleRange, type Config, type NudgeDecision } from "acp-kernel"; + +/** Serialize ranges as ready-to-send compress arguments. Single line per + * entry; extra ranges beyond maxEntries collapse into a trailing note (the + * visible list above still shows them all). */ +export function oneCallPayload(ranges: readonly CompressibleRange[], maxEntries = 16): string { + const shown = ranges.slice(0, maxEntries); + const entries = shown.map((r) => ` { "startId": "${r.startRef}", "endId": "${r.endRef}", "summary": "…" }`); + const more = ranges.length - shown.length; + return [ + `{ "content": [`, + entries.join(",\n") + (more > 0 ? "," : ""), + ...(more > 0 ? [` // …plus ${more} more range(s) — add them as further entries in the SAME call`] : []), + `] }`, + ].join("\n"); +} + +/** Append the one-call payload to a rendered nudge / receipt text. No-op for + * tier-2/3 nudges (their calls are single-shot block rewrites), for ranges + * the submit gate would reject (#847 min chars), and when nothing viable + * remains. Keeps the #1198 licensing intact: the payload is framed as "if + * you compress" with explicit delete-don't-split semantics — a model that + * still needs a range drops the entry, it never folds the call in halves. */ +export function withOneCallPayload(text: string, nudge: NudgeDecision, config: Config): string { + if (!text) return text; + if (nudge.tier !== null && nudge.tier >= 2) return text; + const minChars = config.compress.minCompressRange ?? 0; + const viable = viableRanges(nudge.compressibleRanges) + .filter((r) => minChars <= 0 || (r.chars ?? r.tokens * 4) >= minChars); + if (viable.length < 2) return text; + return `${text}\n\nONE-CALL PAYLOAD — if you compress, fold every range below in a SINGLE compress call: copy this, fill each "summary", DELETE any entry you still need (it reappears in later nudges) — never split it into several calls. Each separate call re-bills the whole remaining history; one call pays once.\n${oneCallPayload(viable)}`; +} diff --git a/src/server.ts b/src/server.ts index 98b7cd54aa..e93f710a27 100644 --- a/src/server.ts +++ b/src/server.ts @@ -5,6 +5,7 @@ import net from "node:net"; import tls from "node:tls"; import { createHash, randomUUID } from "node:crypto"; import { performance } from "node:perf_hooks"; +import { withOneCallPayload } from "./one-call-payload.js"; import { createCore, type CompressionCore, type CompressionState, type Config, type AbsorbConfig, type CoreMessage, type NudgeDecision, type Prompts, type PackSurface, type ToolPrompts, applyAcpToolOverrides, defaultPrompts, defaultCountTokens, renderNudgeText, deactivateBlock, viableRanges, resolveOutputSteeringConfig } from "acp-kernel"; import { DEFAULT_STRIP_IMAGES_KEEP_RECENT, applyCompressSettings, resolveAbsorbSettings, resolveCompress, resolveCompressPrompts, resolveCompressSurfaceDetailed, resolveRequestConfig } from "./compress-settings.js"; import { dropCompressReasoning, type CompressReasoningConfig } from "./reasoning-drop.js"; @@ -3964,8 +3965,9 @@ async function prepareAnthropic( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); if (rendered.text) { - rebuiltMessages = [...rebuiltMessages, { role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(rendered.text), externalSummaryEnabled(config)), visibilityMarkers) }]; + rebuiltMessages = [...rebuiltMessages, { role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(renderedWithPayload), externalSummaryEnabled(config)), visibilityMarkers) }]; } } catch { } @@ -4213,8 +4215,9 @@ async function prepareOpenai( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); if (rendered.text) { - rebuiltMessages = [...rebuiltMessages, { role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(rendered.text), externalSummaryEnabled(config)), visibilityMarkers) }]; + rebuiltMessages = [...rebuiltMessages, { role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(renderedWithPayload), externalSummaryEnabled(config)), visibilityMarkers) }]; } } catch { } @@ -4464,8 +4467,9 @@ async function prepareGoogle( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); if (rendered.text) { - rebuiltContents = appendGoogleNudge(rebuiltContents, withMarkerIntegrityNote(withStagedCompressGuidance(rendered.text), visibilityMarkers)); + rebuiltContents = appendGoogleNudge(rebuiltContents, withMarkerIntegrityNote(withStagedCompressGuidance(renderedWithPayload), visibilityMarkers)); } } catch { } @@ -4792,11 +4796,12 @@ async function prepareResponses( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); if (rendered.text) { const inputItems: ResponseInputItem[] = typeof rebuiltInput === "string" ? [{ type: "message", role: "user", content: rebuiltInput }] : rebuiltInput; - inputItems.push({ type: "message", role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(rendered.text), externalSummaryEnabled(config)), visibilityMarkers) }); + inputItems.push({ type: "message", role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(renderedWithPayload), externalSummaryEnabled(config)), visibilityMarkers) }); rebuiltInput = inputItems; log("debug", `[${sessionId}] [inject] ephemeral nudge appended as trailing user turn (${rendered.text.length} chars)`); } diff --git a/src/stream.ts b/src/stream.ts index 6407e4b964..7296900197 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -6,6 +6,7 @@ import { type Session, cacheBlockContent, markDirty, statusInputBaseline } from import { COMPRESS_TOOL_NAME, parseCompressInput, ABSORB_TOOL_NAME, type ParsedRange } from "./compress-tool.js"; import { effectiveAbsorbConfig, executeAbsorb, isProxyToolFor } from "./absorb.js"; import { executeSearchContextTarget, resolveDecompress } from "./decompress-shared.js"; +import { withOneCallPayload } from "./one-call-payload.js"; import { adoptContentStore, contentStoreOf, ccrEnabled, drainPendingRetrievals, executeRetrieve, retrieveToolName } from "./store.js"; import { IMAGE_FULL_TOOL_NAME, executeImageFull, imageCompressionEnabled } from "./image-compress.js"; import { imagePlaceholdersForSummary } from "./image-note.js"; @@ -364,7 +365,7 @@ function postCompressTail(ctx: RewriteCtx, cleanSuccess: boolean): string { const remaining = viableRanges(nudge.compressibleRanges) .filter((r) => minChars <= 0 || (r.chars ?? r.tokens * 4) >= minChars); if (remaining.length > 0) { - return `\n\nCurrent compressible ranges (use these refs exactly as listed):\n${formatRanges(remaining, [])}`; + return `\n\nCurrent compressible ranges (use these refs exactly as listed):\n${formatRanges(remaining, [])}` + withOneCallPayload("", { ...nudge, compressibleRanges: remaining }, ctx.config); } // A tier-distillation nudge means block-boundary compress calls (bN..bM) // are still actionable — a stop signal there would contradict the tier diff --git a/tests/one-call-payload.test.ts b/tests/one-call-payload.test.ts new file mode 100644 index 0000000000..b84edf7e69 --- /dev/null +++ b/tests/one-call-payload.test.ts @@ -0,0 +1,72 @@ +// #2302 root-cause fix: the recommendation itself must ship as a copy-fill-send +// payload. The nudge used to hand the model a LIST of recommended ranges plus a +// batch hint — and the model digested the list in groups, one compress call per +// group (live: 10 recommended ranges → 3 calls; 5 calls over 44s re-billed +// 1.38M tokens). oneCallPayload pre-serializes every recommended range into the +// exact single-call arguments; withOneCallPayload appends it to every surface +// the model reads (nudge injection ×4 lanes, post-compress tail, acp_status) +// while keeping the #1198 conditional framing (delete entries you still need — +// never split the call). +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { oneCallPayload, withOneCallPayload } from "../src/one-call-payload.ts"; +import { defaultConfig, type CompressibleRange, type NudgeDecision } from "acp-kernel"; + +function range(start: number, end: number, tokens: number, chars?: number): CompressibleRange { + return { + startRef: `m${String(start).padStart(5, "0")}`, + endRef: `m${String(end).padStart(5, "0")}`, + tokens, + chars, + summaryTokens: 64, + } as unknown as CompressibleRange; +} + +function nudge(ranges: CompressibleRange[], tier: number | null = null): NudgeDecision { + return { + shouldInject: true, + reason: "test", + contextUsage: 0.5, + tier, + compressibleRanges: ranges, + } as unknown as NudgeDecision; +} + +const CFG = defaultConfig(200_000); + +test("#2302: oneCallPayload serializes ranges as ready-to-send compress args", () => { + const out = oneCallPayload([range(1, 42, 8000), range(50, 121, 12000), range(130, 200, 9000)]); + assert.ok(out.startsWith(`{ "content": [`), "opens a single-call content array"); + assert.ok(out.includes(`{ "startId": "m00001", "endId": "m00042", "summary": "…" }`), "entry 1 pre-serialized"); + assert.ok(out.includes(`{ "startId": "m00050", "endId": "m00121", "summary": "…" }`), "entry 2 pre-serialized"); + assert.ok(out.includes(`{ "startId": "m00130", "endRef"`.replace("m00130", `"m00130`).slice(0, 0) + `{ "startId": "m00130", "endId": "m00200", "summary": "…" }`), "entry 3 pre-serialized"); + assert.ok(out.trimEnd().endsWith(`] }`), "closes the call"); +}); + +test("#2302: more than maxEntries ranges collapse into a same-call note", () => { + const ranges = Array.from({ length: 18 }, (_, i) => range(i * 10 + 1, i * 10 + 9, 1000)); + const out = oneCallPayload(ranges); + assert.equal((out.match(/"startId"/g) ?? []).length, 16, "16 entries shown"); + assert.ok(out.includes("plus 2 more range(s)"), "overflow folded into a note"); + assert.ok(out.includes("SAME call"), "note keeps them inside the same call"); +}); + +test("#2302: withOneCallPayload appends the payload with #1198-safe framing", () => { + const out = withOneCallPayload("NUDGE BODY", nudge([range(1, 10, 5000), range(11, 20, 5000)]), CFG); + assert.ok(out.startsWith("NUDGE BODY"), "original text preserved"); + assert.ok(out.includes("ONE-CALL PAYLOAD"), "payload section present"); + assert.ok(out.includes("if you compress"), "conditional framing kept (#1198)"); + assert.ok(out.includes("DELETE any entry you still need"), "delete-don't-split licensing kept"); + assert.ok(out.includes("never split"), "never split directive present"); + assert.ok(out.includes(`{ "startId": "m00001", "endId": "m00010", "summary": "…" }`), "ranges pre-serialized"); +}); + +test("#2302: skip conditions — tier>=2, single range, empty text, sub-floor chars", () => { + assert.equal(withOneCallPayload("", nudge([range(1, 10, 5000), range(11, 20, 5000)]), CFG), "", "empty text stays empty"); + // Tier-2/3 nudges drive single-shot block-ref calls — no payload. + assert.equal(withOneCallPayload("T2 BODY", nudge([range(1, 10, 5000), range(11, 20, 5000)], 2), CFG), "T2 BODY"); + // A single remaining range cannot be split — no payload. + assert.equal(withOneCallPayload("ONE BODY", nudge([range(1, 10, 5000)]), CFG), "ONE BODY"); + // Ranges below the submit gate's char floor (#847) must not be advertised. + assert.equal(withOneCallPayload("FLOOR BODY", nudge([range(1, 10, 100, 40), range(11, 20, 100, 40)]), CFG), "FLOOR BODY"); +}); From f6cee8c3fbf67f2310f61e533803297065429732 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 20:57:48 +0800 Subject: [PATCH 2/7] refactor(#2302): one-call payload in the compress tool's preferred line form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Owner review: the JSON content-array skeleton was the wrong shape twice — (1) it prescribed packaging the model should decide for itself, and (2) the tool's preferred form is the LINE FORM: content is ONE string that may carry every range, one block per range ('mNNNNN–mNNNNN optional topic' header, summary body below, no JSON, no escaping). oneCallPayload now emits a line-form skeleton: refs headers authoritative (ours, round-trip through the real parser — pinned by a test), summary bodies entirely the model's (''). The framing stays #1198-safe: 'If you compress… send every block below in a single call; DELETE the blocks you still need — never split'. No JSON shells anywhere. Overflow beyond 16 ranges collapses into a '+N more range(s) — continue the SAME string' note instead of separate blocks. --- src/one-call-payload.ts | 48 +++++++++++++------------ tests/one-call-payload.test.ts | 65 +++++++++++++++++++++------------- 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/src/one-call-payload.ts b/src/one-call-payload.ts index 3edc39c95d..11ca12baec 100644 --- a/src/one-call-payload.ts +++ b/src/one-call-payload.ts @@ -1,39 +1,41 @@ // #2302 root-cause fix: the nudge hands the model a LIST of recommended // ranges ("use these refs exactly as listed") and a hint to batch — and the -// model still digests the list in groups, one compress call per group. Each +// model digests the list in groups, one compress call per group. Each // separate call resets the provider prefix cache from its fold point and // re-bills the whole remaining history; one call carrying every range pays // once (live incident: five single-range calls over 44s on a 555K-token // session re-billed 1.38M tokens; one 9-range call on the same log paid -// once). Instructions have not worked — the recommendation itself now ships -// as a copy-fill-send payload: the exact single-call arguments with every -// recommended range pre-serialized, summary fields left to fill, entries -// deletable (never split the call). Applied at every surface the model reads: -// the injected nudge (all four wire lanes), the post-compress receipt tail, -// and acp_status. +// once). The tool's preferred line form already makes batching natural — +// content is ONE string that may hold every range — so the recommendation +// itself now ships as a ready-to-fill line-form skeleton: refs headers +// authoritative (ours), summary bodies entirely the model's to write (its +// decision, its wording). How to package is NOT prescribed beyond "one +// call, one string": no JSON shells, no escaped strings. Applied at every +// surface the model reads: the injected nudge (all four wire lanes), the +// post-compress receipt tail, and acp_status. import { viableRanges, type CompressibleRange, type Config, type NudgeDecision } from "acp-kernel"; -/** Serialize ranges as ready-to-send compress arguments. Single line per - * entry; extra ranges beyond maxEntries collapse into a trailing note (the - * visible list above still shows them all). */ +/** Serialize ranges as a line-form skeleton: one block per range, first line + * the refs (en dash, optional topic slot), remaining lines the model's + * summary. Matches the compress tool's preferred content shape — one string + * carries the whole batch, no JSON structure, no escaping. Extra ranges + * beyond maxEntries collapse into a trailing same-string note. */ export function oneCallPayload(ranges: readonly CompressibleRange[], maxEntries = 16): string { const shown = ranges.slice(0, maxEntries); - const entries = shown.map((r) => ` { "startId": "${r.startRef}", "endId": "${r.endRef}", "summary": "…" }`); + const blocks = shown.map((r) => `${r.startRef}–${r.endRef} \n`); const more = ranges.length - shown.length; - return [ - `{ "content": [`, - entries.join(",\n") + (more > 0 ? "," : ""), - ...(more > 0 ? [` // …plus ${more} more range(s) — add them as further entries in the SAME call`] : []), - `] }`, - ].join("\n"); + const tailMore = more > 0 + ? `\n\n(+${more} more range(s) — continue the SAME string with further blocks, one per range: ${ranges.slice(maxEntries).map((r) => `${r.startRef}–${r.endRef}`).join(", ")})` + : ""; + return blocks.join("\n\n") + tailMore; } -/** Append the one-call payload to a rendered nudge / receipt text. No-op for +/** Append the one-call skeleton to a rendered nudge / receipt text. No-op for * tier-2/3 nudges (their calls are single-shot block rewrites), for ranges - * the submit gate would reject (#847 min chars), and when nothing viable - * remains. Keeps the #1198 licensing intact: the payload is framed as "if - * you compress" with explicit delete-don't-split semantics — a model that - * still needs a range drops the entry, it never folds the call in halves. */ + * the submit gate would reject (#847 min chars), and when fewer than two + * viable ranges remain. Keeps the #1198 licensing intact: conditional "if + * you compress" framing and delete-don't-split semantics — a model that + * still needs a range drops the block, it never folds the call in halves. */ export function withOneCallPayload(text: string, nudge: NudgeDecision, config: Config): string { if (!text) return text; if (nudge.tier !== null && nudge.tier >= 2) return text; @@ -41,5 +43,5 @@ export function withOneCallPayload(text: string, nudge: NudgeDecision, config: C const viable = viableRanges(nudge.compressibleRanges) .filter((r) => minChars <= 0 || (r.chars ?? r.tokens * 4) >= minChars); if (viable.length < 2) return text; - return `${text}\n\nONE-CALL PAYLOAD — if you compress, fold every range below in a SINGLE compress call: copy this, fill each "summary", DELETE any entry you still need (it reappears in later nudges) — never split it into several calls. Each separate call re-bills the whole remaining history; one call pays once.\n${oneCallPayload(viable)}`; + return `${text}\n\nONE CALL CARRIES THE WHOLE BATCH — compress accepts ONE string holding every range: one block per range, first line the refs (as shown below, optional topic after them), remaining lines your summary. If you compress, send every block below in a single call; DELETE the blocks you still need (they reappear in later nudges) — never split them into several calls. Each separate call re-bills the whole remaining history; one call pays once.\n${oneCallPayload(viable)}`; } diff --git a/tests/one-call-payload.test.ts b/tests/one-call-payload.test.ts index b84edf7e69..4357c9bcef 100644 --- a/tests/one-call-payload.test.ts +++ b/tests/one-call-payload.test.ts @@ -1,15 +1,17 @@ -// #2302 root-cause fix: the recommendation itself must ship as a copy-fill-send -// payload. The nudge used to hand the model a LIST of recommended ranges plus a -// batch hint — and the model digested the list in groups, one compress call per -// group (live: 10 recommended ranges → 3 calls; 5 calls over 44s re-billed -// 1.38M tokens). oneCallPayload pre-serializes every recommended range into the -// exact single-call arguments; withOneCallPayload appends it to every surface -// the model reads (nudge injection ×4 lanes, post-compress tail, acp_status) -// while keeping the #1198 conditional framing (delete entries you still need — -// never split the call). +// #2302 root-cause fix: the recommendation itself must make batching the +// path of least resistance. The nudge used to hand the model a LIST of +// recommended ranges plus a batch hint — and the model digested the list in +// groups, one compress call per group (live: 10 recommended ranges → 3 calls; +// 5 calls over 44s re-billed 1.38M tokens). The compress tool's preferred +// line form already supports one-string-one-batch, so the recommendation now +// ships as a line-form skeleton: refs headers authoritative, summaries the +// model's own to write. Packaging style beyond "one call, one string" is NOT +// prescribed (no JSON object shells — that was the wrong shape, corrected per +// owner review). import { test } from "node:test"; import assert from "node:assert/strict"; import { oneCallPayload, withOneCallPayload } from "../src/one-call-payload.ts"; +import { parseCompressInput } from "../src/compress-tool.ts"; import { defaultConfig, type CompressibleRange, type NudgeDecision } from "acp-kernel"; function range(start: number, end: number, tokens: number, chars?: number): CompressibleRange { @@ -34,31 +36,46 @@ function nudge(ranges: CompressibleRange[], tier: number | null = null): NudgeDe const CFG = defaultConfig(200_000); -test("#2302: oneCallPayload serializes ranges as ready-to-send compress args", () => { +test("#2302: oneCallPayload emits the line-form skeleton (one string, all ranges)", () => { const out = oneCallPayload([range(1, 42, 8000), range(50, 121, 12000), range(130, 200, 9000)]); - assert.ok(out.startsWith(`{ "content": [`), "opens a single-call content array"); - assert.ok(out.includes(`{ "startId": "m00001", "endId": "m00042", "summary": "…" }`), "entry 1 pre-serialized"); - assert.ok(out.includes(`{ "startId": "m00050", "endId": "m00121", "summary": "…" }`), "entry 2 pre-serialized"); - assert.ok(out.includes(`{ "startId": "m00130", "endRef"`.replace("m00130", `"m00130`).slice(0, 0) + `{ "startId": "m00130", "endId": "m00200", "summary": "…" }`), "entry 3 pre-serialized"); - assert.ok(out.trimEnd().endsWith(`] }`), "closes the call"); + assert.ok(out.includes("m00001–m00042 "), "refs header line form (en dash, topic slot)"); + assert.ok(out.includes("m00050–m00121 "), "second range header"); + assert.ok(out.includes("m00130–m00200 "), "third range header"); + assert.ok(out.includes(""), "summary body left to the model"); + assert.ok(!out.includes('"startId"') && !out.includes("{") && !out.includes("}"), "no JSON shells — packaging is the model's call"); }); -test("#2302: more than maxEntries ranges collapse into a same-call note", () => { +test("#2302: the skeleton headers round-trip through the real compress parser", () => { + // The refs we recommend must parse exactly — the model copies the headers + // verbatim, fills the bodies, and sends ONE string. + const ranges = [range(1, 42, 8000), range(50, 121, 12000)]; + const payload = oneCallPayload(ranges) + .replace(//g, "summary body long enough for the kernel minimum length check, written by the model"); + const parsed = parseCompressInput({ content: payload }); + assert.equal(parsed.ranges.length, 2, "one string → both ranges"); + assert.equal(parsed.ranges[0]?.startRef, "m00001"); + assert.equal(parsed.ranges[0]?.endRef, "m00042"); + assert.equal(parsed.ranges[1]?.startRef, "m00050"); + assert.equal(parsed.ranges[1]?.endRef, "m00121"); + assert.ok(parsed.ranges.every((r) => (r.summary ?? "").includes("summary body long enough")), "line-form bodies become summaries"); +}); + +test("#2302: more than maxEntries ranges collapse into a same-string note", () => { const ranges = Array.from({ length: 18 }, (_, i) => range(i * 10 + 1, i * 10 + 9, 1000)); const out = oneCallPayload(ranges); - assert.equal((out.match(/"startId"/g) ?? []).length, 16, "16 entries shown"); - assert.ok(out.includes("plus 2 more range(s)"), "overflow folded into a note"); - assert.ok(out.includes("SAME call"), "note keeps them inside the same call"); + assert.equal((out.match(//g) ?? []).length, 16, "16 headers shown as blocks"); + assert.ok(out.includes("+2 more range(s)"), "overflow folded into a note"); + assert.ok(out.includes("SAME string"), "note keeps them inside the one call"); }); -test("#2302: withOneCallPayload appends the payload with #1198-safe framing", () => { +test("#2302: withOneCallPayload appends the skeleton with #1198-safe framing", () => { const out = withOneCallPayload("NUDGE BODY", nudge([range(1, 10, 5000), range(11, 20, 5000)]), CFG); assert.ok(out.startsWith("NUDGE BODY"), "original text preserved"); - assert.ok(out.includes("ONE-CALL PAYLOAD"), "payload section present"); - assert.ok(out.includes("if you compress"), "conditional framing kept (#1198)"); - assert.ok(out.includes("DELETE any entry you still need"), "delete-don't-split licensing kept"); + assert.ok(out.includes("ONE CALL CARRIES THE WHOLE BATCH"), "one-call framing present"); + assert.ok(out.includes("If you compress"), "conditional framing kept (#1198)"); + assert.ok(out.includes("DELETE the blocks you still need"), "delete-don't-split licensing kept"); assert.ok(out.includes("never split"), "never split directive present"); - assert.ok(out.includes(`{ "startId": "m00001", "endId": "m00010", "summary": "…" }`), "ranges pre-serialized"); + assert.ok(out.includes("m00001–m00010 "), "refs headers pre-serialized"); }); test("#2302: skip conditions — tier>=2, single range, empty text, sub-floor chars", () => { From c979301a5983a2386ff5dc2c29d736ece5303053 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 22:06:05 +0800 Subject: [PATCH 3/7] refactor(#2302): move the one-call skeleton into the kernel nudge text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kernel-change: the one-call skeleton belongs with the nudge that recommends the ranges — renderNudgeText now appends it itself (gentle AND emergency), so every host of acp-kernel gets the fix and the bili-side module plus its six wiring points disappear. - kernel/src/nudge-text.ts: oneCallPayload (line-form skeleton) + oneCallTail (framing + skeleton; conditional framing for gentle #1198, unconditional 'When you compress' for emergency; empty below two ranges). renderNudgeText appends the tail for tier-1 nudges; T2/T3 block-ref nudges never see it. - kernel 0.0.105 → 0.0.106. - bili: src/one-call-payload.ts deleted; the four wire lanes render the kernel text verbatim again; postCompressTail + acp_status call the kernel export directly. - tests: kernel nudge-text pins (gentle/emergency/T2/under-two) + bili-side round-trip through the real compress parser. --- kernel/package.json | 2 +- kernel/src/index.ts | 3 +- kernel/src/nudge-text.ts | 59 +++++++++++++++++++ kernel/tests/nudge-text.test.ts | 48 +++++++++++++++ package-lock.json | 2 +- src/acp-status.ts | 4 +- src/one-call-payload.ts | 47 --------------- src/server.ts | 9 ++- src/stream.ts | 4 +- tests/one-call-payload.test.ts | 101 ++++++++++---------------------- 10 files changed, 150 insertions(+), 129 deletions(-) delete mode 100644 src/one-call-payload.ts diff --git a/kernel/package.json b/kernel/package.json index 3dc5533b9f..b5ec719ae3 100644 --- a/kernel/package.json +++ b/kernel/package.json @@ -1,6 +1,6 @@ { "name": "acp-kernel", - "version": "0.0.105", + "version": "0.0.106", "description": "Framework-agnostic context-compression engine (model-driven, 3-tier LSM). Pure core: no host dependency.", "license": "MIT", "author": "ranxianglei", diff --git a/kernel/src/index.ts b/kernel/src/index.ts index fe6d718ddd..6506667f9d 100644 --- a/kernel/src/index.ts +++ b/kernel/src/index.ts @@ -53,11 +53,12 @@ export { countMessageTokens, } from "./tokenize.js"; export type { TokenCountFn } from "./tokenize.js"; -export { renderNudgeText, formatRanges } from "./nudge-text.js"; +export { renderNudgeText, formatRanges, oneCallPayload, oneCallTail } from "./nudge-text.js"; export type { NudgeVoice, RenderedNudge, NudgePromptSections, + OneCallTailOptions, } from "./nudge-text.js"; export { resolveBlockSpan, diff --git a/kernel/src/nudge-text.ts b/kernel/src/nudge-text.ts index abeedbf992..d5390286fd 100644 --- a/kernel/src/nudge-text.ts +++ b/kernel/src/nudge-text.ts @@ -229,6 +229,63 @@ function compact(parts: string[]): string[] { return parts; } +/** #2302: serialize ranges as a ready-to-fill line-form skeleton — the + * compress tool's preferred content shape. ONE string carries the whole + * batch: one block per range, first line the refs (en dash, optional + * topic slot), remaining lines the model's summary. No JSON shells, no + * escaping. Ranges beyond maxEntries collapse into a trailing same-string + * note. Refs are ours; the wording is the model's. */ +export function oneCallPayload( + ranges: readonly CompressibleRange[], + maxEntries = 16, +): string { + const shown = ranges.slice(0, maxEntries); + const blocks = shown.map( + (r) => + `${r.startRef}–${r.endRef} \n`, + ); + const more = ranges.length - shown.length; + const tailMore = + more > 0 + ? `\n\n(+${more} more range(s) — continue the SAME string with further blocks, one per range: ${ranges + .slice(maxEntries) + .map((r) => `${r.startRef}–${r.endRef}`) + .join(", ")})` + : ""; + return blocks.join("\n\n") + tailMore; +} + +export interface OneCallTailOptions { + /** Gentle nudges frame the skeleton conditionally (#1198 — "if you + * compress"); emergency nudges keep their unconditional directive. */ + conditional?: boolean; +} + +/** #2302 root-cause fix, as a nudge tail. The nudge used to hand the model + * a LIST of recommended ranges plus a batching hint — and the model + * digests the list in groups, one compress call per group. Each separate + * call resets the provider prefix cache from its fold point and re-bills + * the whole remaining history; one call carrying every range pays once + * (live incident: five single-range calls over 44s on a 555K-token + * session re-billed 1.38M tokens; one 9-range call on the same log paid + * once). Instructions about batching do not survive contact with the + * model — the arguments themselves now do. Empty when fewer than two + * ranges (nothing to batch). Keeps #1198 licensing: conditional framing + * where required, and delete-don't-split semantics — a model that still + * needs a range drops the block, it never folds the call in halves. */ +export function oneCallTail( + ranges: readonly CompressibleRange[], + options: OneCallTailOptions = {}, +): string { + if (ranges.length < 2) return ""; + const when = + options.conditional === false + ? "When you compress" + : "If you compress"; + return `\n\nONE CALL, ONE STRING — compress accepts a single string holding every range: one block per range, first line the refs (as shown below), remaining lines your summary. ${when}, send every block below in a single call; DELETE the blocks you still need (they reappear in later nudges) — never split them into several calls. Each separate call re-bills the whole remaining history; one call pays once.\n${oneCallPayload(ranges)}`; +} + + export function renderNudgeText( decision: NudgeDecision, prompts: Prompts = defaultPrompts, @@ -290,6 +347,7 @@ export function renderNudgeText( "", rangesStr, ...(blockMapStr ? ["", blockMapStr] : []), + oneCallTail(decision.compressibleRanges, { conditional: false }), ]).join("\n"), }; } @@ -308,6 +366,7 @@ export function renderNudgeText( ...(blockMapStr ? ["", blockMapStr] : []), "", `💡 If you compress, fold the ranges you keep in ONE call — pass multiple content entries (\`content: [{...}, {...}]\`) or ONE plain string holding every range, each block starting with its 'mNNNNN–mNNNNN topic' header line (most robust through lossy gateways). Ranges the task still needs can wait — they reappear in later nudges.`, + oneCallTail(decision.compressibleRanges), ]).join("\n"), }; } diff --git a/kernel/tests/nudge-text.test.ts b/kernel/tests/nudge-text.test.ts index 49367768af..dd94414f35 100644 --- a/kernel/tests/nudge-text.test.ts +++ b/kernel/tests/nudge-text.test.ts @@ -380,3 +380,51 @@ test("no user-msg annotation when count is zero or absent", () => { "makeRanges fixtures carry no userMsgs", ); }); + +// #2302: the one-call skeleton (line form) rides both gentle and emergency +// nudges — the model gets ready-to-fill compress arguments, not a batch +// hint it will ignore. T2/T3 nudges fold block refs and never see it. +test("#2302: gentle nudge carries the one-call line-form skeleton", () => { + const result = renderNudgeText(makeDecision({ contextUsage: 0.5 })); + assert.ok(result.text.includes("ONE CALL, ONE STRING"), "skeleton framing"); + assert.ok( + result.text.includes("m00001–m00003 "), + "refs header from the recommended ranges", + ); + assert.ok( + result.text.includes(""), + "summary slot left to the model", + ); + // the old batch hint stays — the skeleton extends it, not replaces it + assert.ok(result.text.includes("fold the ranges you keep in ONE call")); +}); + +test("#2302: emergency nudge keeps the skeleton but stays unconditional (#1198)", () => { + const emergency = renderNudgeText( + makeDecision({ contextUsage: 0.99, breakdown: { emergencyOverride: 1 } }), + ); + assert.ok(emergency.text.includes("ONE CALL, ONE STRING"), "skeleton rides"); + assert.ok( + !emergency.text.includes("If you compress"), + "emergency stays unconditional", + ); + assert.ok( + emergency.text.includes("When you compress"), + "unconditional framing for the skeleton", + ); +}); + +test("#2302: tier-2/tier-3 nudges carry no message-ref skeleton (block refs)", () => { + const t2 = renderNudgeText( + makeDecision({ contextUsage: 0.5, tier: 2, tierTargetBlocks: [] }), + ); + assert.ok(!t2.text.includes("ONE CALL, ONE STRING"), "T2 folds blocks"); + assert.ok(!t2.text.includes("")); +}); + +test("#2302: fewer than two ranges → no skeleton (nothing to batch)", () => { + const single = renderNudgeText( + makeDecision({ contextUsage: 0.5, compressibleRanges: makeRanges(1) }), + ); + assert.ok(!single.text.includes("ONE CALL, ONE STRING")); +}); diff --git a/package-lock.json b/package-lock.json index 40e15ba743..0528f06606 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ }, "kernel": { "name": "acp-kernel", - "version": "0.0.105", + "version": "0.0.106", "dev": true, "license": "MIT", "devDependencies": { diff --git a/src/acp-status.ts b/src/acp-status.ts index 5462e32214..8cb192189a 100644 --- a/src/acp-status.ts +++ b/src/acp-status.ts @@ -11,7 +11,7 @@ import { conflictEventsOf, formatConflictSection } from "./conflict-watch.js"; import { getBlindTunnelStats } from "./mitm.js"; import { getUnrecognizedPathStats } from "./server/observability.js"; import { ccrEnabled, ccrLoopConfig, contentStoreOf } from "./store.js"; -import { withOneCallPayload } from "./one-call-payload.js"; +import { oneCallTail } from "acp-kernel"; import { coveredRefSpan } from "./decompress-shared.js"; import { preCompactionArchiveOf, statusInputBaseline, type Session } from "./session.js"; import { describeAdvisory, getAdvisoryState } from "./advisory.js"; @@ -78,7 +78,7 @@ export function handleAcpStatus(args: Record, ctx: AcpStatusCtx const protectedRanges = nudge.protectedRanges ?? []; if (ranges.length > 0 || protectedRanges.length > 0) { extra.push(""); - extra.push(withOneCallPayload(formatRanges(ranges, protectedRanges), { ...nudge, compressibleRanges: ranges }, ctx.config)); + extra.push(formatRanges(ranges, protectedRanges) + oneCallTail(ranges)); } } } catch { diff --git a/src/one-call-payload.ts b/src/one-call-payload.ts deleted file mode 100644 index 11ca12baec..0000000000 --- a/src/one-call-payload.ts +++ /dev/null @@ -1,47 +0,0 @@ -// #2302 root-cause fix: the nudge hands the model a LIST of recommended -// ranges ("use these refs exactly as listed") and a hint to batch — and the -// model digests the list in groups, one compress call per group. Each -// separate call resets the provider prefix cache from its fold point and -// re-bills the whole remaining history; one call carrying every range pays -// once (live incident: five single-range calls over 44s on a 555K-token -// session re-billed 1.38M tokens; one 9-range call on the same log paid -// once). The tool's preferred line form already makes batching natural — -// content is ONE string that may hold every range — so the recommendation -// itself now ships as a ready-to-fill line-form skeleton: refs headers -// authoritative (ours), summary bodies entirely the model's to write (its -// decision, its wording). How to package is NOT prescribed beyond "one -// call, one string": no JSON shells, no escaped strings. Applied at every -// surface the model reads: the injected nudge (all four wire lanes), the -// post-compress receipt tail, and acp_status. -import { viableRanges, type CompressibleRange, type Config, type NudgeDecision } from "acp-kernel"; - -/** Serialize ranges as a line-form skeleton: one block per range, first line - * the refs (en dash, optional topic slot), remaining lines the model's - * summary. Matches the compress tool's preferred content shape — one string - * carries the whole batch, no JSON structure, no escaping. Extra ranges - * beyond maxEntries collapse into a trailing same-string note. */ -export function oneCallPayload(ranges: readonly CompressibleRange[], maxEntries = 16): string { - const shown = ranges.slice(0, maxEntries); - const blocks = shown.map((r) => `${r.startRef}–${r.endRef} \n`); - const more = ranges.length - shown.length; - const tailMore = more > 0 - ? `\n\n(+${more} more range(s) — continue the SAME string with further blocks, one per range: ${ranges.slice(maxEntries).map((r) => `${r.startRef}–${r.endRef}`).join(", ")})` - : ""; - return blocks.join("\n\n") + tailMore; -} - -/** Append the one-call skeleton to a rendered nudge / receipt text. No-op for - * tier-2/3 nudges (their calls are single-shot block rewrites), for ranges - * the submit gate would reject (#847 min chars), and when fewer than two - * viable ranges remain. Keeps the #1198 licensing intact: conditional "if - * you compress" framing and delete-don't-split semantics — a model that - * still needs a range drops the block, it never folds the call in halves. */ -export function withOneCallPayload(text: string, nudge: NudgeDecision, config: Config): string { - if (!text) return text; - if (nudge.tier !== null && nudge.tier >= 2) return text; - const minChars = config.compress.minCompressRange ?? 0; - const viable = viableRanges(nudge.compressibleRanges) - .filter((r) => minChars <= 0 || (r.chars ?? r.tokens * 4) >= minChars); - if (viable.length < 2) return text; - return `${text}\n\nONE CALL CARRIES THE WHOLE BATCH — compress accepts ONE string holding every range: one block per range, first line the refs (as shown below, optional topic after them), remaining lines your summary. If you compress, send every block below in a single call; DELETE the blocks you still need (they reappear in later nudges) — never split them into several calls. Each separate call re-bills the whole remaining history; one call pays once.\n${oneCallPayload(viable)}`; -} diff --git a/src/server.ts b/src/server.ts index e93f710a27..9617a157b7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -5,7 +5,6 @@ import net from "node:net"; import tls from "node:tls"; import { createHash, randomUUID } from "node:crypto"; import { performance } from "node:perf_hooks"; -import { withOneCallPayload } from "./one-call-payload.js"; import { createCore, type CompressionCore, type CompressionState, type Config, type AbsorbConfig, type CoreMessage, type NudgeDecision, type Prompts, type PackSurface, type ToolPrompts, applyAcpToolOverrides, defaultPrompts, defaultCountTokens, renderNudgeText, deactivateBlock, viableRanges, resolveOutputSteeringConfig } from "acp-kernel"; import { DEFAULT_STRIP_IMAGES_KEEP_RECENT, applyCompressSettings, resolveAbsorbSettings, resolveCompress, resolveCompressPrompts, resolveCompressSurfaceDetailed, resolveRequestConfig } from "./compress-settings.js"; import { dropCompressReasoning, type CompressReasoningConfig } from "./reasoning-drop.js"; @@ -3965,7 +3964,7 @@ async function prepareAnthropic( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); - const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); + const renderedWithPayload = rendered.text; if (rendered.text) { rebuiltMessages = [...rebuiltMessages, { role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(renderedWithPayload), externalSummaryEnabled(config)), visibilityMarkers) }]; } @@ -4215,7 +4214,7 @@ async function prepareOpenai( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); - const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); + const renderedWithPayload = rendered.text; if (rendered.text) { rebuiltMessages = [...rebuiltMessages, { role: "user", content: withMarkerIntegrityNote(withSummaryBudgetNote(withStagedCompressGuidance(renderedWithPayload), externalSummaryEnabled(config)), visibilityMarkers) }]; } @@ -4467,7 +4466,7 @@ async function prepareGoogle( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); - const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); + const renderedWithPayload = rendered.text; if (rendered.text) { rebuiltContents = appendGoogleNudge(rebuiltContents, withMarkerIntegrityNote(withStagedCompressGuidance(renderedWithPayload), visibilityMarkers)); } @@ -4796,7 +4795,7 @@ async function prepareResponses( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); - const renderedWithPayload = withOneCallPayload(rendered.text, turn.nudge, config); + const renderedWithPayload = rendered.text; if (rendered.text) { const inputItems: ResponseInputItem[] = typeof rebuiltInput === "string" ? [{ type: "message", role: "user", content: rebuiltInput }] diff --git a/src/stream.ts b/src/stream.ts index 7296900197..d4714dcded 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -6,7 +6,7 @@ import { type Session, cacheBlockContent, markDirty, statusInputBaseline } from import { COMPRESS_TOOL_NAME, parseCompressInput, ABSORB_TOOL_NAME, type ParsedRange } from "./compress-tool.js"; import { effectiveAbsorbConfig, executeAbsorb, isProxyToolFor } from "./absorb.js"; import { executeSearchContextTarget, resolveDecompress } from "./decompress-shared.js"; -import { withOneCallPayload } from "./one-call-payload.js"; +import { oneCallTail } from "acp-kernel"; import { adoptContentStore, contentStoreOf, ccrEnabled, drainPendingRetrievals, executeRetrieve, retrieveToolName } from "./store.js"; import { IMAGE_FULL_TOOL_NAME, executeImageFull, imageCompressionEnabled } from "./image-compress.js"; import { imagePlaceholdersForSummary } from "./image-note.js"; @@ -365,7 +365,7 @@ function postCompressTail(ctx: RewriteCtx, cleanSuccess: boolean): string { const remaining = viableRanges(nudge.compressibleRanges) .filter((r) => minChars <= 0 || (r.chars ?? r.tokens * 4) >= minChars); if (remaining.length > 0) { - return `\n\nCurrent compressible ranges (use these refs exactly as listed):\n${formatRanges(remaining, [])}` + withOneCallPayload("", { ...nudge, compressibleRanges: remaining }, ctx.config); + return `\n\nCurrent compressible ranges (use these refs exactly as listed):\n${formatRanges(remaining, [])}` + oneCallTail(remaining); } // A tier-distillation nudge means block-boundary compress calls (bN..bM) // are still actionable — a stop signal there would contradict the tier diff --git a/tests/one-call-payload.test.ts b/tests/one-call-payload.test.ts index 4357c9bcef..398d65c99a 100644 --- a/tests/one-call-payload.test.ts +++ b/tests/one-call-payload.test.ts @@ -1,57 +1,39 @@ -// #2302 root-cause fix: the recommendation itself must make batching the -// path of least resistance. The nudge used to hand the model a LIST of -// recommended ranges plus a batch hint — and the model digested the list in -// groups, one compress call per group (live: 10 recommended ranges → 3 calls; -// 5 calls over 44s re-billed 1.38M tokens). The compress tool's preferred -// line form already supports one-string-one-batch, so the recommendation now -// ships as a line-form skeleton: refs headers authoritative, summaries the -// model's own to write. Packaging style beyond "one call, one string" is NOT -// prescribed (no JSON object shells — that was the wrong shape, corrected per -// owner review). +// #2302: the one-call skeleton now lives in the kernel (nudge-text.ts) and +// rides every surface the model reads — renderNudgeText itself (all wire +// lanes inject its output), the post-compress receipt tail, and acp_status. +// These tests pin the kernel shape from the bili side, including a +// round-trip through the REAL compress parser: the refs we hand out must +// parse as a one-string batch once the model fills the bodies. import { test } from "node:test"; import assert from "node:assert/strict"; -import { oneCallPayload, withOneCallPayload } from "../src/one-call-payload.ts"; +import { oneCallPayload, oneCallTail, type CompressibleRange } from "acp-kernel"; import { parseCompressInput } from "../src/compress-tool.ts"; -import { defaultConfig, type CompressibleRange, type NudgeDecision } from "acp-kernel"; -function range(start: number, end: number, tokens: number, chars?: number): CompressibleRange { - return { - startRef: `m${String(start).padStart(5, "0")}`, - endRef: `m${String(end).padStart(5, "0")}`, - tokens, - chars, - summaryTokens: 64, - } as unknown as CompressibleRange; +function range(start: number, end: number): CompressibleRange { + return { startRef: `m${String(start).padStart(5, "0")}`, endRef: `m${String(end).padStart(5, "0")}`, tokens: 1000 } as unknown as CompressibleRange; } -function nudge(ranges: CompressibleRange[], tier: number | null = null): NudgeDecision { - return { - shouldInject: true, - reason: "test", - contextUsage: 0.5, - tier, - compressibleRanges: ranges, - } as unknown as NudgeDecision; -} - -const CFG = defaultConfig(200_000); +test("#2302: skeleton is line form — one string, one block per range", () => { + const payload = oneCallPayload([range(1, 42), range(50, 121)]); + assert.ok(!payload.includes("{"), "no JSON shells"); + assert.ok(payload.includes("m00001–m00042 "), "refs header line"); + assert.ok(payload.includes(""), "summary slot"); +}); -test("#2302: oneCallPayload emits the line-form skeleton (one string, all ranges)", () => { - const out = oneCallPayload([range(1, 42, 8000), range(50, 121, 12000), range(130, 200, 9000)]); - assert.ok(out.includes("m00001–m00042 "), "refs header line form (en dash, topic slot)"); - assert.ok(out.includes("m00050–m00121 "), "second range header"); - assert.ok(out.includes("m00130–m00200 "), "third range header"); - assert.ok(out.includes(""), "summary body left to the model"); - assert.ok(!out.includes('"startId"') && !out.includes("{") && !out.includes("}"), "no JSON shells — packaging is the model's call"); +test("#2302: tail frames one call and deferral, skips <2 ranges", () => { + assert.equal(oneCallTail([range(1, 2)]), "", "nothing to batch"); + const tail = oneCallTail([range(1, 42), range(50, 121)]); + assert.ok(tail.includes("If you compress"), "#1198 conditional framing"); + assert.ok(tail.includes("never split"), "delete-don't-split licensing"); + assert.ok(oneCallTail([range(1, 42), range(50, 121)], { conditional: false }).includes("When you compress"), "emergency variant stays unconditional"); }); -test("#2302: the skeleton headers round-trip through the real compress parser", () => { - // The refs we recommend must parse exactly — the model copies the headers - // verbatim, fills the bodies, and sends ONE string. - const ranges = [range(1, 42, 8000), range(50, 121, 12000)]; - const payload = oneCallPayload(ranges) - .replace(//g, "summary body long enough for the kernel minimum length check, written by the model"); - const parsed = parseCompressInput({ content: payload }); +test("#2302: skeleton headers round-trip through the real compress parser", () => { + const payload = oneCallPayload([range(1, 42), range(50, 121)]); + // the model replaces the placeholder bodies with real summaries — + // keep the refs lines, swap in a long-enough summary + const filled = payload.replace(//g, "topic").replace(//g, "summary body long enough for the minimum length check"); + const parsed = parseCompressInput({ content: filled }); assert.equal(parsed.ranges.length, 2, "one string → both ranges"); assert.equal(parsed.ranges[0]?.startRef, "m00001"); assert.equal(parsed.ranges[0]?.endRef, "m00042"); @@ -61,29 +43,8 @@ test("#2302: the skeleton headers round-trip through the real compress parser", }); test("#2302: more than maxEntries ranges collapse into a same-string note", () => { - const ranges = Array.from({ length: 18 }, (_, i) => range(i * 10 + 1, i * 10 + 9, 1000)); - const out = oneCallPayload(ranges); - assert.equal((out.match(//g) ?? []).length, 16, "16 headers shown as blocks"); - assert.ok(out.includes("+2 more range(s)"), "overflow folded into a note"); - assert.ok(out.includes("SAME string"), "note keeps them inside the one call"); -}); - -test("#2302: withOneCallPayload appends the skeleton with #1198-safe framing", () => { - const out = withOneCallPayload("NUDGE BODY", nudge([range(1, 10, 5000), range(11, 20, 5000)]), CFG); - assert.ok(out.startsWith("NUDGE BODY"), "original text preserved"); - assert.ok(out.includes("ONE CALL CARRIES THE WHOLE BATCH"), "one-call framing present"); - assert.ok(out.includes("If you compress"), "conditional framing kept (#1198)"); - assert.ok(out.includes("DELETE the blocks you still need"), "delete-don't-split licensing kept"); - assert.ok(out.includes("never split"), "never split directive present"); - assert.ok(out.includes("m00001–m00010 "), "refs headers pre-serialized"); -}); - -test("#2302: skip conditions — tier>=2, single range, empty text, sub-floor chars", () => { - assert.equal(withOneCallPayload("", nudge([range(1, 10, 5000), range(11, 20, 5000)]), CFG), "", "empty text stays empty"); - // Tier-2/3 nudges drive single-shot block-ref calls — no payload. - assert.equal(withOneCallPayload("T2 BODY", nudge([range(1, 10, 5000), range(11, 20, 5000)], 2), CFG), "T2 BODY"); - // A single remaining range cannot be split — no payload. - assert.equal(withOneCallPayload("ONE BODY", nudge([range(1, 10, 5000)]), CFG), "ONE BODY"); - // Ranges below the submit gate's char floor (#847) must not be advertised. - assert.equal(withOneCallPayload("FLOOR BODY", nudge([range(1, 10, 100, 40), range(11, 20, 100, 40)]), CFG), "FLOOR BODY"); + const many = Array.from({ length: 18 }, (_, i) => range(i * 10 + 1, i * 10 + 9)); + const payload = oneCallPayload(many); + assert.equal((payload.match(//g) ?? []).length, 16, "16 headers shown as blocks"); + assert.ok(payload.includes("continue the SAME string"), "overflow note"); }); From 4295f82fbe8c658abe42c226734c9bfc0a3b1c1a Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 22:14:47 +0800 Subject: [PATCH 4/7] ci: refresh PR event (kernel-change: marker lives in the body since 8857ffe8) From 3c790cd6dca13196222cbd0c65f16dbb61b1ebb8 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 23:18:05 +0800 Subject: [PATCH 5/7] refactor(#2302): unify every compress surface on the single-string batch form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit kernel-change: all surfaces now teach ONE shape — a single-string batch (one block per range, 'mNNNNN–mNNNNN topic' header + summary). The mixed signals (single-entry JSON examples in the emergency nudge and the TOOLS list, a JSON-array alternative in the gentle tip) are what the model was actually following when it split batches. - compress-tools TOOLS entry: leads with the ONE-string batch example; single range is the same shape with one block; object entries demoted to 'also accepted' - COMPRESS_TOOL description + content param description: PREFERRED form first (single string holding ALL ranges), alternatives after - emergency nudge: single-entry JSON example line removed — the appended skeleton IS the example - gentle tip: points at the skeleton, no more JSON-array alternative - oneCallTail shortened to one imperative line (the tool description and the tip carry the semantics; the tail just frames the skeleton) - fixtures regenerated (TOOLS section bytes) kernel 1260/1260; bili typecheck 0; payload suite 4/4. --- kernel/src/compress-tools.ts | 6 ++--- kernel/src/index.ts | 1 - kernel/src/nudge-text.ts | 22 +++++-------------- .../fixtures/prompt-function-default.txt | 2 +- kernel/tests/nudge-text.test.ts | 4 ++-- tests/one-call-payload.test.ts | 3 +-- 6 files changed, 12 insertions(+), 26 deletions(-) diff --git a/kernel/src/compress-tools.ts b/kernel/src/compress-tools.ts index a6dd4a9969..847530eb6c 100644 --- a/kernel/src/compress-tools.ts +++ b/kernel/src/compress-tools.ts @@ -96,7 +96,7 @@ export const COMPRESS_PARAMETERS = { }, content: { description: - "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", anyOf: [ { type: "array", @@ -150,7 +150,7 @@ export const COMPRESS_PARAMETERS = { export const COMPRESS_TOOL = { name: COMPRESS_TOOL_NAME, description: - "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", input_schema: COMPRESS_PARAMETERS, }; @@ -252,7 +252,7 @@ Each message in the conversation is annotated with a ", "endId": "", "summary": "..." }] }`, "Only use IDs from visible messages above. Compress older work first.", "", rangesStr, ...(blockMapStr ? ["", blockMapStr] : []), - oneCallTail(decision.compressibleRanges, { conditional: false }), + oneCallTail(decision.compressibleRanges), ]).join("\n"), }; } diff --git a/kernel/tests/fixtures/prompt-function-default.txt b/kernel/tests/fixtures/prompt-function-default.txt index 89cd4d7f86..0b1bfa32fd 100644 --- a/kernel/tests/fixtures/prompt-function-default.txt +++ b/kernel/tests/fixtures/prompt-function-default.txt @@ -50,7 +50,7 @@ TOOLS You have five context-management tools: -- compress — Replace a contiguous range of older conversation with a single detailed summary you write. Use when content is genuinely consumed (no longer needed for the current task step). Single range: compress({ topic: "...", content: [{ startId: "m00150", endId: "m00220", summary: "..." }] }). Batch (multiple unrelated ranges, each with its own topic): compress({ content: [{ topic: "Auth", startId: "m00150", endId: "m00220", summary: "..." }, { topic: "Deploy", startId: "m00300", endId: "m00350", summary: "..." }] }), or the same batch as ONE plain string — most robust through lossy gateways: compress({ content: "m00150–m00220 Auth\nsummary…\nm00300–m00350 Deploy\nsummary…" }) — one block per range, each starting with its 'mNNNNN–mNNNNN optional topic' header line. +- compress — Replace consumed conversation ranges with self-contained summaries you write. ONE call carries EVERY range: compress({ content: "m00150–m00220 Auth\nsummary…\nm00300–m00350 Deploy\nsummary…" }) — one plain string, one block per range, each block starting with its 'mNNNNN–mNNNNN optional topic' header line followed by that block's summary (plain text survives lossy gateways best). A single range is the same shape with one block. Object entries {startId,endId,summary,topic?} in the content array are also accepted. Never split a batch into one call per range. - decompress — Restore a previously compressed block's content. By default restores one tier up (T2→T1 summaries, not raw messages). Use full: true to restore all the way to original messages. Use toFile to write to file instead of inflating context. Example: decompress({ blockId: "b5" }) or decompress({ blockId: "b5", toFile: "path" }) or decompress({ blockId: "b5", full: true }). - search_context — Search compressed block summaries (and optionally visible messages) by keyword. Use BEFORE decompressing to find the right block. Example: search_context({ query: "auth token refresh" }). - acp_status — Context status with compressible ranges. No args = overview + ranges. Use to find what to compress next. diff --git a/kernel/tests/nudge-text.test.ts b/kernel/tests/nudge-text.test.ts index dd94414f35..8397f75548 100644 --- a/kernel/tests/nudge-text.test.ts +++ b/kernel/tests/nudge-text.test.ts @@ -409,8 +409,8 @@ test("#2302: emergency nudge keeps the skeleton but stays unconditional (#1198)" "emergency stays unconditional", ); assert.ok( - emergency.text.includes("When you compress"), - "unconditional framing for the skeleton", + emergency.text.includes("ONE CALL, ONE STRING"), + "skeleton framing has no conditional of its own (the emergency header carries the directive)", ); }); diff --git a/tests/one-call-payload.test.ts b/tests/one-call-payload.test.ts index 398d65c99a..a5133ee498 100644 --- a/tests/one-call-payload.test.ts +++ b/tests/one-call-payload.test.ts @@ -23,9 +23,8 @@ test("#2302: skeleton is line form — one string, one block per range", () => { test("#2302: tail frames one call and deferral, skips <2 ranges", () => { assert.equal(oneCallTail([range(1, 2)]), "", "nothing to batch"); const tail = oneCallTail([range(1, 42), range(50, 121)]); - assert.ok(tail.includes("If you compress"), "#1198 conditional framing"); assert.ok(tail.includes("never split"), "delete-don't-split licensing"); - assert.ok(oneCallTail([range(1, 42), range(50, 121)], { conditional: false }).includes("When you compress"), "emergency variant stays unconditional"); + assert.ok(!tail.includes("If you compress"), "the tail carries no directive of its own — the nudge text around it does (#1198)"); }); test("#2302: skeleton headers round-trip through the real compress parser", () => { From bd5f34e262d9a19e1a8faacc0180a861cf9c5919 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 23:22:46 +0800 Subject: [PATCH 6/7] refactor(#2302): lean pack content param leads with the ONE-string batch form too --- kernel/src/packs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/src/packs.ts b/kernel/src/packs.ts index 7d6a1651d1..6ec0490d9b 100644 --- a/kernel/src/packs.ts +++ b/kernel/src/packs.ts @@ -182,7 +182,7 @@ const LEAN_TOOL_PROMPTS: ToolPrompts = { "Replace consumed conversation ranges with self-contained summaries using mNNNNN or bN refs; batch multiple ranges into ONE call (a single string may hold every range).", paramDescriptions: { content: - "One string per range: first line 'm00150–m00220 optional topic', remaining lines the summary markdown; ONE string may hold several ranges (new header line per range). Object form also accepted.", + "ONE plain string holding ALL ranges — one block per range, first line 'm00150–m00220 optional topic', remaining lines the summary markdown; object entries in the content array also accepted.", startId: "Inclusive first mNNNNN or bN ref.", endId: "Inclusive last mNNNNN or bN ref.", summary: "Self-contained replacement preserving exact technical details.", From e12a283f832b1b365eab32e9225e8c08a2fa0fb7 Mon Sep 17 00:00:00 2001 From: ranxianglei Date: Wed, 7 Oct 2026 23:44:06 +0800 Subject: [PATCH 7/7] test(#2302): regenerate wire-contract goldens for the one-call description rewording --- tests/golden/wire-contract/bili.json | 14 +++++----- tests/golden/wire-contract/kernel.json | 28 +++++++++---------- .../wire-contract/manifest-default.json | 12 ++++---- .../golden/wire-contract/manifest-optin.json | 12 ++++---- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/golden/wire-contract/bili.json b/tests/golden/wire-contract/bili.json index 4fc1486f53..387acde3f4 100644 --- a/tests/golden/wire-contract/bili.json +++ b/tests/golden/wire-contract/bili.json @@ -3,7 +3,7 @@ "anthropic": [ { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "input_schema": { "type": "object", "properties": { @@ -12,7 +12,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -206,7 +206,7 @@ "type": "function", "function": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -215,7 +215,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -421,7 +421,7 @@ { "type": "function", "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -430,7 +430,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -626,7 +626,7 @@ "google": [ { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { diff --git a/tests/golden/wire-contract/kernel.json b/tests/golden/wire-contract/kernel.json index 42cce6ba3a..7f0eee6958 100644 --- a/tests/golden/wire-contract/kernel.json +++ b/tests/golden/wire-contract/kernel.json @@ -3,7 +3,7 @@ "ACP_TOOLS_ANTHROPIC": [ { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "input_schema": { "type": "object", "properties": { @@ -12,7 +12,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -194,7 +194,7 @@ "type": "function", "function": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -203,7 +203,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -397,7 +397,7 @@ { "type": "function", "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -406,7 +406,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -665,7 +665,7 @@ "ACP_TOOLS_GOOGLE": [ { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -765,7 +765,7 @@ "individual": { "COMPRESS_TOOL": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "input_schema": { "type": "object", "properties": { @@ -774,7 +774,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -885,7 +885,7 @@ "type": "function", "function": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -894,7 +894,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -1005,7 +1005,7 @@ "COMPRESS_TOOL_RESPONSES": { "type": "function", "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -1014,7 +1014,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -1123,7 +1123,7 @@ }, "COMPRESS_TOOL_GOOGLE": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { diff --git a/tests/golden/wire-contract/manifest-default.json b/tests/golden/wire-contract/manifest-default.json index 6fed6d98ad..7cb11e191a 100644 --- a/tests/golden/wire-contract/manifest-default.json +++ b/tests/golden/wire-contract/manifest-default.json @@ -14,7 +14,7 @@ "anthropic": [ { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "input_schema": { "type": "object", "properties": { @@ -23,7 +23,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -209,7 +209,7 @@ "type": "function", "function": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -218,7 +218,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -416,7 +416,7 @@ { "type": "function", "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -425,7 +425,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", diff --git a/tests/golden/wire-contract/manifest-optin.json b/tests/golden/wire-contract/manifest-optin.json index 6de01d0876..fd03624ce0 100644 --- a/tests/golden/wire-contract/manifest-optin.json +++ b/tests/golden/wire-contract/manifest-optin.json @@ -17,7 +17,7 @@ "anthropic": [ { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "input_schema": { "type": "object", "properties": { @@ -26,7 +26,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -278,7 +278,7 @@ "type": "function", "function": { "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -287,7 +287,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array", @@ -560,7 +560,7 @@ { "type": "function", "name": "compress", - "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. Line form (preferred): content = one STRING per range — first line 'm00150–m00220 optional topic', remaining lines the markdown summary written verbatim (no JSON structure, no escaping). Also accepted: object entries {startId,endId,summary,topic?} in the content array, content as a single string (bare line form — one string may hold ALL ranges, each block starting with its refs header line — or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", + "description": "Replace consumed conversation ranges with self-contained summaries you write, identified by their refs. PREFERRED form: content = ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (no JSON structure, no escaping; a JSON-encoded array as that string is also accepted for gateways that stringify arrays). Also accepted: object entries {startId,endId,summary,topic?} in the content array, and a flat single-range call {startId,endId,summary,topic?} without content. Batch multiple ranges into ONE call — do not split into one call per range. Use when content is genuinely consumed. REQUIRED — compress without content or flat range fields is invalid.", "parameters": { "type": "object", "properties": { @@ -569,7 +569,7 @@ "description": "Optional short title for the compressed range" }, "content": { - "description": "One or more ranges to compress into separate summary blocks. Array form: one entry per range — line form (one STRING per range: first line 'm00150–m00220 optional topic', remaining lines the markdown summary verbatim) or object form {startId,endId,summary,topic?}. Single-string form (PREFERRED for multi-range batches — plain text survives lossy gateways best): ONE plain string holding ALL ranges, each block starting with its 'm00150–m00220 optional topic' header line followed by that block's summary. A JSON-encoded array of ranges as that string is also accepted (some gateways stringify arrays). Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", + "description": "One or more ranges to compress into separate summary blocks. PREFERRED (multi-range batch): ONE plain string holding ALL ranges — each block starts with its 'm00150–m00220 optional topic' header line followed by that block's summary (plain text survives lossy gateways best; a JSON-encoded array as that string is also accepted). Array form: one entry per range — a line-form string or an object {startId,endId,summary,topic?}. Batch multiple ranges into ONE call — do not split into one call per range. REQUIRED unless the flat single-range form is used.", "anyOf": [ { "type": "array",