mirror of
https://github.com/langgenius/dify.git
synced 2026-05-30 21:57:46 +08:00
``AgentAppRunner`` runs one conversation turn against the dify-agent backend (instead of the legacy in-process ReAct loop): load the conversation's prior session_snapshot, build the run request (S2b), create the run, consume the event stream, and republish the assistant answer as chat queue events (``QueueLLMChunkEvent`` + ``QueueMessageEndEvent``) so the existing EasyUI chat task pipeline persists the message and streams SSE. On success the conversation session_snapshot is saved for multi-turn continuity; failures raise AgentBackendError; the answer is normalized to text (plain string or structured JSON). MVP emits the final answer as one chunk + message-end; token-level streaming is a follow-up refinement. The generator/entity/converter wiring + live-stack verification land next. Tests: 4 runner cases via the deterministic fake backend client + fake queue (success→chunk+end+session-save, prior-snapshot threading, failure raises, answer extraction). 15 agent_app unit tests green; ruff + pyrefly clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>