LangGraph Pipeline (deer-flow)
Relevant source files
The following files were used as context for generating this wiki page:
The LangGraph Pipeline (deer-flow) is a specialized agentic workflow architecture within the Flow platform designed for complex, multi-step reasoning and research tasks. It utilizes a structured sequence of nodes—primarily comprising a planner, a worker, and a synthesizer—to process user queries, perform intensive data retrieval, and generate cited, high-fidelity responses. Sources: README.md:91, AGENTS.md:14.
Within the broader system, the deer-flow template is distinguished from simpler react-agent or tool-agent templates by its explicit separation of planning from execution and its focus on structured output schemas. Sources: services/api/scripts/seed_agents_and_datasets.py:75-125.
Architecture and Execution Flow
The deer-flow pipeline operates as a linear sequence of functional stages, often integrated with a retrieval-augmented generation (RAG) loop. The primary objective is to move from unstructured user input to a structured, cited response.
Core Pipeline Stages
| Stage | Responsibility |
|---|---|
| Planner | Decomposes the user request into actionable steps and identifies required resources. |
| Worker | Executes the plan using tools (Knowledge search, Web search, Memory) and retrieves context. |
| Synthesizer | Aggregates worker outputs into a final response and generates citations. |
Sources: README.md:91-95, AGENTS.md:14.
Flow Diagram
The following diagram illustrates the standard execution path of a deer-flow pipeline execution:
The pipeline transitions from planning to active tool use (Worker) before concluding with synthesis and streaming. Sources: README.md:91-95, services/api/flow/interfaces/http/routes/meta.py:86-90.
State Management
The deer-flow pipeline maintains state through a TypedDict structure. In specialized implementations like the Research Analyst, the state manages both raw data from external tools and intermediate drafts.
ResearchState Definition
The pipeline state typically includes the following fields:
query: The original user string.arxiv_results: List of academic papers retrieved.web_results: Complementary context from web search providers (e.g., Tavily).draft_report: Intermediate text generation.final_report: The validated Pydantic object for the user.messages: The full history ofBaseMessageobjects.
Sources: services/api/scripts/seed_agents_and_datasets.py:100-110.
Agentic Implementation: Research Analyst
The Research Analyst is the primary agent utilizing the deer-flow template. Its specific logic involves a four-step internal protocol.
- Gather Sources: Concurrent search of arXiv and the web for recent context.
- Cross-Reference: Identification of contradictions and assignment of confidence levels (0.0–1.0) to findings.
- Structure Output: Formatting the result into a specific
ResearchReportJSON schema. - Quality Check: Verification that findings follow logically from retrieved sources.
Sources: services/api/scripts/seed_agents_and_datasets.py:76-96, services/api/scripts/seed_skills.py:270-285.
Tooling and Integration
The deer-flow worker node has access to a variety of configurable tools, which are defined in the agent's genome configuration.
Available Tools
- Knowledge Search: Uses
pgvectorcosine similarity to retrieve up to 8 chunks from uploaded documents. - Long-term Memory: Recalls past execution summaries via the
AsyncPostgresStore. - Web Search: Integration with
Tavilyfor real-time web context. - Specialized Search: Includes
arxiv_searchandhf_papersfor technical research.
Sources: README.md:98-106, services/api/scripts/seed_agents_and_datasets.py:91-98.
Sequence Diagram: Streaming and Citations
The pipeline utilizes Server-Sent Events (SSE) to deliver results to the frontend.
The synthesizer emits a citations SSE frame which the frontend uses to render the Sources panel before or during the streaming of the text response. Sources: README.md:91-96, AGENTS.md:25.
Visualization and Monitoring
The deer-flow pipeline is observable via the Graph Explorer in the web interface. This interface maps the pipeline topology to a React Flow-style canvas. Sources: apps/web/src/app/(app)/graph/page.tsx:120-150.
The FlowCallbackHandler instruments the execution by tracking:
- Per-call latency for LLM and tool nodes.
- Log events such as
llm.start,llm.end, andtool.start. - Metadata including
execution_idandtemplate.
Sources: README.md:154-162.
Summary
The deer-flow pipeline provides a robust, multi-stage execution environment for agents that require more than a simple single-turn response. By separating planning, research (Worker), and structured synthesis, it ensures high-quality, verifiable outputs suitable for academic and technical research tasks within the Flow platform. Sources: AGENTS.md:14, README.md:20.