huskies: merge 551_bug_get_agent_output_mcp_tool_returns_fetch_failed_for_running_agents

This commit is contained in:
dave
2026-04-12 17:46:55 +00:00
parent ae4cacefe8
commit 05c3b11e57
2 changed files with 7 additions and 162 deletions
+7 -2
View File
@@ -142,8 +142,13 @@ pub(super) async fn tool_get_agent_output(
all_lines.push(String::new()); // blank line between sessions
}
// Append buffered live events when a specific agent is requested.
if let Some(agent_name) = agent_name_filter
// Append buffered live events only when no disk logs exist yet.
// emit_event() writes to disk synchronously, so disk is always up-to-date
// when log files are present. Showing live events alongside disk logs would
// produce duplicates. Only fall back to in-memory events when the log
// writer failed and nothing was persisted to disk.
if log_files.is_empty()
&& let Some(agent_name) = agent_name_filter
&& let Ok(live_events) = ctx.agents.drain_events(story_id, agent_name)
&& !live_events.is_empty()
{