mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(auto/coordinator): restart after cross-check failure
This commit is contained in:
@@ -771,6 +771,7 @@ fn run_auto_loop(
|
||||
let observer_cadence_enabled = config.tui.auto_drive.observer_enabled;
|
||||
let observer_thread_enabled = observer_cadence_enabled || cross_check_enabled;
|
||||
let mut observer_bootstrapped = !observer_thread_enabled;
|
||||
let mut cross_check_restart_conversation: Option<Vec<ResponseItem>> = None;
|
||||
let mut observer_handle = if observer_thread_enabled {
|
||||
match start_auto_observer(client.clone(), observer_cadence, cmd_tx.clone()) {
|
||||
Ok(handle) => Some(handle),
|
||||
@@ -946,6 +947,7 @@ fn run_auto_loop(
|
||||
Ok(()) => {
|
||||
awaiting_cross_check = true;
|
||||
observer_last_sent = observer_current_len;
|
||||
cross_check_restart_conversation = Some(conv_for_observer.clone());
|
||||
pending_success = Some(decision_event);
|
||||
continue;
|
||||
}
|
||||
@@ -1077,6 +1079,7 @@ fn run_auto_loop(
|
||||
if let ObserverReason::CrossCheck { summary, .. } = reason {
|
||||
awaiting_cross_check = false;
|
||||
if matches!(status, AutoObserverStatus::Ok) {
|
||||
cross_check_restart_conversation = None;
|
||||
if let Some(decision) = pending_success.take() {
|
||||
app_event_tx.send(decision.into_event());
|
||||
stopped = true;
|
||||
@@ -1101,23 +1104,38 @@ fn run_auto_loop(
|
||||
});
|
||||
}
|
||||
let failure_message = detail
|
||||
.clone()
|
||||
.map(|text| format!("Cross-check failed: {text}"))
|
||||
.unwrap_or_else(|| "Cross-check failed".to_string());
|
||||
let _ = app_event_tx.send(AppEvent::AutoCoordinatorThinking {
|
||||
delta: CROSS_CHECK_RESTART_BANNER.to_string(),
|
||||
summary_index: None,
|
||||
});
|
||||
let fail_event = AppEvent::AutoCoordinatorDecision {
|
||||
status: AutoCoordinatorStatus::Failed,
|
||||
progress_past: None,
|
||||
progress_current: Some(failure_message),
|
||||
cli: None,
|
||||
agents_timing: None,
|
||||
agents: Vec::new(),
|
||||
transcript: Vec::new(),
|
||||
};
|
||||
app_event_tx.send(fail_event);
|
||||
stopped = true;
|
||||
let _ = app_event_tx.send(AppEvent::AutoCoordinatorThinking {
|
||||
delta: failure_message.clone(),
|
||||
summary_index: None,
|
||||
});
|
||||
|
||||
let mut restart_conversation = cross_check_restart_conversation
|
||||
.take()
|
||||
.unwrap_or_else(|| conversation.clone());
|
||||
|
||||
if let Some(text) = detail {
|
||||
let prompt = format!(
|
||||
"Observer cross-check flagged unresolved issues:\n{text}\nPlease address these items before retrying completion."
|
||||
);
|
||||
restart_conversation.push(ResponseItem::Message {
|
||||
id: None,
|
||||
role: "user".to_string(),
|
||||
content: vec![ContentItem::InputText { text: prompt }],
|
||||
});
|
||||
}
|
||||
|
||||
if restart_conversation.is_empty() {
|
||||
restart_conversation = conversation;
|
||||
}
|
||||
|
||||
pending_conversation = Some(restart_conversation);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user