Skip to content

Commit 4618a7f

Browse files
committed
fix: disable pruning of write/edit tools by default
Adds write and edit to default protected tools and disables supersedeWrites strategy to prevent models from outputting placeholder text to files. Fixes #215
1 parent ec3706d commit 4618a7f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ DCP uses its own config file:
106106
},
107107
// Prune write tool inputs when the file has been subsequently read
108108
"supersedeWrites": {
109-
"enabled": true,
109+
"enabled": false,
110110
},
111111
// Prune tool inputs for errored tools after X turns
112112
"purgeErrors": {
@@ -129,7 +129,7 @@ When enabled, turn protection prevents tool outputs from being pruned for a conf
129129
### Protected Tools
130130

131131
By default, these tools are always protected from pruning across all strategies:
132-
`task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`
132+
`task`, `todowrite`, `todoread`, `discard`, `extract`, `batch`, `write`, `edit`
133133

134134
The `protectedTools` arrays in each section add to this default list.
135135

lib/config.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,16 @@ export interface PluginConfig {
5858
}
5959
}
6060

61-
const DEFAULT_PROTECTED_TOOLS = ["task", "todowrite", "todoread", "discard", "extract", "batch"]
61+
const DEFAULT_PROTECTED_TOOLS = [
62+
"task",
63+
"todowrite",
64+
"todoread",
65+
"discard",
66+
"extract",
67+
"batch",
68+
"write",
69+
"edit",
70+
]
6271

6372
// Valid config keys for validation against user config
6473
export const VALID_CONFIG_KEYS = new Set([
@@ -382,7 +391,7 @@ const defaultConfig: PluginConfig = {
382391
protectedTools: [...DEFAULT_PROTECTED_TOOLS],
383392
},
384393
supersedeWrites: {
385-
enabled: true,
394+
enabled: false,
386395
},
387396
purgeErrors: {
388397
enabled: true,
@@ -502,7 +511,7 @@ function createDefaultConfig(): void {
502511
},
503512
// Prune write tool inputs when the file has been subsequently read
504513
"supersedeWrites": {
505-
"enabled": true
514+
"enabled": false
506515
},
507516
// Prune tool inputs for errored tools after X turns
508517
"purgeErrors": {

lib/messages/prune.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const pruneToolOutputs = (state: SessionState, logger: Logger, messages: WithPar
4343
}
4444
}
4545

46+
// NOTE: This function is currently unused because "write" and "edit" are protected by default.
47+
// Some models incorrectly use PRUNED_TOOL_INPUT_REPLACEMENT in their output when they see it in context.
48+
// See: https://github.com/Opencode-DCP/opencode-dynamic-context-pruning/issues/215
49+
// Keeping this function in case the bug is resolved in the future.
4650
const pruneToolInputs = (state: SessionState, logger: Logger, messages: WithParts[]): void => {
4751
for (const msg of messages) {
4852
if (isMessageCompacted(state, msg)) {

0 commit comments

Comments
 (0)