fix(executor): propagate complete_turn failure instead of silent warn#648
fix(executor): propagate complete_turn failure instead of silent warn#648majiayu000 merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances error handling in the run_turn_lifecycle function by logging detailed error information and explicitly marking turns as failed when completion fails. The review feedback suggests improving consistency with other error handling paths by recording an error item in the thread history and persisting the thread state before marking the turn as failed.
| Err(err) => { | ||
| tracing::error!( | ||
| thread_id = %thread_id, | ||
| turn_id = %turn_id, | ||
| "failed to complete turn after execution: {err}" | ||
| ); | ||
| mark_turn_failed( | ||
| &server, | ||
| &thread_db, | ||
| ¬ify_tx, | ||
| ¬ification_tx, | ||
| &thread_id, | ||
| &turn_id, | ||
| err.to_string(), | ||
| ) | ||
| .await; | ||
| } |
There was a problem hiding this comment.
To maintain consistency with the error handling logic used when the agent execution itself fails (lines 319-343), consider adding an error item to the turn history and persisting the thread state before marking the turn as failed. This ensures that the system failure during the completion phase is recorded in the thread's item history, providing better visibility in the UI and audit logs.
Err(err) => {
let error_msg = err.to_string();
tracing::error!(
thread_id = %thread_id,
turn_id = %turn_id,
"failed to complete turn after execution: {error_msg}"
);
if let Err(e) = server.thread_manager.add_item(
&thread_id,
&turn_id,
harness_core::types::Item::Error {
code: -1,
message: format!("Failed to complete turn: {error_msg}"),
},
) {
tracing::warn!("failed to add error item to turn: {e}");
} else {
persist_runtime_thread(&thread_db, &server, &thread_id).await;
}
mark_turn_failed(
&server,
&thread_db,
¬ify_tx,
¬ification_tx,
&thread_id,
&turn_id,
error_msg,
)
.await;
}|
/gemini review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
/gemini review |
6aa7a6d to
87c03ea
Compare
|
/gemini review |
When complete_turn fails after successful agent execution, the turn state
is left inconsistent — the agent finished but no TurnCompleted notification
is emitted and the thread state is never persisted. This violates U-29
(no silent degradation when user-visible data is affected).
Fix: replace tracing::warn with tracing::error (with structured thread_id
and turn_id fields) and call mark_turn_failed so the turn is properly
marked failed, the thread is persisted, and a TurnCompleted{Failed}
notification is emitted to downstream consumers.
Closes #626
Signed-off-by: majiayu000 <1835304752@qq.com>
…failure Before marking the turn failed when complete_turn errors, add an Error item to the turn history and persist the thread state. This mirrors the existing pattern used when agent execution itself fails (lines 319-343) and ensures the failure is visible in the UI and audit logs. Signed-off-by: majiayu000 <1835304752@qq.com>
87c03ea to
28b67f9
Compare
|
/gemini review |
Summary
Test plan