feat(subagent): emit reasoning text as progress in StepCompleted events
This commit is contained in:
@@ -416,6 +416,15 @@ pub fn run_subagent(ctx: &SubagentContext, tx: &mpsc::Sender<SubagentEvent>) ->
|
||||
|
||||
let content = response.content.clone().unwrap_or_default();
|
||||
|
||||
// Emit thinking/reasoning text as StepCompleted so the parent's
|
||||
// drain thread can show it as progress instead of just the tool name.
|
||||
if !content.is_empty() {
|
||||
let _ = tx.blocking_send(SubagentEvent::StepCompleted {
|
||||
step,
|
||||
output: content.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
if has_tool_calls {
|
||||
let tool_calls = response.tool_calls.clone().unwrap_or_default();
|
||||
// Push the assistant message with tool_calls into the conversation
|
||||
|
||||
@@ -211,8 +211,29 @@ fn spawn_single_agent(
|
||||
);
|
||||
}
|
||||
}
|
||||
SubagentEvent::StepCompleted { .. } => {
|
||||
tracing::trace!("[subagent] step completed");
|
||||
SubagentEvent::StepCompleted { output, .. } => {
|
||||
// Show the agent's thinking/reasoning text as progress
|
||||
// instead of just the tool name — first line, truncated.
|
||||
if let Some(ref f) = drain_live {
|
||||
let summary = output
|
||||
.lines()
|
||||
.next()
|
||||
.unwrap_or(output)
|
||||
.chars()
|
||||
.take(80)
|
||||
.collect::<String>();
|
||||
f(
|
||||
drain_agent_id.clone(),
|
||||
drain_agent_name.clone(),
|
||||
AgentStatus {
|
||||
state: AgentState::Running,
|
||||
started_at: Some(drain_started_at),
|
||||
completed_at: None,
|
||||
error: None,
|
||||
progress: Some(summary),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
SubagentEvent::StepFailed { step, error } => {
|
||||
tracing::warn!("[subagent] step {} failed: {}", step, error);
|
||||
|
||||
Reference in New Issue
Block a user