Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/compress-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -252,7 +252,7 @@ Each message in the conversation is annotated with a <acp tokens="2.1K" type="to

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: "..." }] }).
- 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.
- 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.`,
Expand Down
2 changes: 1 addition & 1 deletion src/nudge-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export function renderNudgeText(
rangesStr,
...(blockMapStr ? ["", blockMapStr] : []),
"",
`💡 If you compress, fold the ranges you keep in ONE call (pass multiple content entries: \`content: [{...}, {...}]\`). Ranges the task still needs can wait — they reappear in later nudges.`,
`💡 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.`,
]).join("\n"),
};
}
4 changes: 2 additions & 2 deletions src/packs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ export const defaultPack: Pack = {
const LEAN_TOOL_PROMPTS: ToolPrompts = {
compress: {
description:
"Replace consumed conversation ranges with self-contained summaries using mNNNNN or bN refs.",
"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. Object form also accepted.",
"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.",
startId: "Inclusive first mNNNNN or bN ref.",
endId: "Inclusive last mNNNNN or bN ref.",
summary: "Self-contained replacement preserving exact technical details.",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/prompt-function-default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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: "..." }] }).
- 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.
- 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.
Expand Down
2 changes: 1 addition & 1 deletion tests/packs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ test("lean pack keeps rules default, one-line tool descriptions, adapters namesp
assert.deepEqual(leanPack.surface.prompts ?? {}, {});
assert.equal(
leanPack.surface.toolPrompts?.compress?.description,
"Replace consumed conversation ranges with self-contained summaries using mNNNNN or bN refs.",
"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).",
);
assert.ok(
leanPack.surface.adapters && typeof leanPack.surface.adapters === "object",
Expand Down
34 changes: 34 additions & 0 deletions tests/parse-compress-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,3 +1168,37 @@ test("rebuildCompressionState rebuilds from a single-object content tool-call (#
result.state.blocks.find((b) => 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." },
);
});
Loading