fix(engine): report loop guard halt as Failed instead of Completed#1859
Open
harvey2011888 wants to merge 1 commit into
Open
fix(engine): report loop guard halt as Failed instead of Completed#1859harvey2011888 wants to merge 1 commit into
harvey2011888 wants to merge 1 commit into
Conversation
When the LoopGuard triggers a halt (tool failed 8 times consecutively), the turn loop would break but turn_error remained None, causing TurnOutcomeStatus::Completed to be returned instead of Failed. Now turn_error is set with the halt message so the correct status is returned.
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies the turn loop logic in crates/tui/src/core/engine/turn_loop.rs to ensure that a loop guard halt correctly triggers a Failed outcome status by assigning the halt message to turn_error. The review feedback identifies a consistency issue where a new comment was added in Chinese, whereas the rest of the codebase uses English, and provides a suggested translation.
| crate::logging::warn(message.clone()); | ||
| let _ = self.tx_event.send(Event::status(message)).await; | ||
| let _ = self.tx_event.send(Event::status(message.clone())).await; | ||
| // 设置 turn_error 以确保最终返回 TurnOutcomeStatus::Failed 而非 Completed |
Contributor
There was a problem hiding this comment.
The comment is in Chinese, while the rest of the codebase and this file specifically use English for comments and documentation. For consistency and to ensure the code remains accessible to all contributors, please use English for this comment.
Suggested change
| // 设置 turn_error 以确保最终返回 TurnOutcomeStatus::Failed 而非 Completed | |
| // Set turn_error to ensure the final return is TurnOutcomeStatus::Failed instead of Completed |
This was referenced May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When the LoopGuard triggers a halt (tool failed 8 times consecutively), the turn loop executes �reak but urn_error remains None, causing TurnOutcomeStatus::Completed to be returned instead of Failed.
This misleads the user into thinking the turn succeeded when it was actually forcefully terminated.
Fix
Set urn_error with the halt message before breaking out of the loop, so the final return correctly yields TurnOutcomeStatus::Failed with the error message.
Changes
Verification