From b947fa76902d5e5f6ebe758071c7d747938e9fea Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 26 Sep 2026 08:00:56 +0800 Subject: [PATCH 1/2] fix: targeted no-re-issue receipt for content-less compress calls (#1366) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A compress call carrying no content at all ({} / empty-string args — observed in #1366 as an 'empty companion' compress() emitted alongside the valid one) got the generic format lecture ending in 'Re-issue the compress call'. A structurally empty call can never satisfy that instruction, so a weak FC model looped the identical spec until the #847 repeat-failure guard tripped (~2h of context burn in the incident). applyRanges now detects the truly-empty case (kind empty-input / missing-content without per-entry reasons, excluding the #362 {ranges: ...} shape drift where re-issue IS the right advice) and returns a receipt that names the actual defect and forbids the re-issue. The #847 guard still records these failures; every other receipt is byte-identical. --- src/stream.ts | 17 +++++++++++++- tests/compress-observability.test.ts | 35 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/stream.ts b/src/stream.ts index f87a0cb431..3cca9def03 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -208,11 +208,26 @@ export function applyRanges(parsed: ReturnType, ctx: // list stays logged above). const reasons = rawReasons.slice(0, 3).map((r) => (r.length > 160 ? r.slice(0, 160) + "..." : r)); const why = reasons.length > 0 ? ` Rejected entries: ${reasons.join(" | ")}.` : ""; + // #1366: a call with NO content at all ({} / "" args — an "empty companion" + // compress() emitted alongside the real one) must never be told to + // "re-issue": a structurally empty call fails identically every time, so + // that advice loops until the #847 guard trips. The #362 shape-drift case + // ({ranges: …} instead of {content: …}) stays on the format lecture below: + // there, fixing the key CAN succeed, so re-issue IS the right advice. + const isEmptyCall = + rawReasons.length === 0 && + (diagnostics.kind === "empty-input" || + (diagnostics.kind === "missing-content" && !(diagnostics.keys ?? []).includes("ranges"))); const guard = recordCompressFailure( ctx.session, `parse:${diagnostics.kind}:${diagnostics.invalidItems}:${rawReasons.slice(0, 3).join("|")}`, - "Fix the argument shape against the format below instead of re-issuing the same malformed call.", + isEmptyCall + ? "An empty call fails identically on every retry — drop it instead of re-issuing." + : "Fix the argument shape against the format below instead of re-issuing the same malformed call.", ); + if (isEmptyCall) { + return `[Compression FAILED: the call carried no content at all (kind=${diagnostics.kind}) — an empty compress() compresses nothing and can never succeed. Do NOT re-issue an empty call; if you meant to compress, put the non-empty 'content' array (elements {startId, endId, summary}) in that SAME single call.${guard}]`; + } return `[Compression FAILED: no valid ranges parsed (kind=${diagnostics.kind}, dropped=${diagnostics.invalidItems}).${why} compress requires a non-empty 'content' array where each element is EITHER an object {startId, endId, summary} OR one line-form string whose first line is 'mNNNNN–mNNNNN optional topic' with the summary markdown on the following lines (a separate summary-only element right after a bare header line is also accepted). startId/endId are mNNNNN message refs from the conversation (call acp_status to see current refs).${compressibleSpanHint(ctx.session.state)} Re-issue the compress call with a valid content array.${guard}]`; } // #847: detect reversed refs as SUBMITTED, before #1001 normalization diff --git a/tests/compress-observability.test.ts b/tests/compress-observability.test.ts index 053a134f39..266c49d398 100644 --- a/tests/compress-observability.test.ts +++ b/tests/compress-observability.test.ts @@ -120,6 +120,41 @@ test("#349: empty compress args → actionable no-valid-ranges message (missing- assert.ok(!out.includes("Check your startId/endId parameters"), "old misleading hint removed"); }); +test("#1366: truly-empty call gets the targeted no-re-issue receipt (no loop bait)", () => { + const ctx = makeCompressibleCtx(); + const out = runApply(ctx, {}); + assert.ok(out.startsWith("[Compression FAILED"), `expected failure, got: ${out}`); + assert.ok(out.includes("carried no content at all"), out); + assert.ok(out.includes("kind=missing-content"), out); + assert.ok(out.includes("Do NOT re-issue an empty call"), out); + assert.ok(!out.includes("Re-issue the compress call with a valid content array"), "old loop-bait tail gone: " + out); + assert.ok(out.includes("non-empty 'content' array") && out.includes("{startId, endId, summary}"), "#349 steering kept"); +}); + +test("#1366: empty-string arguments get the same targeted receipt (kind=empty-input)", () => { + const ctx = makeCompressibleCtx(); + const out = runApply(ctx, ""); + assert.ok(out.includes("carried no content at all"), out); + assert.ok(out.includes("kind=empty-input"), out); + assert.ok(!out.includes("Re-issue the compress call with a valid content array"), out); +}); + +test("#1366: empty calls are still recorded by the #847 repeat-failure guard", () => { + const ctx = makeCompressibleCtx(); + runApply(ctx, {}); + const keys = ctx.session.metadata["compressFailKeys"] as unknown[]; + assert.equal(keys.length, 1, "failure recorded"); + assert.match(String(keys[0]), /^parse:missing-content:0:/, String(keys)); +}); + +test("#1366/#362: shape drift ({ranges: …}) keeps the format lecture — re-issue IS right there", () => { + const ctx = makeCompressibleCtx(); + const out = runApply(ctx, { ranges: [{ startId: "m00001", endId: "m00002", summary: "s" }] }); + assert.ok(out.includes("kind=missing-content"), out); + assert.ok(out.includes("Re-issue the compress call with a valid content array"), "lecture retained: " + out); + assert.ok(!out.includes("carried no content at all"), "not mislabeled as empty: " + out); +}); + test("#189: staged-compress steering note appended when shrink exceeds the configured max", () => { const prev = process.env.BILI_MAX_SHRINK_PER_COMPRESS; process.env.BILI_MAX_SHRINK_PER_COMPRESS = "0.05"; From 0d5e11149184c9752f493dae4066d850c25b43ad Mon Sep 17 00:00:00 2001 From: ework-agent Date: Sat, 26 Sep 2026 08:01:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20hedge=20the=20span-hint=20covered-pr?= =?UTF-8?q?efix=20claim=20=E2=80=94=20gaps=20below=20the=20boundary=20stay?= =?UTF-8?q?=20compressible=20(#1366)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compressibleSpanHint told models '(everything up to mNNNNN is already inside active blocks)'. Blocks need not be contiguous: in the #1366 session a live gap (m05027–m05052 between two active blocks) sat below the boundary, and the flat claim contributed to the model's 'nudge vs tool conflict' confusion. Wording now hedges ('largely inside ... isolated free gaps may still exist'); kernel validation was always authoritative. Labeled in-passing fix found while working #1366. --- src/stream.ts | 5 ++++- tests/compress-span-hint.test.ts | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stream.ts b/src/stream.ts index 3cca9def03..e0ae11a19f 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -93,7 +93,10 @@ export function compressibleSpanHint(state: Pick= 2 ? ` (e.g. startId ${actives[0]}, endId ${actives[actives.length - 1]})` : ""; return ` No raw refs are directly compressible right now — compress a run of ACTIVE blocks instead${span}: fold their summaries into one higher-tier block. acp_status lists the current active blocks.`; } - const covered = boundary > 0 ? ` (everything up to ${fmt(boundary)} is already inside active blocks)` : ""; + // #1366: blocks need not be contiguous — a gap below the highest block end + // (e.g. m05027–m05052 between two blocks) is still compressible raw space, so + // claiming "everything up to N is inside blocks" misleads models into skipping it. + const covered = boundary > 0 ? ` (refs up to ${fmt(boundary)} are largely inside active blocks; isolated free gaps may still exist below it)` : ""; return ` Live compressible refs: ${fmt(boundary + 1)}–${fmt(highest)}${covered}. Retry NOW in this same turn with startId/endId inside that span.`; } diff --git a/tests/compress-span-hint.test.ts b/tests/compress-span-hint.test.ts index 86293dfaaf..1709511367 100644 --- a/tests/compress-span-hint.test.ts +++ b/tests/compress-span-hint.test.ts @@ -55,6 +55,9 @@ test("#1026: hint names the raw span past the highest ACTIVE block boundary", () const hint = compressibleSpanHint(ctx.session.state); assert.ok(hint.includes("m00021–m00080"), `span past boundary: ${hint}`); assert.ok(hint.includes("inside active blocks"), `explains the covered prefix: ${hint}`); + // #1366: the covered-prefix claim must stay hedged — blocks need not be contiguous, + // and a flat "everything up to N" misled a model into skipping a live gap. + assert.ok(hint.includes("isolated free gaps may still exist"), `gap hedge present: ${hint}`); }); test("#1026: INACTIVE blocks (decompressed) do not hold the boundary", () => {