Fix live activity timer

This commit is contained in:
wuyang6
2026-05-14 18:12:11 +08:00
parent 87dd67c76a
commit 119e329dfb
2 changed files with 14 additions and 6 deletions
+5 -1
View File
@@ -485,6 +485,7 @@ class RunManager:
'current_stage': record.current_stage,
'started_at': record.started_at,
'updated_at': record.updated_at,
'elapsed_ms': max(0, int((time.time() - record.started_at) * 1000)),
'pending_prompt': record.pending_prompt,
'error': record.error,
'events': [dict(event) for event in record.events],
@@ -1612,7 +1613,10 @@ def create_app(state: AgentState) -> FastAPI:
merged['events'] = stored_snapshot.get('events')
if memory_snapshot.get('current_stage'):
merged['current_stage'] = memory_snapshot.get('current_stage')
if stored_snapshot.get('elapsed_ms') is not None:
if (
memory_snapshot.get('status') not in ACTIVE_RUN_STATUSES
and stored_snapshot.get('elapsed_ms') is not None
):
merged['elapsed_ms'] = stored_snapshot.get('elapsed_ms')
if stored_snapshot.get('finished_at') is not None:
merged['finished_at'] = stored_snapshot.get('finished_at')