Skip to content

Commit df45c44

Browse files
echobtfactorydroid
andauthored
fix(subagent): add logging for silent errors in subagent communication (#310)
- Replace silent 'let _ =' patterns with proper error logging in spawn_subagent - Log errors when ToolEvent channel send fails (Started, Failed, Completed, TodoUpdated) - Add warning when stream ends without Done event - Log status update failures in AgentThread.set_status() This helps diagnose issues where subagents stop without returning results. Co-authored-by: Droid <droid@factory.ai>
1 parent d1d3e3a commit df45c44

File tree

2 files changed

+414
-373
lines changed

2 files changed

+414
-373
lines changed

cortex-agents/src/control.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
66
use crate::AgentInfo;
77
use std::collections::HashMap;
8-
use std::sync::atomic::{AtomicUsize, Ordering};
98
use std::sync::Arc;
10-
use tokio::sync::{watch, RwLock};
9+
use std::sync::atomic::{AtomicUsize, Ordering};
10+
use tokio::sync::{RwLock, watch};
1111
use uuid::Uuid;
1212

1313
/// Unique identifier for an agent thread.
@@ -39,9 +39,10 @@ impl std::fmt::Display for AgentThreadId {
3939
}
4040

4141
/// Status of an agent in the control system.
42-
#[derive(Debug, Clone, PartialEq, Eq)]
42+
#[derive(Debug, Clone, PartialEq, Eq, Default)]
4343
pub enum AgentThreadStatus {
4444
/// Agent is being initialized.
45+
#[default]
4546
PendingInit,
4647
/// Agent is running.
4748
Running,
@@ -68,12 +69,6 @@ impl AgentThreadStatus {
6869
}
6970
}
7071

71-
impl Default for AgentThreadStatus {
72-
fn default() -> Self {
73-
AgentThreadStatus::PendingInit
74-
}
75-
}
76-
7772
/// An agent thread managed by the control system.
7873
pub struct AgentThread {
7974
/// Thread ID.
@@ -119,7 +114,13 @@ impl AgentThread {
119114

120115
/// Update status.
121116
pub fn set_status(&self, status: AgentThreadStatus) {
122-
let _ = self.status_tx.send(status);
117+
if self.status_tx.send(status.clone()).is_err() {
118+
tracing::warn!(
119+
"Failed to send status update {:?} for agent {} - all receivers dropped",
120+
status,
121+
self.id
122+
);
123+
}
123124
}
124125

125126
/// Subscribe to status updates.

0 commit comments

Comments
 (0)