@tarquinen/opencode-dcp 1.1.0-beta.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +6 -3
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/messages/prune.d.ts.map +1 -1
  5. package/dist/lib/messages/prune.js +36 -81
  6. package/dist/lib/messages/prune.js.map +1 -1
  7. package/dist/lib/messages/utils.d.ts +2 -0
  8. package/dist/lib/messages/utils.d.ts.map +1 -1
  9. package/dist/lib/messages/utils.js +65 -0
  10. package/dist/lib/messages/utils.js.map +1 -1
  11. package/dist/lib/prompts/{system → assistant/system}/system-prompt-both.txt +5 -4
  12. package/dist/lib/prompts/{system → assistant/system}/system-prompt-discard.txt +2 -0
  13. package/dist/lib/prompts/{system → assistant/system}/system-prompt-extract.txt +2 -0
  14. package/dist/lib/prompts/discard-tool-spec.txt +11 -26
  15. package/dist/lib/prompts/extract-tool-spec.txt +18 -50
  16. package/dist/lib/prompts/user/nudge/nudge-both.txt +10 -0
  17. package/dist/lib/prompts/user/nudge/nudge-discard.txt +9 -0
  18. package/dist/lib/prompts/user/nudge/nudge-extract.txt +9 -0
  19. package/dist/lib/prompts/user/system/system-prompt-both.txt +58 -0
  20. package/dist/lib/prompts/user/system/system-prompt-discard.txt +49 -0
  21. package/dist/lib/prompts/user/system/system-prompt-extract.txt +49 -0
  22. package/dist/lib/strategies/tools.js +5 -5
  23. package/dist/lib/strategies/tools.js.map +1 -1
  24. package/package.json +1 -1
  25. /package/dist/lib/prompts/{nudge → assistant/nudge}/nudge-both.txt +0 -0
  26. /package/dist/lib/prompts/{nudge → assistant/nudge}/nudge-discard.txt +0 -0
  27. /package/dist/lib/prompts/{nudge → assistant/nudge}/nudge-extract.txt +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AASjD,QAAA,MAAM,MAAM,EAAE,MAuGK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AASjD,QAAA,MAAM,MAAM,EAAE,MA2GK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
