Skip to content

fix(engine): report loop guard halt as Failed instead of Completed#1859

Open
harvey2011888 wants to merge 1 commit into
Hmbown:mainfrom
harvey2011888:fix/loop-guard-halt-status
Open

fix(engine): report loop guard halt as Failed instead of Completed#1859
harvey2011888 wants to merge 1 commit into
Hmbown:mainfrom
harvey2011888:fix/loop-guard-halt-status

Conversation

@harvey2011888
Copy link
Copy Markdown

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

  • File: crates/tui/src/core/engine/turn_loop.rs
  • Added urn_error = Some(message) in the loop_guard_halt branch before �reak
  • Cloned message for the event send (since it's now moved into urn_error)

Verification

  • cargo check -p deepseek-tui passes

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.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants