Skip to content

Commit f3ced9c

Browse files
committed
fix(agent): await endExecution in onAgentLoopEnd for streaming mode
In streaming mode, onAgentLoopEnd called endExecution() as fire-and-forget (.catch() without await), so the cleanup handler that sends the agent_run_end event could complete after the method returned. This caused the Web UI to never receive the termination signal, leaving it stuck in a spinning state. Properly await endExecution() to ensure the agent_run_end event is sent before the streaming promise chain completes. Closes #1061
1 parent 239b654 commit f3ced9c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • multimodal/tarko/agent/src/agent

multimodal/tarko/agent/src/agent/agent.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,11 @@ Provide concise and accurate responses.`;
616616

617617
// End execution if not already ended
618618
if (this.executionController.isExecuting()) {
619-
this.executionController.endExecution(AgentStatus.IDLE).catch((err) => {
619+
try {
620+
await this.executionController.endExecution(AgentStatus.IDLE);
621+
} catch (err) {
620622
this.logger.error(`Error ending execution: ${err}`);
621-
});
623+
}
622624
}
623625
}
624626

0 commit comments

Comments
 (0)