@@ -216,25 +216,37 @@ export async function runStepFresh(ctx: RunnerContext): Promise<RunStepResult |
216216 session . setOutput ( stepOutput ) ;
217217 const loaded = session . loadChainedPrompts ( output . chainedPrompts ) ;
218218 if ( loaded ) {
219+ // Has chained prompts - go to awaiting state
219220 session . markAwaiting ( ) ;
220221 if ( ! machineCtx . autoMode ) {
221222 ctx . emitter . updateAgentStatus ( uniqueAgentId , 'awaiting' ) ;
222223 }
224+ ctx . machine . send ( { type : 'STEP_COMPLETE' , output : stepOutput } ) ;
225+ return { output : stepOutput } ;
223226 } else if ( session . promptQueue . length === 0 ) {
224- // Truly no prompts - complete the session
227+ // No prompts - complete and go directly to next step
225228 await session . complete ( ) ;
226229 ctx . emitter . updateAgentStatus ( uniqueAgentId , 'completed' ) ;
230+ await ctx . indexManager . stepCompleted ( stepIndex ) ;
231+ ctx . machine . send ( { type : 'SKIP' } ) ;
232+ return { output : stepOutput } ;
227233 }
228- // If prompts exist but already loaded, no action needed - indexManager has the state
234+ // If prompts exist but already loaded, fall through to STEP_COMPLETE
229235 } else if ( output . chainedPrompts && output . chainedPrompts . length > 0 ) {
230- // No session - use indexManager directly
236+ // No session but has chained prompts - go to awaiting state
231237 ctx . indexManager . initQueue ( output . chainedPrompts , 0 ) ;
232238 if ( ! machineCtx . autoMode ) {
233239 ctx . emitter . updateAgentStatus ( uniqueAgentId , 'awaiting' ) ;
234240 }
241+ ctx . machine . send ( { type : 'STEP_COMPLETE' , output : stepOutput } ) ;
242+ return { output : stepOutput } ;
235243 } else {
244+ // No session, no chained prompts - go directly to next step
236245 ctx . emitter . updateAgentStatus ( uniqueAgentId , 'completed' ) ;
237246 ctx . indexManager . resetQueue ( ) ;
247+ await ctx . indexManager . stepCompleted ( stepIndex ) ;
248+ ctx . machine . send ( { type : 'SKIP' } ) ;
249+ return { output : stepOutput } ;
238250 }
239251
240252 ctx . machine . send ( { type : 'STEP_COMPLETE' , output : stepOutput } ) ;
0 commit comments