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
{{ message }}
Repository navigation
Commit 204dd20
Browse filesBrowse the repository at this point in the historyBrowse files
constCOMPACT_PROMPT_BASE=`Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
13
-
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
14
-
15
-
Before providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:
16
-
17
-
1. Chronologically analyze each message and section of the conversation. For each section thoroughly identify:
18
-
- The user's explicit requests and intents
19
-
- Your approach to addressing the user's requests
20
-
- Key decisions, technical concepts and code patterns
21
-
- Specific details like:
22
-
- file names
23
-
- full code snippets
24
-
- function signatures
25
-
- file edits
26
-
- Errors that you ran into and how you fixed them
27
-
- Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
28
-
2. Double-check for technical accuracy and completeness, addressing each required element thoroughly.
29
-
30
-
Your summary should include the following sections:
31
-
32
-
1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail
33
-
2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.
34
-
3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.
35
-
4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.
36
-
5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.
37
-
6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent.
38
-
6. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.
39
-
7. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
40
-
8. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
41
-
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
42
-
43
-
Here's an example of how your output should be structured:
44
-
45
-
<example>
46
-
<analysis>
47
-
[Your thought process, ensuring all points are covered thoroughly and accurately]
48
-
</analysis>
49
-
50
-
<summary>
51
-
1. Primary Request and Intent:
52
-
[Detailed description]
53
-
54
-
2. Key Technical Concepts:
55
-
- [Concept 1]
56
-
- [Concept 2]
57
-
- [...]
58
-
59
-
3. Files and Code Sections:
60
-
- [File Name 1]
61
-
- [Summary of why this file is important]
62
-
- [Summary of the changes made to this file, if any]
63
-
- [Important Code Snippet]
64
-
- [File Name 2]
65
-
- [Important Code Snippet]
66
-
- [...]
67
-
68
-
4. Errors and fixes:
69
-
- [Detailed description of error 1]:
70
-
- [How you fixed the error]
71
-
- [User feedback on the error if any]
72
-
- [...]
73
-
74
-
5. Problem Solving:
75
-
[Description of solved problems and ongoing troubleshooting]
76
-
77
-
6. All user messages:
78
-
- [Detailed non tool use user message]
79
-
- [...]
80
-
81
-
7. Pending Tasks:
82
-
- [Task 1]
83
-
- [Task 2]
84
-
- [...]
85
-
86
-
8. Current Work:
87
-
[Precise description of current work]
88
-
89
-
9. Optional Next Step:
90
-
[Optional Next step to take]
91
-
92
-
</summary>`;
11
+
constSUMMARY_OPEN_TAG="<compacted-summary>";
12
+
constSUMMARY_CLOSE_TAG="</compacted-summary>";
13
+
14
+
/**
15
+
* The summarization directive, delivered as the FINAL user message after the
16
+
* replayed conversation rather than as a distinct summarizer system prompt.
17
+
* Keeping the conversation's own system prompt, tools, and message prefix in
18
+
* front of it makes the auxiliary call a genuine prefix of the last routed
19
+
* request, so the provider's KV cache is reused instead of invalidated.
20
+
*/
21
+
exportconstCOMPACTION_INSTRUCTION=[
22
+
"You are now acting as a compaction engine for this AI coding assistant. Condense the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context.",
23
+
"",
24
+
'Output EXACTLY the Markdown structure below: keep every section, in order. Use terse bullets, not prose paragraphs. Write "(none)" for an empty section — never drop a section.',
25
+
"",
26
+
"## Primary Request and Intent",
27
+
"- [the user's original and evolving goals; quote verbatim where the exact wording matters]",
28
+
"",
29
+
"## Key Technical Concepts",
30
+
"- [technologies, frameworks, patterns, and conventions in play]",
31
+
"",
32
+
"## Files and Code",
33
+
"- [exact path: why it matters, key changes or snippets]",
34
+
"",
35
+
"## Errors and Fixes",
36
+
"- [error: how it was resolved, plus any related user feedback]",
37
+
"",
38
+
"## Pending Jobs",
39
+
"- [explicitly requested work not yet completed]",
40
+
"",
41
+
"## Current Work",
42
+
"- [precisely what was in progress at this checkpoint]",
43
+
"",
44
+
"## Next Step",
45
+
'- [the single next action, directly in line with the most recent request, or "(none)"]',
46
+
"",
47
+
"## Critical Context",
48
+
"- [decisions and their rationale, constraints, user preferences, open questions, data needed to continue]",
49
+
"",
50
+
"Rules:",
51
+
"- Write concise English engineering prose. Preserve exact file paths, commands, error strings, identifiers, numeric values, function signatures, and syntax fragments.",
52
+
"- Capture user feedback and explicit instructions faithfully, especially corrections.",
53
+
"- Do NOT mention this summarization request or that the context was compacted.",
54
+
"- Output only the checkpoint text: do not call any tool or take any other action.",
55
+
`- If the conversation already contains a ${SUMMARY_OPEN_TAG} block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts, drop stale ones, and merge newer information into a single consolidated summary under the same structure.`,
56
+
].join("\n");
57
+
58
+
/** Framing that makes the replacement user message established context. */
59
+
exportconstCHECKPOINT_PREAMBLE=
60
+
"This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.";
93
61
94
62
constSYSTEM_PROMPT_BASE=`You are a helpful software engineer assistant.`;
95
63
@@ -293,20 +261,12 @@ export function getSystemPrompt(_projectRoot: string, options: PromptToolOptions
293
261
returntoolDocs ? `${SYSTEM_PROMPT_BASE}\n\n# Available Tools\n\n${toolDocs}` : SYSTEM_PROMPT_BASE;
0 commit comments