feat(subagent): emit reasoning text as progress in StepCompleted events

This commit is contained in:
asepharyana
2026-07-15 02:25:15 +07:00
parent dfceb8acac
commit 97aa75f2da
2 changed files with 32 additions and 2 deletions
+9
View File
@@ -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
+23 -2
View File
@@ -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);