fix: don't reset chat status to Ready while tools are executing#1283
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the chat interface incorrectly displayed "Ready" status while agent tools were still executing. The root cause was that the finally block in the handleSendMessage function unconditionally reset the chat status to "ready" after the SSE stream loop ended, which prematurely overrode the transitional statuses ("processing_tools", "generating_response") that were correctly set by message handlers during ongoing tool execution.
Changes:
- Removed the unconditional
setChatStatus("ready")call from the finally block inhandleSendMessage - Added explanatory comments documenting that message handlers already set the appropriate status when final stream events arrive
- Error paths continue to correctly set their own status via their respective catch blocks
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
EItanya
left a comment
There was a problem hiding this comment.
Hey there thanks for the fix, in order for me to approve DCO needs to pass. In order for it to pass you'll need to sign all of your commits
Remove the unconditional setChatStatus('ready') from the finally block
in handleSendMessage. The message handlers (finalizeStreaming,
handleA2ATaskStatusUpdate, handleA2ATaskArtifactUpdate) already set the
correct status when the final stream event arrives. The unconditional
reset was overriding transitional states like 'processing_tools' and
'generating_response', causing the UI to show 'Ready' while tools were
still executing.
Error paths (AbortError, streaming failures, session creation errors)
still correctly set their own status via their respective catch blocks.
Fixes kagent-dev#325
Signed-off-by: OpSpawn <opspawn@users.noreply.github.com>
80cbb6b to
5f5cd10
Compare
|
Hi @EItanya, just wanted to follow up -- the DCO check is now passing. Would you be able to re-review this PR when you get a chance? Happy to make any further changes if needed. Thanks! |
Summary
Fixes the chat interface showing "Ready" while tools are still executing (#325).
Problem
The
finallyblock inhandleSendMessageunconditionally calledsetChatStatus('ready')after the SSE stream loop ended. This overrode transitional statuses likeprocessing_toolsandgenerating_responsethat were correctly set by the message handlers during tool execution.Fix
Removed the unconditional
setChatStatus('ready')from thefinallyblock. The message handlers (finalizeStreaming,handleA2ATaskStatusUpdate,handleA2ATaskArtifactUpdate) already set the correct status when the final stream event arrives. Error paths (AbortError, streaming failures, session creation errors) still correctly set their own status via their respective catch blocks.Fixes #325