feat(agent): SSE — progressive Themen-Tabs (Phase 2)
Der Compliance-Check streamt jetzt progressive Events; der Impressum-Tab
erscheint, sobald das Thema fertig ist, statt am Ende alles auf einmal.
Additiv — das Polling fürs finale Ergebnis bleibt.
- backend: _sse.py (Queue/emit/event_generator) + Endpoint
/compliance-check/{id}/stream; _update emittiert progress,
run_agent_outputs emittiert topic (laeuft jetzt frueh nach Phase B),
Orchestrator emittiert complete/error.
- frontend: SSE-Proxy-Route + EventSource in ComplianceCheckTab merged
topic-Events in agent_outputs -> Tab erscheint progressiv.
- Tests: backend 5 passed (SSE + agent_outputs); tsc 0 neue Fehler,
vitest 2 passed, check-loc 0.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,8 @@ import logging
|
||||
|
||||
from compliance.services.specialist_agents import REGISTRY, AgentInput
|
||||
|
||||
from ._sse import emit
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# topic key (matches state["doc_texts"]) -> registered agent_id
|
||||
@@ -43,7 +45,9 @@ def _derive_scope(profile_dict: dict) -> list[str]:
|
||||
|
||||
async def run_agent_outputs(state: dict) -> None:
|
||||
"""Für jedes Topic mit registriertem v3-Agent + ausreichend Text:
|
||||
Agent laufen lassen und den strukturierten AgentOutput ablegen."""
|
||||
Agent laufen lassen, AgentOutput ablegen + als SSE topic-Event
|
||||
emittieren (Tab füllt sich progressiv)."""
|
||||
check_id = state.get("check_id", "")
|
||||
doc_texts = state.get("doc_texts") or {}
|
||||
profile_dict = state.get("profile_dict") or {}
|
||||
req = state.get("req")
|
||||
@@ -75,6 +79,8 @@ async def run_agent_outputs(state: dict) -> None:
|
||||
origin_domain=origin_domain,
|
||||
))
|
||||
outputs[topic] = out.model_dump(mode="json")
|
||||
emit(check_id, {"type": "topic", "topic": topic,
|
||||
"output": outputs[topic]})
|
||||
logger.info(
|
||||
"agent_outputs[%s]: %d findings, confidence %.2f",
|
||||
topic, len(out.findings), out.confidence,
|
||||
|
||||
Reference in New Issue
Block a user