11import type { SessionState , WithParts } from "../state"
22import type { Logger } from "../logger"
33import type { PluginConfig } from "../config"
4- import { getLastUserMessage , extractParameterKey , buildToolIdList } from "./utils"
54import { loadPrompt } from "../prompt"
5+ import { extractParameterKey , buildToolIdList } from "./utils"
6+ import { getLastUserMessage } from "../shared-utils"
7+ import { UserMessage } from "@opencode-ai/sdk"
68
79const PRUNED_TOOL_OUTPUT_REPLACEMENT = '[Output removed to save context - information superseded or no longer needed]'
810const NUDGE_STRING = loadPrompt ( "nudge" )
@@ -51,7 +53,7 @@ export const insertPruneToolContext = (
5153 }
5254
5355 const lastUserMessage = getLastUserMessage ( messages )
54- if ( ! lastUserMessage || lastUserMessage . info . role !== 'user' ) {
56+ if ( ! lastUserMessage ) {
5557 return
5658 }
5759
@@ -72,10 +74,10 @@ export const insertPruneToolContext = (
7274 sessionID : lastUserMessage . info . sessionID ,
7375 role : "user" ,
7476 time : { created : Date . now ( ) } ,
75- agent : lastUserMessage . info . agent || "build" ,
77+ agent : ( lastUserMessage . info as UserMessage ) . agent || "build" ,
7678 model : {
77- providerID : lastUserMessage . info . model . providerID ,
78- modelID : lastUserMessage . info . model . modelID
79+ providerID : ( lastUserMessage . info as UserMessage ) . model . providerID ,
80+ modelID : ( lastUserMessage . info as UserMessage ) . model . modelID
7981 }
8082 } ,
8183 parts : [
@@ -118,9 +120,6 @@ const pruneToolOutputs = (
118120 if ( part . state . status === 'completed' ) {
119121 part . state . output = PRUNED_TOOL_OUTPUT_REPLACEMENT
120122 }
121- // if (part.state.status === 'error') {
122- // part.state.error = PRUNED_TOOL_OUTPUT_REPLACEMENT
123- // }
124123 }
125124 }
126125}
0 commit comments