diff --git a/src/compress-tools.ts b/src/compress-tools.ts index c2c8d56..a6dd4a9 100644 --- a/src/compress-tools.ts +++ b/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 (preferred): 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?}. String form also accepted: bare line-form text, or a JSON-encoded array of ranges (some gateways stringify arrays). REQUIRED unless the flat single-range form is used.", + "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.", anyOf: [ { type: "array", @@ -105,7 +105,7 @@ export const COMPRESS_PARAMETERS = { { type: "string", description: - "Line form: first line 'm00150–m00220 optional topic', remaining lines the summary markdown, verbatim (no JSON escaping)", + "Line form: first line 'm00150–m00220 optional topic', remaining lines the summary markdown, verbatim (no JSON escaping). A single string may carry MULTIPLE ranges — each block starts with its own refs header line", }, { ...COMPRESS_RANGE_OBJECT, @@ -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 or JSON-encoded array), and a flat single-range call {startId,endId,summary,topic?} without content. 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. 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.", input_schema: COMPRESS_PARAMETERS, }; @@ -252,7 +252,7 @@ Each message in the conversation is annotated with a b.summary.includes("single object")), ); }); + +test("one bare string may carry a whole batch: every tool surface recommends it (#472)", () => { + // The default/lean packs + the nudge hint now teach this form as the + // gateway-robust way to batch — pin the parse so it cannot regress. + const { ranges, diagnostics } = parseCompressArgs({ + content: + "m00001–m00005 topic one\nsummary one line.\nm00006–m00008\ntopic-less summary.", + }); + assert.equal(diagnostics.kind, "ok"); + assert.equal(diagnostics.invalidItems, 0); + assert.equal(ranges.length, 2); + assert.deepEqual( + { + start: ranges[0]?.startRef, + end: ranges[0]?.endRef, + topic: ranges[0]?.topic, + summary: ranges[0]?.summary, + }, + { + start: "m00001", + end: "m00005", + topic: "topic one", + summary: "summary one line.", + }, + ); + assert.deepEqual( + { + start: ranges[1]?.startRef, + end: ranges[1]?.endRef, + summary: ranges[1]?.summary, + }, + { start: "m00006", end: "m00008", summary: "topic-less summary." }, + ); +});