From b83b3f8c53050e5d1a7f561198d61dbe5044a6ac Mon Sep 17 00:00:00 2001
From: wassname <1103714+wassname@users.noreply.github.com>
Date: Thu, 16 Apr 2026 15:39:24 +0800
Subject: [PATCH] fix: use HTML comment format for dcp-id tags to prevent model
echo
XML-style m001 tags get echoed by models because they
look like semantic content. HTML comments are
invisible in rendered markdown and models are trained to skip them.
---
prompts.ts | 6 +++---
pruner.ts | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/prompts.ts b/prompts.ts
index 5bc985a..cb69319 100644
--- a/prompts.ts
+++ b/prompts.ts
@@ -13,7 +13,7 @@ You operate in a context-constrained environment. Manage context continuously to
The ONLY tool you have for context management is \`compress\`. It replaces older conversation content with technical summaries you produce.
-\`\` and \`\` tags are environment-injected metadata. Do not output them.
+\`\` and \`\` tags are environment-injected metadata. Do not output them.
THE PHILOSOPHY OF COMPRESS
\`compress\` transforms conversation content into dense, high-fidelity summaries. This is not cleanup — it is crystallization. Your summary becomes the authoritative record of what transpired.
@@ -114,7 +114,7 @@ You specify boundaries by ID using the injected IDs visible in the conversation:
- \`mNNN\` IDs identify raw messages (3 digits, zero-padded, e.g. \`m001\`, \`m042\`)
- \`bN\` IDs identify previously compressed blocks
-Each message has an ID inside XML metadata tags like \`...\`.
+Each message has an ID inside an HTML comment like \`\`.
The ID tag appears at the end of the message it belongs to — it identifies the message above it, not the one below it.
Treat these tags as boundary metadata only, not as tool result content.
@@ -215,7 +215,7 @@ Prefer multiple short, closed ranges over one large range when several independe
export const MANUAL_MODE_SYSTEM_PROMPT = `
You are operating in DCP manual mode for context management.
-\`\` and \`\` tags are environment-injected metadata. Do not output them.
+\`\` and \`\` tags are environment-injected metadata. Do not output them.
In manual mode you do NOT proactively compress conversation content. Compression is a deliberate, user-directed action.
diff --git a/pruner.ts b/pruner.ts
index efe4e3d..469542c 100644
--- a/pruner.ts
+++ b/pruner.ts
@@ -151,9 +151,9 @@ function applyCompressionBlocks(messages: any[], state: DcpState): any[] {
block.topic +
"]\n\n" +
block.summary +
- "\n\nb" +
+ "\n\n",
},
],
// anchorTimestamp is always finite (resolveAnchorTimestamp returns
@@ -356,11 +356,11 @@ function injectMessageIds(messages: any[], state: DcpState): void {
const id = "m" + String(counter).padStart(3, "0");
counter++;
- const idTag = `\n${id}`;
+ const idTag = `\n`;
if (role === "user") {
if (typeof msg.content === "string") {
- msg.content = msg.content + `\n\n${id}`;
+ msg.content = msg.content + `\n\n`;
} else if (Array.isArray(msg.content)) {
msg.content = [...msg.content, { type: "text", text: idTag }];
}