Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ DCP uses its own config file:
},
// Prune write tool inputs when the file has been subsequently read
"supersedeWrites": {
"enabled": true,
"enabled": false,
},
// Prune tool inputs for errored tools after X turns
"purgeErrors": {
Expand All @@ -129,7 +129,7 @@ When enabled, turn protection prevents tool outputs from being pruned for a conf
### Protected Tools

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

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

Expand Down
15 changes: 12 additions & 3 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ export interface PluginConfig {
}
}

const DEFAULT_PROTECTED_TOOLS = ["task", "todowrite", "todoread", "discard", "extract", "batch"]
const DEFAULT_PROTECTED_TOOLS = [
"task",
"todowrite",
"todoread",
"discard",
"extract",
"batch",
"write",
"edit",
]

// Valid config keys for validation against user config
export const VALID_CONFIG_KEYS = new Set([
Expand Down Expand Up @@ -382,7 +391,7 @@ const defaultConfig: PluginConfig = {
protectedTools: [...DEFAULT_PROTECTED_TOOLS],
},
supersedeWrites: {
enabled: true,
enabled: false,
},
purgeErrors: {
enabled: true,
Expand Down Expand Up @@ -502,7 +511,7 @@ function createDefaultConfig(): void {
},
// Prune write tool inputs when the file has been subsequently read
"supersedeWrites": {
"enabled": true
"enabled": false
},
// Prune tool inputs for errored tools after X turns
"purgeErrors": {
Expand Down
4 changes: 4 additions & 0 deletions lib/messages/prune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const pruneToolOutputs = (state: SessionState, logger: Logger, messages: WithPar
}
}

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