Fix: Set isComplete=true after agent turn ends without tool calls #9899
+13
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When an agent completes a turn with a final response (no tool calls), we now correctly set isComplete=true in the metadata. Previously, isComplete was only set when Exit, ReportFailure, or Status tools were called, or when the server shut down. This caused agents that gave final responses to remain in 'running' state indefinitely.
The fix checks the last message in history after each turn - if it's from the assistant and has no tool_calls, the agent is marked as complete.
Description
[ What changed? Feel free to be brief. ]
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]
Tests
[ What tests were added or updated to ensure the changes work as expected? ]
Continue Tasks:▶️ 2 queued — View all
Summary by cubic
Mark agents as complete when they finish with a final assistant response (no tool calls), preventing sessions from getting stuck in “running.” Metadata is updated immediately after each turn.
Written for commit ebc81a6. Summary will update on new commits.