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: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ For model-facing behavior (prompts and tool calls), this capability is always ad
30
30
31
31
### Tool
32
32
33
-
**Compress** — Exposes a single `compress` tool with one method: match a conversation range using `startString` and `endString`, then replace it with a technical summary.
33
+
**Compress** — Exposes a single `compress` tool with one method: select a conversation range using injected `startId` and `endId` (`mNNNN` or `bN`), then replace it with a technical summary.
34
34
35
35
The model can use that same method at different scales: tiny ranges for noise cleanup, focused ranges for preserving key findings, and full chapters for completed work.
Copy file name to clipboardExpand all lines: lib/prompts/compress.md
+41-30Lines changed: 41 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,29 @@ USER INTENT FIDELITY
31
31
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.
32
32
Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
33
33
34
+
COMPRESSED BLOCK PLACEHOLDERS
35
+
When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
36
+
37
+
-`{block_N}`
38
+
39
+
Rules:
40
+
41
+
- Include every required block placeholder exactly once.
42
+
- Do not invent placeholders for blocks outside the selected range.
43
+
- Treat `{block_N}` placeholders as RESERVED TOKENS. Do not emit `{block_N}` text anywhere except intentional placeholders.
44
+
- If you need to mention a block in prose, use plain text like `compressed bN` (without curly braces).
45
+
- Preflight check before finalizing: the set of `{block_N}` placeholders in your summary must exactly match the required set, with no duplicates.
46
+
47
+
These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
48
+
49
+
FLOW PRESERVATION WITH PLACEHOLDERS
50
+
When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
51
+
52
+
- Treat each placeholder as a stand-in for a full conversation segment, not as a short label.
53
+
- Ensure transitions before and after each placeholder preserve chronology and causality.
54
+
- Do not write text that depends on the placeholder staying literal (for example, "as noted in {block_2}").
55
+
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
56
+
34
57
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.
35
58
36
59
THE WAYS OF COMPRESS
@@ -43,7 +66,7 @@ Exploration exhausted and patterns understood
43
66
Compress smaller ranges when:
44
67
You need to discard dead-end noise without waiting for a whole chapter to close
45
68
You need to preserve key findings from a narrow slice while freeing context quickly
46
-
You can bound a stale range cleanly with unique boundaries
69
+
You can bound a stale range cleanly with injected IDs
47
70
48
71
Do NOT compress when:
49
72
You may need exact code, error messages, or file contents from the range in the immediate next steps
@@ -52,40 +75,28 @@ You cannot identify reliable boundaries yet
52
75
53
76
Before compressing, ask: _"Is this range closed enough to become summary-only right now?"_ Compression is irreversible. The summary replaces everything in the range.
54
77
55
-
BOUNDARY MATCHING
56
-
You specify boundaries by matching unique text strings in the conversation. CRITICAL: In code-centric conversations, strings repeat often. Provide sufficiently unique text to match exactly once. Be conservative and choose longer, highly specific boundaries when in doubt. If a match fails (not found or found multiple times), the tool will error - extend your boundary string with more surrounding context in order to make SURE the tool does NOT error.
57
-
58
-
WHERE TO PICK STRINGS FROM (important for reliable matching):
59
-
60
-
- Your own assistant text responses (MOST RELIABLE - always stored verbatim)
61
-
- The user's own words in their messages
62
-
- Tool result output text (distinctive substrings within the output)
63
-
- Previous compress summaries
64
-
- Tool input string values (LEAST RELIABLE - only single concrete field values, not keys or schema fields, may be transformed by AI SDK)
65
-
66
-
NEVER USE GENERIC OR REPEATING STRINGS:
78
+
BOUNDARY IDS
79
+
You specify boundaries by ID
67
80
68
-
Tool status messages repeat identically across every invocation. These are ALWAYS ambiguous:
81
+
Use the injected IDs visible in the conversation:
69
82
70
-
- "Edit applied successfully." (appears in EVERY successful edit)
71
-
- "File written successfully" or any tool success/error boilerplate
72
-
- Common tool output patterns that are identical across calls
83
+
-`mNNNN` IDs identify raw messages
84
+
-`bN` IDs identify previously compressed blocks
73
85
74
-
Instead, combine the generic output with surrounding unique context (a file path, a specific code snippet, or your own unique assistant text).
86
+
Rules:
75
87
76
-
Each boundary string you choose MUST be unique to ONE specific message. Before using a string, ask: "Could this exact text appear in any other place in this conversation?" If yes, extend it or pick a different string.
88
+
- Pick `startId` and `endId` directly from injected IDs in context.
89
+
- IDs must exist in the current visible context.
90
+
-`startId` must appear before `endId`.
91
+
- Prefer boundaries that produce short, closed ranges.
77
92
78
-
WHERE TO NEVER PICK STRINGS FROM:
93
+
ID SOURCES
79
94
80
-
-`<system-reminder>` tags or any XML wrapper/meta-commentary around messages
- File/directory listing framing text (e.g. "Called the Read tool with the following input...")
84
-
- Strings that span across message or part boundaries
85
-
- Entire serialized JSON objects (key ordering may differ - pick a distinctive substring within instead)
95
+
- User messages include a text marker with their `mNNNN` ID.
96
+
- Assistant messages include a `context_info` tool marker with their `mNNNN` ID.
97
+
- Compressed blocks are addressable by `bN` IDs.
86
98
87
-
CRITICAL: AVOID USING TOOL INPUT VALUES
88
-
NEVER use tool input schema keys or field names as boundary strings (e.g., "startString", "endString", "filePath", "content"). These may be transformed by the AI SDK and are not reliable. The ONLY acceptable use of tool input strings is a SINGLE concrete field VALUE (not the key), and even then, prefer using assistant text, user messages, or tool result outputs instead. When in doubt, choose boundaries from your own assistant responses or distinctive user message content.
99
+
Do not invent IDs. Use only IDs that are present in context.
89
100
90
101
PARALLEL COMPRESS EXECUTION
91
102
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.
@@ -96,8 +107,8 @@ THE FORMAT OF COMPRESS
96
107
{
97
108
topic: string, // Short label (3-5 words) - e.g., "Auth System Exploration"
98
109
content: {
99
-
startString: string, // Unique text string marking the beginning of the range
100
-
endString: string, // Unique text string marking the end of the range
110
+
startId: string, // Boundary ID at range start: mNNNN or bN
111
+
endId: string, // Boundary ID at range end: mNNNN or bN
101
112
summary: string // Complete technical summary replacing all content in the range
Copy file name to clipboardExpand all lines: lib/prompts/nudge.md
+1-4Lines changed: 1 addition & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,10 +31,7 @@ Do not jump to a single broad range when the same cleanup can be done safely wit
31
31
32
32
If you are performing a critical atomic operation, do not interrupt it, but make sure to perform context management rapidly
33
33
34
-
BE VERY MINDFUL of the startString and endString you use for compression for RELIABLE boundary matching. NEVER use generic tool outputs like "Edit applied successfully." or generic status message as boundaries. Use unique assistant text or distinctive content instead with enough surrounding context to ensure uniqueness.
35
-
36
-
CRITICAL: AVOID USING TOOL INPUT VALUES AS BOUNDARIES
37
-
NEVER use tool input schema keys or field names. The ONLY acceptable use of tool input strings is a SINGLE concrete field VALUE (not the key), and even then, prefer assistant text, user messages, or tool result outputs instead.
34
+
Use injected boundary IDs for compression (`mNNNN` for messages, `bN` for compressed blocks). Pick IDs that are visible in context and ensure `startId` appears before `endId`.
38
35
39
36
Ensure your summaries are inclusive of all parts of the range.
40
37
If the compressed range includes user messages, preserve user intent exactly. Prefer direct quotes for short user messages to avoid semantic drift.
0 commit comments