Emit final agent_update events so all dots turn green at completion

The final decision block set all agents to "completed" in buf but never
emitted agent_update SSE events for them. This left Risk stage dots as
cyan (active) and Decision dot as gray on the UI. Now emits agent_update
for any agents not yet shown as completed before the decision event.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dtarkent2-sys 2026-02-20 11:53:03 +00:00
parent 67463a2b99
commit aa654c9425
1 changed files with 13 additions and 0 deletions

13
app.py
View File

@ -300,6 +300,19 @@ async def run_analysis(analysis_id: str, ticker: str, trade_date: str):
for agent in buf.agent_status:
buf.update_agent_status(agent, "completed")
st = get_stats_dict(stats_handler, buf, start_time)
# Emit agent_update for any agents not yet shown as completed on the client
for agent, status in buf.agent_status.items():
if prev_statuses.get(agent) != "completed":
prev_statuses[agent] = "completed"
evt = {
"type": "agent_update",
"agent": agent,
"stage": _agent_stage(agent),
"status": "completed",
"stats": st,
}
state["events"].append(evt)
await q.put(evt)
evt = {
"type": "decision",
"stage": "decision",