subagents (#2797)
Co-authored-by: Lily Delalande <ldelalande@squareup.com>
This commit is contained in:
@@ -618,6 +618,7 @@ async fn process_message_streaming(
|
||||
// Log model change
|
||||
tracing::info!("Model changed to {} in {} mode", model, mode);
|
||||
}
|
||||
|
||||
Err(e) => {
|
||||
error!("Error in message stream: {}", e);
|
||||
let mut sender = sender.lock().await;
|
||||
|
||||
@@ -906,23 +906,87 @@ impl Session {
|
||||
match method.as_str() {
|
||||
"notifications/message" => {
|
||||
let data = o.get("data").unwrap_or(&Value::Null);
|
||||
let message = match data {
|
||||
Value::String(s) => s.clone(),
|
||||
let (formatted_message, subagent_id, _notification_type) = match data {
|
||||
Value::String(s) => (s.clone(), None, None),
|
||||
Value::Object(o) => {
|
||||
if let Some(Value::String(output)) = o.get("output") {
|
||||
output.to_owned()
|
||||
// Check for subagent notification structure first
|
||||
if let Some(Value::String(msg)) = o.get("message") {
|
||||
// Extract subagent info for better display
|
||||
let subagent_id = o.get("subagent_id")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("unknown");
|
||||
let notification_type = o.get("type")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
let formatted = match notification_type {
|
||||
"subagent_created" | "completed" | "terminated" => {
|
||||
format!("🤖 {}", msg)
|
||||
}
|
||||
"tool_usage" | "tool_completed" | "tool_error" => {
|
||||
format!("🔧 {}", msg)
|
||||
}
|
||||
"message_processing" | "turn_progress" => {
|
||||
format!("💭 {}", msg)
|
||||
}
|
||||
"response_generated" => {
|
||||
// Check verbosity setting for subagent response content
|
||||
let config = Config::global();
|
||||
let min_priority = config
|
||||
.get_param::<f32>("GOOSE_CLI_MIN_PRIORITY")
|
||||
.ok()
|
||||
.unwrap_or(0.5);
|
||||
|
||||
if min_priority > 0.1 && !self.debug {
|
||||
// High/Medium verbosity: show truncated response
|
||||
if let Some(response_content) = msg.strip_prefix("Responded: ") {
|
||||
if response_content.len() > 100 {
|
||||
format!("🤖 Responded: {}...", &response_content[..100])
|
||||
} else {
|
||||
format!("🤖 {}", msg)
|
||||
}
|
||||
} else {
|
||||
format!("🤖 {}", msg)
|
||||
}
|
||||
} else {
|
||||
// All verbosity or debug: show full response
|
||||
format!("🤖 {}", msg)
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
msg.to_string()
|
||||
}
|
||||
};
|
||||
(formatted, Some(subagent_id.to_string()), Some(notification_type.to_string()))
|
||||
} else if let Some(Value::String(output)) = o.get("output") {
|
||||
// Fallback for other MCP notification types
|
||||
(output.to_owned(), None, None)
|
||||
} else {
|
||||
data.to_string()
|
||||
(data.to_string(), None, None)
|
||||
}
|
||||
},
|
||||
v => {
|
||||
v.to_string()
|
||||
(v.to_string(), None, None)
|
||||
},
|
||||
};
|
||||
if interactive {
|
||||
output::set_thinking_message(&message);
|
||||
|
||||
// Handle subagent notifications - show immediately
|
||||
if let Some(_id) = subagent_id {
|
||||
// Show subagent notifications immediately (no buffering) with compact spacing
|
||||
if interactive {
|
||||
let _ = progress_bars.hide();
|
||||
println!("{}", console::style(&formatted_message).green().dim());
|
||||
} else {
|
||||
progress_bars.log(&formatted_message);
|
||||
}
|
||||
} else {
|
||||
progress_bars.log(&message);
|
||||
// Non-subagent notification, display immediately with compact spacing
|
||||
if interactive {
|
||||
let _ = progress_bars.hide();
|
||||
println!("{}", console::style(&formatted_message).green().dim());
|
||||
} else {
|
||||
progress_bars.log(&formatted_message);
|
||||
}
|
||||
}
|
||||
},
|
||||
"notifications/progress" => {
|
||||
@@ -951,6 +1015,7 @@ impl Session {
|
||||
eprintln!("Model changed to {} in {} mode", model, mode);
|
||||
}
|
||||
}
|
||||
|
||||
Some(Err(e)) => {
|
||||
eprintln!("Error: {}", e);
|
||||
drop(stream);
|
||||
|
||||
@@ -117,6 +117,7 @@ pub fn hide_thinking() {
|
||||
THINKING.with(|t| t.borrow_mut().hide());
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn set_thinking_message(s: &String) {
|
||||
THINKING.with(|t| {
|
||||
if let Some(spinner) = t.borrow_mut().spinner.as_mut() {
|
||||
|
||||
Reference in New Issue
Block a user