You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/prompts/compress.ts
+9-33Lines changed: 9 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -1,34 +1,19 @@
1
-
exportconstCOMPRESS=`Your only tool for context management, use it to collapse a range in the conversation into a detailed summary
1
+
exportconstCOMPRESS=`Collapse a range in the conversation into a detailed summary.
2
2
3
3
THE PHILOSOPHY OF COMPRESS
4
4
\`compress\` transforms verbose conversation sequences into dense, high-fidelity summaries. This is not cleanup - it is crystallization. Your summary becomes the authoritative record of what transpired.
5
5
6
6
Think of compression as phase transitions: raw exploration becomes refined understanding. The original context served its purpose; your summary now carries that understanding forward.
7
7
8
-
One method, many safe ranges:
9
-
10
-
- short, closed ranges for disposable noise
11
-
- short, closed ranges for resolved investigative slices
12
-
- short, closed ranges for completed implementation chunks
13
-
14
-
Default to multiple short, bounded compressions. Prefer several safe range compressions over one large sweep whenever independent ranges are available.
15
-
16
-
CADENCE, SIGNALS, AND LATENCY
17
-
Use \`compress\` during work whenever a slice is summary-safe; do not wait for the user to send another message.
18
-
19
-
- no fixed threshold forces compression
20
-
- prioritize closedness and independence over raw range size
21
-
- qualitative signals still matter most (stale exploration, noisy tool bursts, resolved branches)
22
-
23
-
PREFER smaller, regular compressions OVER infrequent large compressions for better latency and better summary fidelity.
24
-
25
8
THE SUMMARY
26
9
Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings... EVERYTHING that maintains context integrity. This is not a brief note - it is an authoritative record so faithful that the original conversation adds no value.
27
10
28
11
USER INTENT FIDELITY
29
12
When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
30
13
Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
31
14
15
+
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
16
+
32
17
COMPRESSED BLOCK PLACEHOLDERS
33
18
When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
34
19
@@ -55,11 +40,9 @@ When you use compressed block placeholders, write the surrounding summary text s
55
40
56
41
- Treat each placeholder as a stand-in for a full conversation segment, not as a short label.
57
42
- Ensure transitions before and after each placeholder preserve chronology and causality.
58
-
- Do not write text that depends on the placeholder staying literal (for example, "as noted in (b2)").
43
+
- Do not write text that depends on the placeholder staying literal (for example, "as noted in \`(b2)\`").
59
44
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
60
45
61
-
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
62
-
63
46
THE WAYS OF COMPRESS
64
47
Compress when a range is genuinely closed and the raw conversation has served its purpose:
65
48
@@ -80,28 +63,21 @@ You cannot identify reliable boundaries yet
80
63
Before compressing, ask: _"Is this range closed enough to become summary-only right now?"_ Compression is irreversible. The summary replaces everything in the range.
81
64
82
65
BOUNDARY IDS
83
-
You specify boundaries by ID
84
-
85
-
Use the injected IDs visible in the conversation:
66
+
You specify boundaries by ID using the injected IDs visible in the conversation:
Each message has an ID inside XML metadata tags like \`<dcp-message-id>...</dcp-message-id>\`.
72
+
Treat these tags as boundary metadata only, not as tool result content.
73
+
90
74
Rules:
91
75
92
76
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
93
77
- IDs must exist in the current visible context.
94
78
- \`startId\` must appear before \`endId\`.
95
79
- Prefer boundaries that produce short, closed ranges.
96
-
97
-
ID SOURCES
98
-
99
-
- There is always an ID available for each message in XML tags like \`<dcp-message-id>...</dcp-message-id>\`.
100
-
- Compressed blocks are addressable by \`bN\` IDs.
101
-
102
-
Treat \`<dcp-message-id>...</dcp-message-id>\` as metadata only. It is not part of the tool result semantics.
103
-
104
-
Do not invent IDs. Use only IDs that are present in context.
80
+
- Do not invent IDs. Use only IDs that are present in context.
105
81
106
82
PARALLEL COMPRESS EXECUTION
107
83
When multiple independent ranges are ready and their boundaries do not overlap, launch MULTIPLE \`compress\` calls in parallel in a single response. This is the PREFERRED pattern over a single large-range compression when the work can be safely split. Run compression sequentially only when ranges overlap or when a later range depends on the result of an earlier compression.
You operate in a context-constrained environment. Manage context continuously to avoid buildup and preserve retrieval quality. Efficient context management is paramount for your agentic performance.
3
3
4
4
The ONLY tool you have for context management is \`compress\`. It replaces a contiguous portion of the conversation (inclusive) with a technical summary you produce.
@@ -16,27 +16,6 @@ CADENCE, SIGNALS, AND LATENCY
16
16
- Prefer smaller, regular compressions over infrequent massive compressions for better latency and summary quality
17
17
- When multiple independent stale ranges are ready, batch compressions in parallel
18
18
19
-
BOUNDARY MATCHING
20
-
\`compress\` uses inclusive ID boundaries via \`startId\` and \`endId\`. IDs are injected in context as message refs (\`mNNNN\`) and compressed block refs (\`bN\`).
21
-
22
-
Each message has an ID inside XML metadata tags like \`<dcp-message-id>...</dcp-message-id>\`.
23
-
Treat these tags as boundary metadata only, not as tool result content.
24
-
Similarly, \`<dcp-system-reminder>\` tags contain system-injected context management guidance. Treat them as metadata and do not echo them in your output.
25
-
26
-
Only choose IDs currently visible in context. Do not invent IDs.
27
-
28
-
RESPECT THE CHRONOLOGY OF THE RANGE
29
-
\`startId\` MUST refer to an item above/before \`endId\`
30
-
\`endId\` MUST refer to an item below/after \`startId\`
31
-
Always provide boundaries via the tool schema fields \`startId\` and \`endId\`.
32
-
33
-
THE SUMMARY STANDARD
34
-
Your summary MUST be technical and specific enough to preserve FULL understanding of what transpired, such that NO ambiguity remains about what asked, found, planned, done, or decided - yet noise free
35
-
36
-
When compressing ranges that include user messages, preserve user intent faithfully. Do not reinterpret or redirect the request. Directly quote short user messages when that is the most reliable way to preserve exact meaning.
37
-
38
-
Preserve key details: file paths, symbols, signatures, constraints, decisions, outcomes, commands, etc.. in order to produce a high fidelity, authoritative technical record
39
-
40
19
DO NOT COMPRESS IF
41
20
42
21
- raw context is still relevant and needed for edits or precise references
@@ -45,5 +24,4 @@ DO NOT COMPRESS IF
45
24
Evaluate conversation signal-to-noise REGULARLY. Use \`compress\` deliberately with quality-first summaries. Prefer multiple short, independent range compressions before considering broader ranges, and prioritize ranges intelligently to maintain a high-signal context window that supports your agency
46
25
47
26
It is of your responsibility to keep a sharp, high-quality context window for optimal performance
0 commit comments