Skip to content

Commit c728879

Browse files
authored
Merge pull request #173 from Opencode-DCP/refactor/consolidate-prompts
Refactor prompt loading and rename pruning prompt files
2 parents 6532e3f + ac67023 commit c728879

File tree

8 files changed

+5
-5
lines changed

8 files changed

+5
-5
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const plugin: Plugin = (async (ctx) => {
2929

3030
return {
3131
"experimental.chat.system.transform": async (_input: unknown, output: { system: string[] }) => {
32-
const syntheticPrompt = loadPrompt("synthetic")
32+
const syntheticPrompt = loadPrompt("prune-system-prompt")
3333
output.system.push(syntheticPrompt)
3434
},
3535
"experimental.chat.messages.transform": createChatMessageTransformHandler(

lib/messages/prune.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { UserMessage } from "@opencode-ai/sdk"
88

99
const PRUNED_TOOL_INPUT_REPLACEMENT = '[Input removed to save context]'
1010
const PRUNED_TOOL_OUTPUT_REPLACEMENT = '[Output removed to save context - information superseded or no longer needed]'
11-
const NUDGE_STRING = loadPrompt("nudge")
11+
const NUDGE_STRING = loadPrompt("prune-nudge")
1212

1313
const wrapPrunableTools = (content: string): string => `<prunable-tools>
1414
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.

lib/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function buildAnalysisPrompt(
127127
const minimizedMessages = minimizeMessages(messages, alreadyPrunedIds, protectedToolCallIds)
128128
const messagesJson = JSON.stringify(minimizedMessages, null, 2).replace(/\\n/g, '\n')
129129

130-
return loadPrompt("pruning", {
130+
return loadPrompt("on-idle-analysis", {
131131
available_tool_call_ids: unprunedToolCallIds.join(", "),
132132
session_history: messagesJson
133133
})

lib/strategies/prune-tool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import type { Logger } from "../logger"
1010
import { loadPrompt } from "../prompt"
1111
import { calculateTokensSaved, getCurrentParams } from "./utils"
1212

13-
/** Tool description loaded from prompts/tool.txt */
14-
const TOOL_DESCRIPTION = loadPrompt("tool")
13+
/** Tool description loaded from prompts/prune-tool-spec.txt */
14+
const TOOL_DESCRIPTION = loadPrompt("prune-tool-spec")
1515

1616
export interface PruneToolContext {
1717
client: any

0 commit comments

Comments
 (0)