Skip to content

Commit d90c5f8

Browse files
authored
Merge pull request #9899 from continuedev/fix/agent-iscomplete-metadata
Fix: Set isComplete=true after agent turn ends without tool calls
2 parents 6863397 + ebc81a6 commit d90c5f8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

extensions/cli/src/commands/serve.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)