@@ -284,22 +284,40 @@ ${PLACEHOLDER.GIT_CHANGES_PROMPT}
284284 noAskUser,
285285 } ) ,
286286
287- handleSteps : function * ( { params } ) {
288- while ( true ) {
289- // Run context-pruner before each step
290- yield {
291- toolName : 'spawn_agent_inline' ,
292- input : {
293- agent_type : 'context-pruner' ,
294- params : params ?? { } ,
295- } ,
296- includeToolCall : false ,
297- } as any
298-
299- const { stepsComplete } = yield 'STEP'
300- if ( stepsComplete ) break
301- }
302- } ,
287+ // handleSteps is serialized via .toString() and re-eval'd, so closure
288+ // variables like `isFree` are not in scope at runtime. Pick the right
289+ // literal-baked function here instead.
290+ handleSteps : isFree
291+ ? function * ( { params } ) {
292+ while ( true ) {
293+ yield {
294+ toolName : 'spawn_agent_inline' ,
295+ input : {
296+ agent_type : 'context-pruner' ,
297+ params : { ...( params ?? { } ) , cacheExpiryMs : 10 * 60 * 1000 } ,
298+ } ,
299+ includeToolCall : false ,
300+ } as any
301+
302+ const { stepsComplete } = yield 'STEP'
303+ if ( stepsComplete ) break
304+ }
305+ }
306+ : function * ( { params } ) {
307+ while ( true ) {
308+ yield {
309+ toolName : 'spawn_agent_inline' ,
310+ input : {
311+ agent_type : 'context-pruner' ,
312+ params : params ?? { } ,
313+ } ,
314+ includeToolCall : false ,
315+ } as any
316+
317+ const { stepsComplete } = yield 'STEP'
318+ if ( stepsComplete ) break
319+ }
320+ } ,
303321 }
304322}
305323
0 commit comments