Fix live activity streaming and replay summary
This commit is contained in:
+17
-1
@@ -1901,7 +1901,14 @@ def create_app(state: AgentState) -> FastAPI:
|
||||
break
|
||||
yield json.dumps(item, ensure_ascii=False) + '\n'
|
||||
|
||||
return StreamingResponse(generate(), media_type='application/x-ndjson')
|
||||
return StreamingResponse(
|
||||
generate(),
|
||||
media_type='application/x-ndjson',
|
||||
headers={
|
||||
'Cache-Control': 'no-cache, no-transform',
|
||||
'X-Accel-Buffering': 'no',
|
||||
},
|
||||
)
|
||||
|
||||
@app.post('/api/clear')
|
||||
async def clear_state(account_id: str | None = None) -> dict[str, Any]:
|
||||
@@ -2117,12 +2124,17 @@ def _interrupted_session_message(status: str) -> str:
|
||||
|
||||
def _runtime_event_stage(event: dict[str, object]) -> str:
|
||||
event_type = event.get('type')
|
||||
if event_type == 'content_delta':
|
||||
return ''
|
||||
if event_type == 'tool_start':
|
||||
stage_note = str(event.get('assistant_content') or '').strip()
|
||||
if stage_note.startswith(('进度:', '进度:')):
|
||||
return stage_note
|
||||
tool_name = str(event.get('tool_name') or '').strip()
|
||||
return f'调用工具 {tool_name}' if tool_name else '正在调用工具'
|
||||
if event_type == 'tool_delta':
|
||||
tool_name = str(event.get('tool_name') or '').strip()
|
||||
return f'{tool_name} 输出中' if tool_name else '工具输出中'
|
||||
if event_type == 'tool_result':
|
||||
tool_name = str(event.get('tool_name') or '').strip()
|
||||
return f'工具完成 {tool_name}' if tool_name else '工具调用完成'
|
||||
@@ -2149,7 +2161,9 @@ def _runtime_event_stage(event: dict[str, object]) -> str:
|
||||
_RUN_EVENT_TYPES = {
|
||||
'run_queued',
|
||||
'run_started',
|
||||
'content_delta',
|
||||
'tool_start',
|
||||
'tool_delta',
|
||||
'tool_result',
|
||||
'final_text_start',
|
||||
'final_text_end',
|
||||
@@ -2175,8 +2189,10 @@ def _normalize_run_event(event: dict[str, object]) -> dict[str, Any] | None:
|
||||
'tool_name',
|
||||
'tool_call_id',
|
||||
'arguments',
|
||||
'delta',
|
||||
'assistant_content',
|
||||
'message_id',
|
||||
'stream',
|
||||
'ok',
|
||||
'metadata',
|
||||
'reason',
|
||||
|
||||
Reference in New Issue
Block a user