Enterprise Deep Research Agent (Dify)
A Deep Research system built as a Dify low-code workflow: it classifies intent, decomposes a topic into 2–3 sub-questions, runs a ReAct agent that iteratively searches (Tavily) and extracts evidence with citations, then has an LLM write a Markdown report with footnote references.
Built as a Dify advanced-chat workflow, not a hand-rolled Python agent. The interesting work is the graph design: a three-way intent gate, topic decomposition, an iterative ReAct research agent over Tavily, evidence accumulation with stable source IDs, and an LLM report writer with footnote citations.
Overview
Deep Research means more than "search and summarize": decompose a question, gather evidence from multiple sources,
keep track of where each claim came from, and write it up with citations a human can verify. This project implements
that loop as a Dify workflow (Agent_深度搜索_加强版.yml, mode: advanced-chat). You give it a research topic;
it returns a structured Markdown report with footnoted sources.
It uses DeepSeek for the reasoning stages (intent, decomposition, the research agent) and Qwen3-max (Tongyi) for the final report writing, with Tavily Search + Tavily Extract as the web tools.
Workflow graph
START
└─ Intent classify (DeepSeek) → {NeedMoreInfo | Decompose | Execute}
├─ NeedMoreInfo → ask the user for the missing pieces, accumulate, loop back
├─ Decompose → propose a 2–3 item outline, ask the user to confirm
└─ Execute ↓
├─ Topic decompose (DeepSeek) → main_intent, key_dimensions,
│ subtopics[{title, description, suggested_query}]
├─ Iterate over subtopics (parallel):
│ └─ Research Agent (ReAct, DeepSeek)
│ ├─ tavily_search (focused query)
│ ├─ tavily_extract (≤2 URLs → markdown)
│ └─ emit JSON: {queries, new_sources, new_findings,
│ coverage, should_continue, stop_reason}
│ └─ Accumulate (code): URL→sid dedup, merge findings, append history
├─ Markdown format (code): sources → numbered reference list
└─ Report writer (Qwen3-max) → Markdown report with [^sid] footnotes
Design details that matter
-
Three-way intent gate. Before doing any work, an LLM node classifies the input as
NeedMoreInfo(too vague — ask for specifics),Decompose(clear — propose an outline and confirm), orExecute(user confirmed — go). This keeps the agent from burning search budget on an under-specified question. -
Decomposition into 2–3 sub-questions. The decompose node returns
main_intent,key_dimensions, and a small list ofsubtopics, each with a concretesuggested_querywritten for a retriever, not for a human reader. The prompt explicitly bans vague dimensions like "background" or "development". -
Iterative, evidence-first research agent. For each subtopic a ReAct agent runs: it calls
tavily_search(one focused query), picks ≤2 high-quality links, callstavily_extract, and produces structured findings as{claim, quote, confidence}— every claim must be backed by a quote, no fabrication. It also returns acoveragemap over the key dimensions and ashould_continue/stop_reasondecision so it knows when to stop. -
Stable source IDs + dedup. A code node normalizes URLs, reuses the existing
sidfor a URL already seen, and only mints a newsidfor genuinely new sources. Findings are de-duplicated on(sid, claim, quote). This is what makes the final citations consistent across iterations. -
Footnote-cited report. The writer node (Qwen3-max) is handed
findings,history, and a pre-renderedsources_markdown, and must produce a fixed report structure (overview → key-dimension analysis → findings → sources) where factual sentences carry[^sid]footnotes and unsupported points are explicitly marked "(证据不足)".
Honest scope
This is a Dify low-code workflow, so it runs on the Dify platform and depends on API keys for DeepSeek, Tongyi/Qwen, and Tavily. The accompanying notebook is conceptual — it explains what Deep Research is and why the Agent loop matters — and does not ship a captured end-to-end report. The strength of the project is the workflow design (intent gating, decomposition, evidence-first iteration, stable citations), not a novel model or a from-scratch framework.
What this project signals
- You can design a non-trivial agent workflow in Dify — branching intent control, iteration over subtopics, code nodes for state accumulation, multi-model routing (DeepSeek for reasoning, Qwen for writing).
- You take evidence discipline seriously: claim+quote+confidence, URL dedup with stable source IDs, footnote citations, explicit "evidence insufficient" marking.
- You know when low-code is the right tool — and can be honest that the value is the orchestration, not bespoke code.
What the live demo replays
The demo replays the workflow on a sample topic: the three-way intent gate, decomposition into sub-questions, the ReAct agent's search→extract→evidence loop per subtopic, source dedup with stable IDs, and the final footnote-cited report. No live Dify/Tavily/LLM calls on the portfolio host — the replay shows the real graph's behavior.