From 46e5a8c065404bc774e65fe551bec369d7e2e1dc Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Tue, 9 Dec 2025 10:42:56 -0500 Subject: [PATCH 1/2] Fix nudge injection to insert before tool_use blocks --- lib/fetch-wrapper/formats/anthropic.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/fetch-wrapper/formats/anthropic.ts b/lib/fetch-wrapper/formats/anthropic.ts index dab215e0..c1a99d82 100644 --- a/lib/fetch-wrapper/formats/anthropic.ts +++ b/lib/fetch-wrapper/formats/anthropic.ts @@ -42,7 +42,12 @@ export const anthropicFormat: FormatDescriptor = { if (msg.role === 'assistant') { // Append to existing content array if (Array.isArray(msg.content)) { - msg.content.push({ type: 'text', text: injection }) + const firstToolUseIndex = msg.content.findIndex((block: any) => block.type === 'tool_use') + if (firstToolUseIndex !== -1) { + msg.content.splice(firstToolUseIndex, 0, { type: 'text', text: injection }) + } else { + msg.content.push({ type: 'text', text: injection }) + } } else if (typeof msg.content === 'string') { // Convert string content to array format msg.content = [ From 193b4e173bc71c19d43bca2795b73f3c5f82e9ff Mon Sep 17 00:00:00 2001 From: Daniel Smolsky Date: Tue, 9 Dec 2025 10:42:56 -0500 Subject: [PATCH 2/2] Update demo image in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 937207ca..69e34315 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Automatically reduces token usage in OpenCode by removing obsolete tool outputs from conversation history. -![DCP in action](dcp-demo.png) +![DCP in action](dcp-demo3.png) ## Installation