Skip to content

Commit cc14f82

Browse files
prompt rewrite
1 parent 2699f7b commit cc14f82

4 files changed

Lines changed: 27 additions & 58 deletions

File tree

lib/prompts/compress.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Use this tool to collapse a contiguous range of conversation into a preserved summary.
1+
Your only tool for context management, use it to collapse a range in the conversation into a detailed summary
22

33
THE PHILOSOPHY OF COMPRESS
44
`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.
@@ -39,7 +39,7 @@ BOUNDARY MATCHING
3939
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. 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.
4040

4141
WHERE TO PICK STRINGS FROM (important for reliable matching):
42-
42+
- `muid` and `uid` strings in message and tool output annotations (MOST RELIABLE - guaranteed unique)
4343
- Your own assistant text responses (MOST RELIABLE - always stored verbatim)
4444
- The user's own words in their messages
4545
- Tool result output text (distinctive substrings within the output)

lib/prompts/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function renderSystemPrompt(flags?: ToolFlags): string {
4848

4949
export function renderNudge(mode: NudgeMode = "frequency"): string {
5050
if (mode === "context-limit") {
51-
return extractInstruction(NUDGE, "context_limit_reached")
51+
return extractInstruction(NUDGE, "context_buildup_warning")
5252
}
5353

5454
return extractInstruction(NUDGE, "context_management_required")

lib/prompts/nudge.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@ NOISE REMOVAL: If you read files or ran commands that yielded no value, compress
1313
PHASE COMPLETION: If a chapter is complete, compress the entire sequence into a detailed technical summary with unambiguous outcomes.
1414
</instruction>
1515

16-
<instruction name=context_limit_reached>
17-
CRITICAL CONTEXT LIMIT
18-
Your session context has exceeded the configured limit. Strict adherence to context compression is required.
16+
<instruction name=context_buildup_warning>
17+
The context window is filling-up. You've reached a point where performance may increasingly degrade. Active context management is now strategically relevant. Mind your context footprint as the conversation grows
1918

20-
PROTOCOL
21-
You should prioritize context management, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.
22-
23-
IMMEDIATE ACTION REQUIRED
24-
PHASE COMPLETION: If a phase is complete, compress the entire sequence now.
19+
Avoid unnecessary context build-up with targeted uses of the `compress` tool. Start with low hanging fruits and clearly identified ranges that can be compressed with minimal risk of losing critical information. Look BACK on the conversation history and avoid compressing the newest ranges until you have exhausted older ones
2520

26-
KNOWLEDGE PRESERVATION: If no full chapter is closed yet, compress smaller closed ranges with high-fidelity summaries to preserve critical findings.
21+
If you are performing a critical atomic operation, do not interrupt it, but make sure to perform context management rapidly
2722

28-
NOISE REMOVAL: Compress clearly irrelevant or superseded ranges first to recover context quickly.
23+
Be mindful of the startString and endString you use for compression and prefer using `muid` and `uid` strings for reliable boundary matching. Ensure your summaries are inclusive of all parts of the range.
2924
</instruction>

lib/prompts/system.md

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,34 @@
11
<system-reminder>
2-
<instruction name=context_management_protocol policy_level=critical>
3-
You operate a context-constrained environment and MUST PROACTIVELY MANAGE IT TO AVOID CONTEXT ROT. Efficient context management is CRITICAL to maintaining performance and ensuring successful task completion.
2+
<instruction name=compress_tool attention_level=high>
3+
You operate a context-constrained environment and MUST MANAGE IT to avoid bad context buildup and eventual leak. Efficient context management is paramount for your agentic performance, retrieval capacity and overall system health.
44

5-
AVAILABLE TOOL FOR CONTEXT MANAGEMENT
6-
`compress`: squash contiguous portions of conversation and replace them with low-level technical summaries.
5+
The ONLY tool you have for context management is `compress` which squashes a contiguous portion of the conversation (inclusive) into a low-level technical summary you are to produce.
76

8-
THE PHILOSOPHY OF COMPRESSION
9-
`compress` is your unified context-management instrument.
7+
THE PHILOSOPHY BEHIND COMPRESSION
8+
Compression can operate at various scales. The method is the same regardless of range size, but strategic use case differs.
109

11-
Use it at multiple scales:
10+
MICRO: ideal for low-latency noise disposal
11+
MESO: good to filter signal from noise of heavy tool outputs or decluttering the session from closed/resolved investigation paths
12+
MACRO: for completed phases, distilling entire chapters of conversation
1213

13-
- micro-compression for disposable noise
14-
- meso-compression for closed investigation slices
15-
- chapter-compression for completed phases
14+
A strategic and regular use of the `compress` tool is encouraged to maintain a focused context. Be proactive and deliberate in managing your context.
1615

17-
The method stays the same; the range changes.
16+
BOUNDARY MATCHING
17+
`compress` uses inclusive string boundaries, matching a string at the start of a message or tool output will consume the entire item. User messages are annotated with `muid`, tool outputs with `uid`, and are intended for you to use as startString and endString anchors to avoid any potential mismatch errors. You can also use unique text from your own reasoning or text outputs, but be sure to provide more than enough surrounding context to ensure a unique match. The preferred way to match is still to use `muid` and `uid` strings.
1818

1919
THE SUMMARY STANDARD
20-
Your summary MUST be technical and specific enough to preserve FULL understanding of WHAT TRANSPIRED, such that NO AMBIGUITY remains about what was done, found, or decided.
21-
22-
Preserve key details: symbols, signatures, constraints, decisions, outcomes, file paths, and why choices were made.
23-
24-
Yet be lean: remove dead-end chatter, redundant outputs, and repeated back-and-forth.
25-
26-
WHEN TO COMPRESS
27-
Use compression aggressively for:
20+
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
2821

29-
- irrelevant/noisy exploration that no longer serves the task
30-
- stale outputs superseded by newer outputs
31-
- completed work phases that can be replaced by an authoritative technical record
22+
Preserve key details: file paths, symbols, signatures, constraints, decisions, outcomes... in order to produce a high fidelity, authoritative technical record
3223

33-
Do NOT compress when:
24+
SAFEGUARDS
25+
Do NOT compress if
26+
raw context is still relevant and needed for edits or precise references
27+
the task in the target range is still actively in progress
3428

35-
- exact raw text is still needed for imminent edits or precise references
36-
- the target range is still actively in progress and likely to be revisited immediately
37-
38-
Before compressing, ask: _"Is this range closed enough to become summary-only?"_
39-
40-
BOUNDARY MATCHING
41-
Compression uses string boundaries. In code-heavy sessions, text repeats often. Match conservatively with sufficiently unique `startString` and `endString` values to avoid mismatch errors.
29+
EVALUATE THE CONVERSATION SIGNAL TO NOISE RATIO REGULARLY AND USE `compress` PROACTIVELY. PARALLELIZE COMPRESSION WHEN POSSIBLE. BEFORE COMPRESSING, CONSIDER YOUR RANGE OPTIONS AND PRIORITIZE INTELLIGENTLY.
4230

43-
TIMING
44-
Prefer managing context at the START of a new loop (after receiving a user message) rather than at the END of your previous turn. At turn start, you can better judge relevance versus noise.
45-
46-
EVALUATE YOUR CONTEXT AND MANAGE REGULARLY TO AVOID CONTEXT ROT. AVOID USING CONTEXT MANAGEMENT AS THE ONLY TOOL ACTION IN YOUR RESPONSE; PARALLELIZE WITH OTHER RELEVANT TOOLS TO TASK CONTINUATION (read, edit, bash...).
47-
48-
When multiple non-overlapping stale ranges are ready, issue MULTIPLE `compress` calls in parallel in the same response. Run compression sequentially only when ranges overlap or a later boundary depends on an earlier compression result.
49-
50-
The session is your responsibility. Be PROACTIVE, DELIBERATE, and STRATEGIC. Keep context clean, relevant, and high-quality.
31+
The context health is your responsibility, keep it clean, focused, and high-quality by being deliberate and strategic with your `compress` tool use.
5132
</instruction>
5233

5334
<manual><instruction name=manual_mode policy_level=critical>
@@ -58,11 +39,4 @@ Manual mode is enabled. Do NOT use compress unless the user has explicitly trigg
5839
After completing a manually triggered context-management action, STOP IMMEDIATELY. Do NOT continue with any task execution. End your response right after the tool use completes and wait for the next user input.
5940
</instruction></manual>
6041

61-
<instruction name=injected_context_handling policy_level=critical>
62-
This environment may inject a `<context-pressure-tools>` list containing tool outputs currently occupying context budget.
63-
64-
Use this list as forced attention for deciding what to compress next. Prioritize high-token entries and stale/noise-heavy entries.
65-
66-
This list is advisory context, not a strict command format.
67-
</instruction>
6842
</system-reminder>

0 commit comments

Comments
 (0)