@@ -5,7 +5,7 @@ import { Logger } from "./lib/logger"
55import { Janitor , type SessionStats } from "./lib/janitor"
66import { checkForUpdates } from "./lib/version-checker"
77import { loadPrompt } from "./lib/prompt"
8- import { injectSynthInstruction , createToolResultTracker , maybeInjectToolResultNudge } from "./lib/synth-instruction"
8+ import { injectSynth , createToolTracker , injectNudge } from "./lib/synth-instruction"
99
1010async function isSubagentSession ( client : any , sessionID : string ) : Promise < boolean > {
1111 try {
@@ -16,9 +16,9 @@ async function isSubagentSession(client: any, sessionID: string): Promise<boolea
1616 }
1717}
1818
19- const TOOL_SYNTH_INSTRUCTION = loadPrompt ( "synthetic" )
20- const TOOL_CONTEXT_PRUNING_DESCRIPTION = loadPrompt ( "context_pruning" )
21- const TOOL_TOOL_PART_NUDGE = loadPrompt ( "tool-result- nudge" )
19+ const SYNTH_INSTRUCTION = loadPrompt ( "synthetic" )
20+ const TOOL_INSTRUCTION = loadPrompt ( "context_pruning" )
21+ const NUDGE_INSTRUCTION = loadPrompt ( "nudge" )
2222
2323const plugin : Plugin = ( async ( ctx ) => {
2424 const { config, migrations } = getConfig ( ctx )
@@ -37,7 +37,7 @@ const plugin: Plugin = (async (ctx) => {
3737 const toolParametersCache = new Map < string , any > ( )
3838 const modelCache = new Map < string , { providerID : string ; modelID : string } > ( )
3939 const janitor = new Janitor ( ctx . client , prunedIdsState , statsState , logger , toolParametersCache , config . protectedTools , modelCache , config . model , config . showModelErrorToasts , config . strictModelSelection , config . pruning_summary , ctx . directory )
40- const toolResultTracker = createToolResultTracker ( )
40+ const toolTracker = createToolTracker ( )
4141
4242 const cacheToolParameters = ( messages : any [ ] ) => {
4343 for ( const message of messages ) {
@@ -79,17 +79,17 @@ const plugin: Plugin = (async (ctx) => {
7979
8080 // Inject periodic nudge every 5 tool results
8181 if ( config . strategies . onTool . length > 0 ) {
82- if ( maybeInjectToolResultNudge ( body . messages , toolResultTracker , TOOL_TOOL_PART_NUDGE ) ) {
82+ if ( injectNudge ( body . messages , toolTracker , NUDGE_INSTRUCTION ) ) {
8383 logger . debug ( "fetch" , "Injected tool-result nudge" , {
84- toolResultCount : toolResultTracker . toolResultCount
84+ toolResultCount : toolTracker . toolResultCount
8585 } )
8686 modified = true
8787 }
8888 }
8989
9090 // Inject synthInstruction for the context_pruning tool
9191 if ( config . strategies . onTool . length > 0 ) {
92- if ( injectSynthInstruction ( body . messages , TOOL_SYNTH_INSTRUCTION ) ) {
92+ if ( injectSynth ( body . messages , SYNTH_INSTRUCTION ) ) {
9393 logger . debug ( "fetch" , "Injected synthInstruction" )
9494 modified = true
9595 }
@@ -263,7 +263,7 @@ const plugin: Plugin = (async (ctx) => {
263263
264264 tool : config . strategies . onTool . length > 0 ? {
265265 context_pruning : tool ( {
266- description : TOOL_CONTEXT_PRUNING_DESCRIPTION ,
266+ description : TOOL_INSTRUCTION ,
267267 args : {
268268 reason : tool . schema . string ( ) . optional ( ) . describe (
269269 "Brief reason for triggering pruning (e.g., 'task complete', 'switching focus')"
0 commit comments