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
Optimize AI prompt by minimizing message structure
- Add minimizeMessages() function to strip unnecessary data from messages
- Remove step markers that add no value for analysis
- Keep only essential tool call information (callID, tool, output, minimal input)
- Summarize batch operations instead of including full arrays
- Reduces token usage significantly while preserving analysis accuracy
? `- NEVER prune the following protected tools: ${protectedTools.join(", ")}\n`
79
+
constprotectedToolsText=protectedTools.length>0
80
+
? `- NEVER prune tool calls from these protected tools: ${protectedTools.join(", ")}\n`
4
81
: '';
5
-
82
+
83
+
// Minimize messages to reduce token usage
84
+
constminimizedMessages=minimizeMessages(messages)
85
+
6
86
return`You are a conversation analyzer that identifies obsolete tool outputs in a coding session.
7
87
8
88
Your task: Analyze the session history and identify tool call IDs whose outputs are NO LONGER RELEVANT to the current conversation context.
@@ -15,19 +95,19 @@ Guidelines for identifying obsolete tool calls:
15
95
5. Tool calls whose information has been replaced by more recent operations
16
96
17
97
DO NOT prune:
18
-
${protectedToolsText}- Recent tool calls
98
+
${protectedToolsText}
19
99
- Tool calls that modified state (edits, writes, etc.)
20
100
- Tool calls whose outputs are actively being discussed
21
101
- Tool calls that produced errors still being debugged
22
102
- Tool calls where the user explicitly indicated they want to retain the information (e.g., "save this", "remember this", "keep this for later", "don't output anything else but save this")
23
103
- Tool calls that are the MOST RECENT activity in the conversation (these may be intended for future use)
24
104
25
-
IMPORTANT: Available tool call IDs for analysis (duplicates already removed): ${unprunedToolCallIds.join(", ")}
105
+
IMPORTANT: Available tool call IDs for analysis: ${unprunedToolCallIds.join(", ")}
26
106
27
-
You may see additional tool call IDs in the session history below, but those have already been handled by automatic deduplication. ONLY return IDs from the available list above.
107
+
You may see additional tool call IDs in the session history below, but those have already been pruned (either by automatic deduplication or previous analysis runs) and their outputs replaced with placeholders. ONLY return IDs from the available list above.
28
108
29
109
Session history:
30
-
${JSON.stringify(messages,null,2)}
110
+
${JSON.stringify(minimizedMessages,null,2)}
31
111
32
112
You MUST respond with valid JSON matching this exact schema:
0 commit comments