package/dist/index.js CHANGED
@@ -33,15 +33,18 @@ const plugin = (async (ctx) => {
33
33
  "experimental.chat.system.transform": async (_input, output) => {
34
34
  const discardEnabled = config.tools.discard.enabled;
35
35
  const extractEnabled = config.tools.extract.enabled;
36
+ // Use user-role prompts for reasoning models (second person),
37
+ // assistant-role prompts for non-reasoning models (first person)
38
+ const roleDir = state.isReasoningModel ? "user" : "assistant";
36
39
  let promptName;
37
40
  if (discardEnabled && extractEnabled) {
38
- promptName = "system/system-prompt-both";
41
+ promptName = `${roleDir}/system/system-prompt-both`;
39
42
  }
40
43
  else if (discardEnabled) {
41
- promptName = "system/system-prompt-discard";
44
+ promptName = `${roleDir}/system/system-prompt-discard`;
42
45
  }
43
46
  else if (extractEnabled) {
44
- promptName = "system/system-prompt-extract";
47
+ promptName = `${roleDir}/system/system-prompt-extract`;
45
48
  }
46
49
  else {
47
50
  return;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,E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,UAAU,SAAS,EAAE,KACtB,IA6FF,CAAA;AAED,eAAO,MAAM,KAAK,GACd,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,QAAQ,YAAY,EACpB,UAAU,SAAS,EAAE,KACtB,IAGF,CAAA"}
1
+ {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAuG7C,eAAO,MAAM,sBAAsB,GAC/B,OAAO,YAAY,EACnB,QAAQ,YAAY,EACpB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,KACtB,IA8CF,CAAA;AAED,eAAO,MAAM,KAAK,GACd,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,QAAQ,YAAY,EACpB,UAAU,SAAS,EAAE,KACtB,IAGF,CAAA"}
@@ -1,27 +1,32 @@
1
1
  import { loadPrompt } from "../prompt";
2
- import { extractParameterKey, buildToolIdList } from "./utils";
2
+ import { extractParameterKey, buildToolIdList, createSyntheticUserMessage, createSyntheticAssistantMessage, } from "./utils";
3
3
  import { getLastAssistantMessage, getLastUserMessage, isMessageCompacted } from "../shared-utils";
4
- const PRUNED_TOOL_INPUT_REPLACEMENT = "[Input removed to save context]";
4
+ const PRUNED_TOOL_INPUT_REPLACEMENT = "[content removed to save context, this is not what was written to the file, but a placeholder]";
5
5
  const PRUNED_TOOL_OUTPUT_REPLACEMENT = "[Output removed to save context - information superseded or no longer needed]";
6
- const getNudgeString = (config) => {
6
+ const getNudgeString = (config, isReasoningModel) => {
7
7
  const discardEnabled = config.tools.discard.enabled;
8
8
  const extractEnabled = config.tools.extract.enabled;
9
+ const roleDir = isReasoningModel ? "user" : "assistant";
9
10
  if (discardEnabled && extractEnabled) {
10
- return loadPrompt("nudge/nudge-both");
11
+ return loadPrompt(`${roleDir}/nudge/nudge-both`);
11
12
  }
12
13
  else if (discardEnabled) {
13
- return loadPrompt("nudge/nudge-discard");
14
+ return loadPrompt(`${roleDir}/nudge/nudge-discard`);
14
15
  }
15
16
  else if (extractEnabled) {
16
- return loadPrompt("nudge/nudge-extract");
17
+ return loadPrompt(`${roleDir}/nudge/nudge-extract`);
17
18
  }
18
19
  return "";
19
20
  };
20
- const wrapPrunableTools = (content) => `<prunable-tools>
21
+ const wrapPrunableToolsUser = (content) => `<prunable-tools>
22
+ The following tools have been invoked and are available for pruning. This list does not mandate immediate action. Consider your current goals and the resources you need before discarding valuable tool inputs or outputs. Consolidate your prunes for efficiency; it is rarely worth pruning a single tiny tool output. Keep the context free of noise.
23
+ ${content}
24
+ </prunable-tools>`;
25
+ const wrapPrunableToolsAssistant = (content) => `<prunable-tools>
21
26
  I have the following tool outputs available for pruning. I should consider my current goals and the resources I need before discarding valuable inputs or outputs. I should consolidate prunes for efficiency; it is rarely worth pruning a single tiny tool output.
22
27
  ${content}
23
28
  </prunable-tools>`;
24
- const getCooldownMessage = (config) => {
29
+ const getCooldownMessage = (config, isReasoningModel) => {
25
30
  const discardEnabled = config.tools.discard.enabled;
26
31
  const extractEnabled = config.tools.extract.enabled;
27
32
  let toolName;
@@ -34,15 +39,11 @@ const getCooldownMessage = (config) => {
34
39
  else {
35
40
  toolName = "extract tool";
36
41
  }
37
- return `<prunable-tools>
38
- I just performed context management. I will not use the ${toolName} again until after my next tool use, when a fresh list will be available.
39
- </prunable-tools>`;
42
+ const message = isReasoningModel
43
+ ? `Context management was just performed. Do not use the ${toolName} again. A fresh list will be available after your next tool use.`
44
+ : `I just performed context management. I will not use the ${toolName} again until after my next tool use, when a fresh list will be available.`;
45
+ return `<prunable-tools>\n${message}\n</prunable-tools>`;
40
46
  };
41
- const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345";
42
- const SYNTHETIC_PART_ID = "prt_01234567890123456789012345";
43
- const SYNTHETIC_USER_MESSAGE_ID = "msg_01234567890123456789012346";
44
- const SYNTHETIC_USER_PART_ID = "prt_01234567890123456789012346";
45
- const REASONING_MODEL_USER_MESSAGE_CONTENT = "<system-context-injection/>";
46
47
  const buildPrunableToolsList = (state, config, logger, messages) => {
47
48
  const lines = [];
48
49
  const toolIdList = buildToolIdList(state, messages, logger);
@@ -72,20 +73,19 @@ const buildPrunableToolsList = (state, config, logger, messages) => {
72
73
  if (lines.length === 0) {
73
74
  return "";
74
75
  }
75
- return wrapPrunableTools(lines.join("\n"));
76
+ const wrapFn = state.isReasoningModel ? wrapPrunableToolsUser : wrapPrunableToolsAssistant;
77
+ return wrapFn(lines.join("\n"));
76
78
  };
77
79
  export const insertPruneToolContext = (state, config, logger, messages) => {
78
80
  if (!config.tools.discard.enabled && !config.tools.extract.enabled) {
79
81
  return;
80
82
  }
81
- const lastAssistantMessage = getLastAssistantMessage(messages);
82
- if (!lastAssistantMessage) {
83
- return;
84
- }
83
+ // For reasoning models, inject into user role; for non-reasoning, inject into assistant role
84
+ const isReasoningModel = state.isReasoningModel;
85
85
  let prunableToolsContent;
86
86
  if (state.lastToolPrune) {
87
87
  logger.debug("Last tool was prune - injecting cooldown message");
88
- prunableToolsContent = getCooldownMessage(config);
88
+ prunableToolsContent = getCooldownMessage(config, isReasoningModel);
89
89
  }
90
90
  else {
91
91
  const prunableToolsList = buildPrunableToolsList(state, config, logger, messages);
@@ -97,64 +97,23 @@ export const insertPruneToolContext = (state, config, logger, messages) => {
97
97
  if (config.tools.settings.nudgeEnabled &&
98
98
  state.nudgeCounter >= config.tools.settings.nudgeFrequency) {
99
99
  logger.info("Inserting prune nudge message");
100
- nudgeString = "\n" + getNudgeString(config);
100
+ nudgeString = "\n" + getNudgeString(config, isReasoningModel);
101
101
  }
102
102
  prunableToolsContent = prunableToolsList + nudgeString;
103
103
  }
104
- const assistantInfo = lastAssistantMessage.info;
105
- const assistantMessage = {
106
- info: {
107
- id: SYNTHETIC_MESSAGE_ID,
108
- sessionID: assistantInfo.sessionID,
109
- role: "assistant",
110
- parentID: assistantInfo.parentID,
111
- modelID: assistantInfo.modelID,
112
- providerID: assistantInfo.providerID,
113
- time: { created: Date.now() },
114
- tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
115
- cost: 0,
116
- path: assistantInfo.path,
117
- mode: assistantInfo.mode,
118
- },
119
- parts: [
120
- {
121
- id: SYNTHETIC_PART_ID,
122
- sessionID: assistantInfo.sessionID,
123
- messageID: SYNTHETIC_MESSAGE_ID,
124
- type: "text",
125
- text: prunableToolsContent,
126
- },
127
- ],
128
- };
129
- messages.push(assistantMessage);
130
- // For reasoning models, append a synthetic user message to close the assistant turn.
131
- if (state.isReasoningModel) {
132
- const lastRealUserMessage = getLastUserMessage(messages);
133
- const userMessageInfo = lastRealUserMessage?.info;
134
- const userMessage = {
135
- info: {
136
- id: SYNTHETIC_USER_MESSAGE_ID,
137
- sessionID: assistantInfo.sessionID,
138
- role: "user",
139
- time: { created: Date.now() + 1 },
140
- agent: userMessageInfo?.agent ?? "code",
141
- model: userMessageInfo?.model ?? {
142
- providerID: assistantInfo.providerID,
143
- modelID: assistantInfo.modelID,
144
- },
145
- },
146
- parts: [
147
- {
148
- id: SYNTHETIC_USER_PART_ID,
149
- sessionID: assistantInfo.sessionID,
150
- messageID: SYNTHETIC_USER_MESSAGE_ID,
151
- type: "text",
152
- text: REASONING_MODEL_USER_MESSAGE_CONTENT,
153
- },
154
- ],
155
- };
156
- messages.push(userMessage);
157
- logger.debug("Appended synthetic user message for reasoning model");
104
+ if (isReasoningModel) {
105
+ const lastUserMessage = getLastUserMessage(messages);
106
+ if (!lastUserMessage) {
107
+ return;
108
+ }
109
+ messages.push(createSyntheticUserMessage(lastUserMessage, prunableToolsContent));
110
+ }
111
+ else {
112
+ const lastAssistantMessage = getLastAssistantMessage(messages);
113
+ if (!lastAssistantMessage) {
114
+ return;
115
+ }
116
+ messages.push(createSyntheticAssistantMessage(lastAssistantMessage, prunableToolsContent));
158
117
  }
159
118
  };
160
119
  export const prune = (state, logger, config, messages) => {
@@ -173,7 +132,6 @@ const pruneToolOutputs = (state, logger, messages) => {
173
132
  if (!state.prune.toolIds.includes(part.callID)) {
174
133
  continue;
175
134
  }
176
- // Skip write and edit tools - their inputs are pruned instead
177
135
  if (part.tool === "write" || part.tool === "edit") {
178
136
  continue;
179
137
  }
@@ -192,15 +150,12 @@ const pruneToolInputs = (state, logger, messages) => {
192
150
  if (!state.prune.toolIds.includes(part.callID)) {
193
151
  continue;
194
152
  }
195
- // Only prune inputs for write and edit tools
196
153
  if (part.tool !== "write" && part.tool !== "edit") {
197
154
  continue;
198
155
  }
199
- // Don't prune yet if tool is still pending or running
200
156
  if (part.state.status === "pending" || part.state.status === "running") {
201
157
  continue;
202
158
  }
203
- // Write tool has content field, edit tool has oldString/newString fields
204
159
  if (part.tool === "write" && part.state.input?.content !== undefined) {
205
160
  part.state.input.content = PRUNED_TOOL_INPUT_REPLACEMENT;
206
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prune.js","sourceRoot":"","sources":["../../../lib/messages/prune.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGjG,MAAM,6BAA6B,GAAG,iCAAiC,CAAA;AACvE,MAAM,8BAA8B,GAChC,+EAA+E,CAAA;AACnF,MAAM,cAAc,GAAG,CAAC,MAAoB,EAAU,EAAE;IACpD,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IACnD,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IAEnD,IAAI,cAAc,IAAI,cAAc,EAAE,CAAC;Q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K,CAAC,SAAS,GAAG,6BAA6B,CAAA;gBAC9D,CAAC;gBACD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;oBAC5C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,6BAA6B,CAAA;gBAC9D,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import { Logger } from "../logger";
2
2
  import type { SessionState, WithParts } from "../state";
3
+ export declare const createSyntheticUserMessage: (baseMessage: WithParts, content: string) => WithParts;
4
+ export declare const createSyntheticAssistantMessage: (baseMessage: WithParts, content: string) => WithParts;
3
5
  /**
4
6
  * Extracts a human-readable key from tool metadata for display purposes.
5
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEvD;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,EAAE,YAAY,GAAG,KAAG,MAkEnE,CAAA;AAED,wBAAgB,eAAe,CAC3B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,MAAM,GACf,MAAM,EAAE,CAeV"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAMvD,eAAO,MAAM,0BAA0B,GAAI,aAAa,SAAS,EAAE,SAAS,MAAM,KAAG,SAwBpF,CAAA;AAED,eAAO,MAAM,+BAA+B,GACxC,aAAa,SAAS,EACtB,SAAS,MAAM,KAChB,SA0BF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,EAAE,YAAY,GAAG,KAAG,MA6EnE,CAAA;AAED,wBAAgB,eAAe,CAC3B,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,MAAM,GACf,MAAM,EAAE,CAeV"}
@@ -1,4 +1,58 @@
1
1
  import { isMessageCompacted } from "../shared-utils";
2
+ const SYNTHETIC_MESSAGE_ID = "msg_01234567890123456789012345";
3
+ const SYNTHETIC_PART_ID = "prt_01234567890123456789012345";
4
+ export const createSyntheticUserMessage = (baseMessage, content) => {
5
+ const userInfo = baseMessage.info;
6
+ return {
7
+ info: {
8
+ id: SYNTHETIC_MESSAGE_ID,
9
+ sessionID: userInfo.sessionID,
10
+ role: "user",
11
+ time: { created: Date.now() },
12
+ agent: userInfo.agent || "code",
13
+ model: {
14
+ providerID: userInfo.model.providerID,
15
+ modelID: userInfo.model.modelID,
16
+ },
17
+ },
18
+ parts: [
19
+ {
20
+ id: SYNTHETIC_PART_ID,
21
+ sessionID: userInfo.sessionID,
22
+ messageID: SYNTHETIC_MESSAGE_ID,
23
+ type: "text",
24
+ text: content,
25
+ },
26
+ ],
27
+ };
28
+ };
29
+ export const createSyntheticAssistantMessage = (baseMessage, content) => {
30
+ const assistantInfo = baseMessage.info;
31
+ return {
32
+ info: {
33
+ id: SYNTHETIC_MESSAGE_ID,
34
+ sessionID: assistantInfo.sessionID,
35
+ role: "assistant",
36
+ parentID: assistantInfo.parentID,
37
+ modelID: assistantInfo.modelID,
38
+ providerID: assistantInfo.providerID,
39
+ time: { created: Date.now() },
40
+ tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
41
+ cost: 0,
42
+ path: assistantInfo.path,
43
+ mode: assistantInfo.mode,
44
+ },
45
+ parts: [
46
+ {
47
+ id: SYNTHETIC_PART_ID,
48
+ sessionID: assistantInfo.sessionID,
49
+ messageID: SYNTHETIC_MESSAGE_ID,
50
+ type: "text",
51
+ text: content,
52
+ },
53
+ ],
54
+ };
55
+ };
2
56
  /**
3
57
  * Extracts a human-readable key from tool metadata for display purposes.
4
58
  */
@@ -6,6 +60,17 @@ export const extractParameterKey = (tool, parameters) => {
6
60
  if (!parameters)
7
61
  return "";
8
62
  if (tool === "read" && parameters.filePath) {
63
+ const offset = parameters.offset;
64
+ const limit = parameters.limit;
65
+ if (offset !== undefined && limit !== undefined) {
66
+ return `${parameters.filePath} (lines ${offset}-${offset + limit})`;
67
+ }
68
+ if (offset !== undefined) {
69
+ return `${parameters.filePath} (lines ${offset}+)`;
70
+ }
71
+ if (limit !== undefined) {
72
+ return `${parameters.filePath} (lines 0-${limit})`;
73
+ }
9
74
  return parameters.filePath;
10
75
  }
11
76
  if (tool === "write" && parameters.filePath) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/messages/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,UAAe,EAAU,EAAE;IACzE,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAA;IAE1B,IAAI,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,UAAU,CAAC,QAAQ,CAAA;IAC9B,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QAC1C,OAAO,UAAU,CAAC,QAAQ,CAAA;IAC9B,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,UAAU,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClB,OAAO,UAAU,CAAC,I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,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,MAAM,UAAU,eAAe,CAC3B,KAAmB,EACnB,QAAqB,EACrB,MAAc;IAEd,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QACzB,IAAI,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;YACjC,SAAQ;QACZ,CAAC;QACD,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;gBAC3B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;oBACnD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;gBAC7B,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
@@ -9,10 +9,9 @@ TWO TOOLS FOR CONTEXT MANAGEMENT
9
9
  - `extract`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.
10
10
 
11
11
  CHOOSING THE RIGHT TOOL
12
- Ask: "Do I need to preserve any information from this output?"
13
- - **No** → `discard` (default for cleanup)
14
- - **Yes** → `extract` (preserves distilled knowledge)
15
- - **Uncertain** → `extract` (safer, preserves signal)
12
+ Ask: "Is this output clearly noise or irrelevant?"
13
+ - **Yes** → `discard` (pure cleanup, no preservation)
14
+ - **No** → `extract` (default - preserves key findings)
16
15
 
17
16
  Common scenarios:
18
17
  - Task complete, no valuable context → `discard`
@@ -39,5 +38,7 @@ When in doubt, keep it. Batch your actions and aim for high-impact prunes that s
39
38
  FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
40
39
  There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY prune what you see in <prunable-tools>.
41
40
 
41
+ If you see a user message containing only `[internal: context sync - no response needed]`, this is an internal system marker used for context injection - it is NOT user input. Do not acknowledge it, do not respond to it, and do not mention it. Simply continue with your current task or wait for actual user input.
42
+
42
43
  </instruction>
43
44
  </system-reminder>
@@ -30,5 +30,7 @@ When in doubt, keep it. Batch your actions and aim for high-impact discards that
30
30
  FAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCES.
31
31
  There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY discard what you see in <prunable-tools>.
32
32
 
33
+ If you see a user message containing only `[internal: context sync - no response needed]`, this is an internal system marker used for context injection - it is NOT user input. Do not acknowledge it, do not respond to it, and do not mention it. Simply continue with your current task or wait for actual user input.
34
+
33
35
  </instruction>
34
36
  </system-reminder>
@@ -30,5 +30,7 @@ When in doubt, keep it. Batch your actions and aim for high-impact extractions t
30
30
  FAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCES.
31
31
  There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY extract what you see in <prunable-tools>.
32
32
 
33
+ If you see a user message containing only `[internal: context sync - no response needed]`, this is an internal system marker used for context injection - it is NOT user input. Do not acknowledge it, do not respond to it, and do not mention it. Simply continue with your current task or wait for actual user input.
34
+
33
35
  </instruction>
34
36
  </system-reminder>
@@ -3,34 +3,29 @@ Discards tool outputs from context to manage conversation size and reduce noise.
3
3
  ## IMPORTANT: The Prunable List
4
4
  A `<prunable-tools>` list is provided to you showing available tool outputs you can discard when there are tools available for pruning. Each line has the format `ID: tool, parameter` (e.g., `20: read, /path/to/file.ts`). You MUST only use numeric IDs that appear in this list to select which tools to discard.
5
5
 
6
- **Note:** For `write` and `edit` tools, discarding removes the input content (the code being written/edited) while preserving the output confirmation. This is useful after completing a file modification when you no longer need the raw content in context.
7
-
8
6
  ## When to Use This Tool
9
7
 
10
- Use `discard` for removing tool outputs that are no longer needed **without preserving their content**:
11
-
12
- ### 1. Task Completion (Clean Up)
13
- **When:** You have successfully completed a specific unit of work (e.g., fixed a bug, wrote a file, answered a question).
14
- **Action:** Discard the tools used for that task with reason `completion`.
8
+ Use `discard` for removing tool content that is no longer needed
15
9
 
16
- ### 2. Removing Noise (Garbage Collection)
17
- **When:** You have read files or run commands that turned out to be irrelevant, unhelpful, or outdated (meaning later tools have provided fresher, more valid information).
18
- **Action:** Discard these specific tool outputs immediately with reason `noise`.
10
+ - **Noise:** Irrelevant, unhelpful, or superseded outputs that provide no value.
11
+ - **Task Completion:** Work is complete and there's no valuable information worth preserving.
19
12
 
20
13
  ## When NOT to Use This Tool
21
14
 
22
- - **If you need to preserve information:** Keep the raw output in context rather than discarding it.
23
- - **If you'll need the output later:** Don't discard files you plan to edit, or context you'll need for implementation.
15
+ - **If the output contains useful information:** Use `extract` instead to preserve key findings.
16
+ - **If you'll need the output later:** Don't discard files you plan to edit or context you'll need for implementation.
24
17
 
25
18
  ## Best Practices
26
19
  - **Strategic Batching:** Don't discard single small tool outputs (like short bash commands) unless they are pure noise. Wait until you have several items to perform high-impact discards.
27
20
  - **Think ahead:** Before discarding, ask: "Will I need this output for an upcoming task?" If yes, keep it.
28
21
 
29
22
  ## Format
30
- The `ids` parameter is an array where the first element is the reason, followed by numeric IDs:
31
- `ids: ["reason", "id1", "id2", ...]`
32
23
 
33
- ## Examples
24
+ - `ids`: Array where the first element is the reason, followed by numeric IDs from the `<prunable-tools>` list
25
+
26
+ Reasons: `noise` | `completion`
27
+
28
+ ## Example
34
29
 
35
30
  <example_noise>
36
31
  Assistant: [Reads 'wrong_file.ts']
@@ -40,17 +35,7 @@ This file isn't relevant to the auth system. I'll remove it to clear the context
40
35
 
41
36
  <example_completion>
42
37
  Assistant: [Runs tests, they pass]
43
- The tests passed. I'll clean up now.
38
+ The tests passed and I don't need to preserve any details. I'll clean up now.
44
39
  [Uses discard with ids: ["completion", "20", "21"]]
45
40
  </example_completion>
46
41
 
47
- <example_keep>
48
- Assistant: [Reads 'auth.ts' to understand the login flow]
49
- I've understood the auth flow. I'll need to modify this file to add the new validation, so I'm keeping this read in context rather than discarding.
50
- </example_keep>
51
-
52
- <example_edit_completion>
53
- Assistant: [Edits 'auth.ts' to add validation]
54
- The edit was successful. I no longer need the raw edit content in context.
55
- [Uses discard with ids: ["completion", "15"]]
56
- </example_edit_completion>
@@ -7,70 +7,38 @@ A `<prunable-tools>` list is provided to you showing available tool outputs you
7
7
 
8
8
  Use `extract` when you have gathered useful information that you want to **preserve in distilled form** before removing the raw outputs:
9
9
 
10
- ### 1. Task Completion
11
- **When:** You have completed a unit of work and want to preserve key findings.
12
- **Action:** Extract with distillation scaled to the value of the content. High-value insights require comprehensive capture; routine completions can use lighter distillation.
13
-
14
- ### 2. Knowledge Preservation
15
- **When:** You have read files, run commands, or gathered context that contains valuable information you'll need to reference later, but the full raw output is too large to keep.
16
- **Action:** Convert raw data into distilled knowledge. This allows you to remove large outputs (like full file reads) while keeping only the specific parts you need (like a single function signature or constant).
17
-
18
- ## CRITICAL: Distillation Requirements
19
-
20
- You MUST provide distilled findings in the `distillation` parameter. This is not optional.
21
-
22
- - **Comprehensive Capture:** Distillation is not just a summary. It must be a high-fidelity representation of the technical details. If you read a file, the distillation should include function signatures, specific logic flows, constant values, and any constraints or edge cases discovered.
23
- - **Task-Relevant Verbosity:** Be as verbose as necessary to ensure that the "distilled" version is a complete substitute for the raw output for the task at hand. If you will need to reference a specific algorithm or interface later, include it in its entirety within the distillation.
24
- - **Extract Per-ID:** When extracting from multiple tools, your `distillation` object MUST contain a corresponding entry for EVERY ID being extracted. You must capture high-fidelity findings for each tool individually to ensure no signal is lost.
25
- - **Structure:** Map EVERY `ID` from the `ids` array to its specific distilled findings.
26
- Example: `{ "20": { ... }, "21": { ... } }`
27
- - Capture all relevant details (function names, logic, constraints) to ensure no signal is lost.
28
- - Prioritize information that is essential for the immediate next steps of your plan.
10
+ - **Task Completion:** You completed a unit of work and want to preserve key findings.
11
+ - **Knowledge Preservation:** You have context that contains valuable information, but also a lot of unnecessary detail - you only need to preserve some specifics.
29
12
 
30
13
  ## When NOT to Use This Tool
31
14
 
32
- - **If you need precise syntax:** If you'll need to edit a file, grep for exact strings, or reference precise syntax, keep the raw output. Distillation works for understanding; implementation often requires the original.
33
- - **If uncertain:** Prefer keeping over re-fetching. The cost of retaining context is lower than the cost of redundant tool calls.
15
+ - **If you need precise syntax:** If you'll edit a file or grep for exact strings, keep the raw output.
16
+ - **If uncertain:** Prefer keeping over re-fetching.
17
+
34
18
 
35
19
  ## Best Practices
36
- - **Technical Fidelity:** Ensure that types, parameters, and return values are preserved if they are relevant to upcoming implementation steps.
37
20
  - **Strategic Batching:** Wait until you have several items or a few large outputs to extract, rather than doing tiny, frequent extractions. Aim for high-impact extractions that significantly reduce context size.
38
21
  - **Think ahead:** Before extracting, ask: "Will I need the raw output for an upcoming task?" If you researched a file you'll later edit, do NOT extract it.
39
22
 
40
23
  ## Format
41
- The `ids` parameter is an array of numeric IDs as strings:
42
- `ids: ["id1", "id2", ...]`
43
24
 
44
- The `distillation` parameter is an object mapping each ID to its distilled findings:
45
- `distillation: { "id1": { ...findings... }, "id2": { ...findings... } }`
25
+ - `ids`: Array of numeric IDs as strings from the `<prunable-tools>` list
26
+ - `distillation`: Array of strings, one per ID (positional: distillation[0] is for ids[0], etc.)
27
+
28
+ Each distillation string should capture the essential information you need to preserve - function signatures, logic, constraints, values, etc. Be as detailed as needed for your task.
46
29
 
47
30
  ## Example
48
31
 
49
32
  <example_extraction>
50
- Assistant: [Reads service implementation, types, and config]
51
- I'll preserve the full technical specification and implementation logic before extracting.
52
- [Uses extract with ids: ["10", "11", "12"], distillation: {
53
- "10": {
54
- "file": "src/services/auth.ts",
55
- "signatures": [
56
- "async function validateToken(token: string): Promise<User | null>",
57
- "function hashPassword(password: string): string"
58
- ],
59
- "logic": "The validateToken function first checks the local cache before calling the external OIDC provider. It uses a 5-minute TTL for cached tokens.",
60
- "dependencies": ["import { cache } from '../utils/cache'", "import { oidc } from '../config'"],
61
- "constraints": "Tokens must be at least 128 chars long. hashPassword uses bcrypt with 12 rounds."
62
- },
63
- "11": {
64
- "file": "src/types/user.ts",
65
- "interface": "interface User { id: string; email: string; permissions: ('read' | 'write' | 'admin')[]; status: 'active' | 'suspended'; }",
66
- "context": "The permissions array is strictly typed and used by the RBAC middleware."
67
- },
68
- "12": {
69
- "file": "config/default.json",
70
- "values": { "PORT": 3000, "RETRY_STRATEGY": "exponential", "MAX_ATTEMPTS": 5 },
71
- "impact": "The retry strategy affects all outgoing HTTP clients in the core module."
72
- }
73
- }]
33
+ Assistant: [Reads auth service and user types]
34
+ I'll preserve the key details before extracting.
35
+ [Uses extract with:
36
+ ids: ["10", "11"],
37
+ distillation: [
38
+ "auth.ts: validateToken(token: string) -> User|null checks cache first (5min TTL) then OIDC. hashPassword uses bcrypt 12 rounds. Tokens must be 128+ chars.",
39
+ "user.ts: interface User { id: string; email: string; permissions: ('read'|'write'|'admin')[]; status: 'active'|'suspended' }"
40
+ ]
41
+ ]
74
42
  </example_extraction>
75
43
 
76
44
  <example_keep>
@@ -0,0 +1,10 @@
1
+ <instruction name=context_management_required>
2
+ **CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
3
+
4
+ **Immediate Actions Required:**
5
+ 1. **Task Completion:** If a sub-task is complete, decide: use `discard` if no valuable context to preserve (default), or use `extract` if insights are worth keeping.
6
+ 2. **Noise Removal:** If you read files or ran commands that yielded no value, use `discard` to remove them.
7
+ 3. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use `extract` to distill the insights and remove the raw entry.
8
+
9
+ **Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must perform context management.
10
+ </instruction>
@@ -0,0 +1,9 @@
1
+ <instruction name=context_management_required>
2
+ **CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
3
+
4
+ **Immediate Actions Required:**
5
+ 1. **Task Completion:** If a sub-task is complete, use the `discard` tool to remove the tools used.
6
+ 2. **Noise Removal:** If you read files or ran commands that yielded no value, use the `discard` tool to remove them.
7
+
8
+ **Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must discard unneeded tool outputs.
9
+ </instruction>
@@ -0,0 +1,9 @@
1
+ <instruction name=context_management_required>
2
+ **CRITICAL CONTEXT WARNING:** Your context window is filling with tool outputs. Strict adherence to context hygiene is required.
3
+
4
+ **Immediate Actions Required:**
5
+ 1. **Task Completion:** If you have completed work, extract key findings from the tools used. Scale distillation depth to the value of the content.
6
+ 2. **Knowledge Preservation:** If you are holding valuable raw data you'll need to reference later, use the `extract` tool with high-fidelity distillation to preserve the insights and remove the raw entry.
7
+
8
+ **Protocol:** You should prioritize this cleanup, but do not interrupt a critical atomic operation if one is in progress. Once the immediate step is done, you must extract valuable findings from tool outputs.
9
+ </instruction>
@@ -0,0 +1,58 @@
1
+ <system-reminder>
2
+ <instruction name=context_management_protocol policy_level=critical>
3
+
4
+ ENVIRONMENT
5
+ You are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` and `extract` tools. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to prune.
6
+
7
+ TWO TOOLS FOR CONTEXT MANAGEMENT
8
+ - `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
9
+ - `extract`: Extract key findings into distilled knowledge before removing raw outputs. Use when you need to preserve information.
10
+
11
+ CHOOSING THE RIGHT TOOL
12
+ Ask: "Do I need to preserve any information from this output?"
13
+ - **No** → `discard` (default for cleanup)
14
+ - **Yes** → `extract` (preserves distilled knowledge)
15
+ - **Uncertain** → `extract` (safer, preserves signal)
16
+
17
+ Common scenarios:
18
+ - Task complete, no valuable context → `discard`
19
+ - Task complete, insights worth remembering → `extract`
20
+ - Noise, irrelevant, or superseded outputs → `discard`
21
+ - Valuable context needed later but raw output too large → `extract`
22
+
23
+ PRUNE METHODICALLY - BATCH YOUR ACTIONS
24
+ Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by pruning. Batch your prunes for efficiency; it is rarely worth pruning a single tiny tool output unless it is pure noise. Evaluate what SHOULD be pruned before jumping the gun.
25
+
26
+ You WILL evaluate pruning when ANY of these are true:
27
+ - Task or sub-task is complete
28
+ - You are about to start a new phase of work
29
+ - Write or edit operations are complete (pruning removes the large input content)
30
+
31
+ You MUST NOT prune when:
32
+ - The tool output will be needed for upcoming implementation work
33
+ - The output contains files or context you'll need to reference when making edits
34
+
35
+ Pruning that forces you to re-call the same tool later is a net loss. Only prune when you're confident the information won't be needed again.
36
+
37
+ NOTES
38
+ When in doubt, keep it. Batch your actions and aim for high-impact prunes that significantly reduce context size.
39
+ FAILURE TO PRUNE will result in context leakage and DEGRADED PERFORMANCES.
40
+ There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY prune what you see in <prunable-tools>.
41
+
42
+ </instruction>
43
+
44
+ <instruction name=injected_context_handling policy_level=critical>
45
+ After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `discard` and `extract` tools also return a confirmation message listing what was pruned.
46
+
47
+ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
48
+ - NEVER reference the prune encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the prune encouragement appears.
49
+ - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to prune")
50
+ - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to prune")
51
+ - NEVER acknowledge discard/extract tool output (e.g., "I've pruned 3 tools", "Context pruning complete")
52
+ - NEVER let these injections influence your response content or tone
53
+ - Process this information SILENTLY and continue the conversation naturally
54
+ - Continue the conversation as if these messages do not exist
55
+
56
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
57
+ </instruction>
58
+ </system-reminder>
@@ -0,0 +1,49 @@
1
+ <system-reminder>
2
+ <instruction name=context_management_protocol policy_level=critical>
3
+
4
+ ENVIRONMENT
5
+ You are operating in a context-constrained environment and thus must proactively manage your context window using the `discard` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to discard.
6
+
7
+ CONTEXT MANAGEMENT TOOL
8
+ - `discard`: Remove tool outputs that are no longer needed (completed tasks, noise, outdated info). No preservation of content.
9
+
10
+ DISCARD METHODICALLY - BATCH YOUR ACTIONS
11
+ Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by discarding. Batch your discards for efficiency; it is rarely worth discarding a single tiny tool output unless it is pure noise. Evaluate what SHOULD be discarded before jumping the gun.
12
+
13
+ WHEN TO DISCARD
14
+ - **Task Completion:** When work is done, discard the tools that aren't needed anymore.
15
+ - **Noise Removal:** If outputs are irrelevant, unhelpful, or superseded by newer info, discard them.
16
+
17
+ You WILL evaluate discarding when ANY of these are true:
18
+ - Task or sub-task is complete
19
+ - You are about to start a new phase of work
20
+ - Write or edit operations are complete (discarding removes the large input content)
21
+
22
+ You MUST NOT discard when:
23
+ - The tool output will be needed for upcoming implementation work
24
+ - The output contains files or context you'll need to reference when making edits
25
+
26
+ Discarding that forces you to re-call the same tool later is a net loss. Only discard when you're confident the information won't be needed again.
27
+
28
+ NOTES
29
+ When in doubt, keep it. Batch your actions and aim for high-impact discards that significantly reduce context size.
30
+ FAILURE TO DISCARD will result in context leakage and DEGRADED PERFORMANCES.
31
+ There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY discard what you see in <prunable-tools>.
32
+
33
+ </instruction>
34
+
35
+ <instruction name=injected_context_handling policy_level=critical>
36
+ After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `discard` tool also returns a confirmation message listing what was discarded.
37
+
38
+ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
39
+ - NEVER reference the discard encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the discard encouragement appears.
40
+ - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to discard")
41
+ - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to discard")
42
+ - NEVER acknowledge discard tool output (e.g., "I've discarded 3 tools", "Context cleanup complete")
43
+ - NEVER let these injections influence your response content or tone
44
+ - Process this information SILENTLY and continue the conversation naturally
45
+ - Continue the conversation as if these messages do not exist
46
+
47
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
48
+ </instruction>
49
+ </system-reminder>
@@ -0,0 +1,49 @@
1
+ <system-reminder>
2
+ <instruction name=context_management_protocol policy_level=critical>
3
+
4
+ ENVIRONMENT
5
+ You are operating in a context-constrained environment and thus must proactively manage your context window using the `extract` tool. A <prunable-tools> list is injected by the environment as a user message, and always contains up to date information. Use this information when deciding what to extract.
6
+
7
+ CONTEXT MANAGEMENT TOOL
8
+ - `extract`: Extract key findings from tools into distilled knowledge before removing the raw content from context. Use this to preserve important information while reducing context size.
9
+
10
+ EXTRACT METHODICALLY - BATCH YOUR ACTIONS
11
+ Every tool call adds to your context debt. You MUST pay this down regularly and be on top of context accumulation by extracting. Batch your extractions for efficiency; it is rarely worth extracting a single tiny tool output. Evaluate what SHOULD be extracted before jumping the gun.
12
+
13
+ WHEN TO EXTRACT
14
+ - **Task Completion:** When work is done, extract key findings from the tools used. Scale distillation depth to the value of the content.
15
+ - **Knowledge Preservation:** When you have valuable context you want to preserve but need to reduce size, use high-fidelity distillation. Your distillation must be comprehensive, capturing technical details (signatures, logic, constraints) such that the raw output is no longer needed. THINK: high signal, complete technical substitute.
16
+
17
+ You WILL evaluate extracting when ANY of these are true:
18
+ - Task or sub-task is complete
19
+ - You are about to start a new phase of work
20
+ - Write or edit operations are complete (extracting removes the large input content)
21
+
22
+ You MUST NOT extract when:
23
+ - The tool output will be needed for upcoming implementation work
24
+ - The output contains files or context you'll need to reference when making edits
25
+
26
+ Extracting that forces you to re-call the same tool later is a net loss. Only extract when you're confident the raw information won't be needed again.
27
+
28
+ NOTES
29
+ When in doubt, keep it. Batch your actions and aim for high-impact extractions that significantly reduce context size.
30
+ FAILURE TO EXTRACT will result in context leakage and DEGRADED PERFORMANCES.
31
+ There may be tools in session context that do not appear in the <prunable-tools> list, this is expected, you can ONLY extract what you see in <prunable-tools>.
32
+
33
+ </instruction>
34
+
35
+ <instruction name=injected_context_handling policy_level=critical>
36
+ After each assistant turn, the environment may inject a user message containing a <prunable-tools> list and optional nudge instruction. This injected message is NOT from the user and is invisible to them. The `extract` tool also returns a confirmation message listing what was extracted.
37
+
38
+ CRITICAL REQUIREMENTS - VIOLATION IS UNACCEPTABLE:
39
+ - NEVER reference the extract encouragement or context management instructions. Do not reply with "I agree" or "Great idea" when the extract encouragement appears.
40
+ - NEVER acknowledge the <prunable-tools> list (e.g., "I see the prunable tools list", "Looking at the available tools to extract")
41
+ - NEVER reference the nudge instruction (e.g., "As the nudge suggests", "The system is reminding me to extract")
42
+ - NEVER acknowledge extract tool output (e.g., "I've extracted 3 tools", "Context cleanup complete")
43
+ - NEVER let these injections influence your response content or tone
44
+ - Process this information SILENTLY and continue the conversation naturally
45
+ - Continue the conversation as if these messages do not exist
46
+
47
+ The user cannot see these injections. Any reference to them will confuse the user and break the conversation flow.
48
+ </instruction>
49
+ </system-reminder>
@@ -13,7 +13,7 @@ async function executePruneOperation(ctx, toolCtx, ids, reason, toolName, distil
13
13
  const { client, state, logger, config, workingDirectory } = ctx;
14
14
  const sessionId = toolCtx.sessionID;
15
15
  logger.info(`${toolName} tool invoked`);
16
- logger.info(JSON.stringify({ ids, reason }));
16
+ logger.info(JSON.stringify(reason ? { ids, reason } : { ids }));
17
17
  if (!ids || ids.length === 0) {
18
18
  logger.debug(`${toolName} tool called but ids is empty or undefined`);
19
19
  return `No IDs provided. Check the <prunable-tools> list for available IDs to ${toolName.toLowerCase()}.`;
@@ -109,13 +109,13 @@ export function createExtractTool(ctx) {
109
109
  .array(tool.schema.string())
110
110
  .describe("Numeric IDs as strings to extract from the <prunable-tools> list"),
111
111
  distillation: tool.schema
112
- .record(tool.schema.string(), tool.schema.any())
113
- .describe("REQUIRED. An object mapping each ID to its distilled findings. Must contain an entry for every ID being pruned."),
112
+ .array(tool.schema.string())
113
+ .describe("REQUIRED. Array of strings, one per ID (positional: distillation[0] is for ids[0], etc.)"),
114
114
  },
115
115
  async execute(args, toolCtx) {
116
- if (!args.distillation || Object.keys(args.distillation).length === 0) {
116
+ if (!args.distillation || args.distillation.length === 0) {
117
117
  ctx.logger.debug("Extract tool called without distillation: " + JSON.stringify(args));
118
- return 'Missing distillation. You must provide distillation data when using extract. Format: distillation: { "id": { ...findings... } }';
118
+ return "Missing distillation. You must provide a distillation string for each ID.";
119
119
  }
120
120
  // Log the distillation for debugging/analysis
121
121
  ctx.logger.info("Distillation data received:");
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../lib/strategies/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAEH,uBAAuB,EACvB,4BAA4B,GAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEhE,MAAM,wBAAwB,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;AAChE,MAAM,wBAAwB,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAA;AAUhE,+CAA+C;AAC/C,KAAK,UAAU,qBAAqB,CAChC,GAAqB,EACrB,OAA8B,EAC9B,GAAa,EACb,MAAmB,EACnB,QAAgB,EAChB,YAAkC;IAElC,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C,GAAG,EACR,eAA8B,EAC9B,SAAS,EACT,IAAI,CAAC,YAAY,CACpB,CAAA;QACL,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@tarquinen/opencode-dcp",
4
- "version": "1.1.0-beta.3",
4
+ "version": "1.1.0",
5
5
  "type": "module",
6
6
  "description": "OpenCode plugin that optimizes token usage by pruning obsolete tool outputs from conversation context",
7
7
  "main": "./dist/index.js",