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/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 + `${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; +} + +/** #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: the gentle tip above + * stays conditional, and delete-don't-split semantics mean a model that + * still needs a range drops the block, never folds the call in halves. */ +export function oneCallTail( + ranges: readonly CompressibleRange[], +): string { + if (ranges.length < 2) return ""; + return `\n\nONE CALL, ONE STRING — copy, fill each summary, DELETE the blocks you still need (they reappear in later nudges); never split into several calls:\n${oneCallPayload(ranges)}`; +} + + export function renderNudgeText( decision: NudgeDecision, prompts: Prompts = defaultPrompts, @@ -285,11 +331,11 @@ export function renderNudgeText( "", prompts.howToCompressRules, "", - `{ "topic": "...", "content": [{ "startId": "", "endId": "", "summary": "..." }] }`, "Only use IDs from visible messages above. Compress older work first.", "", rangesStr, ...(blockMapStr ? ["", blockMapStr] : []), + oneCallTail(decision.compressibleRanges), ]).join("\n"), }; } @@ -308,6 +354,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/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.", 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 49367768af..8397f75548 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("ONE CALL, ONE STRING"), + "skeleton framing has no conditional of its own (the emergency header carries the directive)", + ); +}); + +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 70a0012208..8cb192189a 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 { oneCallTail } from "acp-kernel"; 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(formatRanges(ranges, protectedRanges) + oneCallTail(ranges)); } } } catch { diff --git a/src/server.ts b/src/server.ts index 98b7cd54aa..9617a157b7 100644 --- a/src/server.ts +++ b/src/server.ts @@ -3964,8 +3964,9 @@ async function prepareAnthropic( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = rendered.text; 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 +4214,9 @@ async function prepareOpenai( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = rendered.text; 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 +4466,9 @@ async function prepareGoogle( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = rendered.text; if (rendered.text) { - rebuiltContents = appendGoogleNudge(rebuiltContents, withMarkerIntegrityNote(withStagedCompressGuidance(rendered.text), visibilityMarkers)); + rebuiltContents = appendGoogleNudge(rebuiltContents, withMarkerIntegrityNote(withStagedCompressGuidance(renderedWithPayload), visibilityMarkers)); } } catch { } @@ -4792,11 +4795,12 @@ async function prepareResponses( if (willInjectNudge && turn.nudge) { try { const rendered = renderNudgeText(turn.nudge, prompts, surface?.nudgeSections); + const renderedWithPayload = rendered.text; 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..d4714dcded 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 { 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"; @@ -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, [])}` + 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/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", diff --git a/tests/one-call-payload.test.ts b/tests/one-call-payload.test.ts new file mode 100644 index 0000000000..a5133ee498 --- /dev/null +++ b/tests/one-call-payload.test.ts @@ -0,0 +1,49 @@ +// #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, oneCallTail, type CompressibleRange } from "acp-kernel"; +import { parseCompressInput } from "../src/compress-tool.ts"; + +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; +} + +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: 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("never split"), "delete-don't-split licensing"); + 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", () => { + 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"); + 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 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"); +});