File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
extensions/cli/src/commands Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -529,7 +529,19 @@ export async function serve(prompt?: string, options: ServeOptions = {}) {
529529 // Update metadata after successful agent turn
530530 try {
531531 const history = services . chatHistory ?. getHistory ( ) ;
532- await updateAgentMetadata ( history ) ;
532+
533+ // Check if the agent should be marked as complete
534+ // The agent is complete if the last message is from the assistant and has no tool calls
535+ let isComplete = false ;
536+ if ( history && history . length > 0 ) {
537+ const lastItem = history [ history . length - 1 ] ;
538+ if ( lastItem ?. message ?. role === "assistant" ) {
539+ const toolCalls = ( lastItem . message as any ) . tool_calls ;
540+ isComplete = ! toolCalls || toolCalls . length === 0 ;
541+ }
542+ }
543+
544+ await updateAgentMetadata ( { history, isComplete } ) ;
533545 } catch ( metadataErr ) {
534546 // Non-critical: log but don't fail the agent execution
535547 logger . debug (
You can’t perform that action at this time.
0 commit comments