.png)
Automate multi-step company research with agentic orchestration and structured web intelligence.通过智能体编排和结构化网络情报,实现多步骤公司调研自动化。
Company due diligence is a workflow that shows up everywhere in financial services. PE analysts screen deals, bank credit teams assess borrowers, compliance teams onboard new entities, insurance underwriters evaluate commercial policyholders. The research follows a consistent pattern. Take a company, investigate it across several dimensions, produce a structured intelligence report where every claim has a source trail.公司尽职调查是金融服务领域随处可见的工作流程。私募股权分析师筛选交易、银行信贷团队评估借款人、合规团队完成新主体准入、保险承保人评估商业保单持有人,调研都遵循统一的模式:选定一家公司,从多个维度展开调查,生成结构化情报报告,报告中每一项结论都有溯源路径。
This cookbook builds an agent that automates that workflow by combining LangChain's Deep Agents for orchestration and Parallel's Task API for web research. Deep Agents handles planning, subagent delegation, and context management. Parallel handles the actual research, returning structured findings with per-field citations, reasoning traces, and calibrated confidence scores via Basis. When findings from one track raise new questions, Parallel's interactive research feature lets the agent chain follow-up queries with full context from the prior research thread.
本教程将构建一个智能体,通过结合LangChain的Deep Agents实现编排功能、Parallel的Task API实现网络调研,从而自动化该工作流程。Deep Agents负责规划、子智能体委派和上下文管理;Parallel负责实际调研,通过Basis返回带逐字段引用、推理轨迹和校准置信度得分的结构化调研结果。当某一调研轨道的发现引出新问题时,Parallel的交互式调研功能可让智能体基于此前调研线程的完整上下文,串联发起后续查询。
Overview概述
The agent orchestrates five research tracks, each handled by a dedicated subagent:该智能体编排五条调研轨道,每条轨道由专属子智能体负责:
- Corporate profile — legal entity structure, key officers, founding history, headcount, office locations企业概况——法人实体结构、核心高管、成立历史、员工规模、办公地点
- Financial health — funding history, revenue signals, valuation indicators, profitability markers财务健康度——融资历史、营收信号、估值指标、盈利性标记
- Litigation and regulatory — lawsuits, SEC filings, sanctions screening, regulatory actions, settlements诉讼与监管——诉讼情况、SEC备案文件、制裁筛查、监管措施、和解记录
- News and reputation — recent press coverage, leadership changes, controversy flags, media sentiment新闻与声誉——近期媒体报道、管理层变动、争议标记、媒体舆情
- Competitive landscape — identifies the top three direct competitors and the target's positioning竞争格局——识别前三名直接竞争对手及目标公司的市场定位
Once competitive-landscape returns its named list, the orchestrator dispatches a separate competitor-analysis subagent once per competitor, in parallel — the canonical Deep Agents fan-out shape, with each instance running in its own isolated context. The orchestrator then reads every workpaper, cross-references for contradictions and low-confidence findings, runs ad-hoc lookups via Parallel's Search API when discrepancies surface, and writes the final report with risk flags and citation trails.竞争格局调研轨道返回命名列表后,编排器会为每个竞争对手并行派发一个独立的竞品分析子智能体——这是Deep Agents典型的分发形态,每个实例都在独立的上下文中运行。随后编排器会读取所有工作底稿,交叉比对矛盾点和低置信度发现,当出现差异时通过Parallel的搜索API进行临时查询,最终生成带风险标记和引用路径的报告。
DD requires this multi-step architecture because earlier findings change what needs to be investigated next. If the corporate profile reveals the target is a subsidiary, the financial analysis needs to cover the parent. If the litigation scan surfaces an SEC investigation, the risk assessment changes. Deep Agents' planning tool lets the orchestrator adapt when findings shift the research plan.尽职调查需要这种多步骤架构,因为早期的发现会改变后续需要调查的内容。如果企业概况显示目标是子公司,财务分析就需要覆盖母公司;如果诉讼扫描发现SEC调查,风险评估就需要调整。Deep Agents的规划工具可让编排器在发现改变调研计划时灵活适配。
Each research track uses a pro-fast processor Task API call. Validated end-to-end on Rivian Automotive (NASDAQ: RIVN): nine calls in ~23 minutes. See Parallel pricing for current rates.每条调研轨道都使用pro-fast处理器的Task API调用。已在Rivian Automotive(纳斯达克代码:RIVN)上完成端到端验证:9次调用耗时约23分钟。当前费率可查看Parallel定价页面。
Implementation实现方案
uv pip install deepagents langchain-parallel langchain-anthropic
export ANTHROPIC_API_KEY="your-anthropic-api-key"
export PARALLEL_API_KEY="your-parallel-api-key"
Defining the Parallel research tools定义Parallel调研工具
We define two tools. The first wraps Parallel's Task API for structured research with Basis-aware confidence handling. The second uses the LangChain integration's web search tool for quick factual lookups during synthesis.我们定义两个工具:第一个封装Parallel的Task API,用于支持Basis感知置信度处理的结构化调研;第二个使用LangChain集成的网络搜索工具,在综合阶段快速查询事实信息。
from typing import Optional
from langchain_core.tools import tool
from langchain_parallel import (
ParallelTaskRunTool,
ParallelWebSearchTool,
parse_basis,
)
@tool
def research_task(
query: str,
output_description: str,
previous_interaction_id: Optional[str] = None,
) -> dict:
"""Run structured web research via Parallel's Task API.
Returns findings with per-field citations and confidence scores (Basis).
Use previous_interaction_id to chain follow-up queries that build on
prior research context.
"""
runner = ParallelTaskRunTool(
processor="pro-fast",
task_output_schema=output_description,
)
invoke_args: dict = {"input": query}
if previous_interaction_id:
invoke_args["previous_interaction_id"] = previous_interaction_id
result = runner.invoke(invoke_args)
parsed = parse_basis(result)
output = result["output"]
findings = output.get("content") if isinstance(output, dict) else output
response: dict = {
"findings": findings,
"citations_by_field": parsed["citations_by_field"],
"interaction_id": parsed["interaction_id"],
}
if parsed["low_confidence_fields"]:
response["low_confidence_warning"] = (
"These fields came back with low confidence and should be "
"verified, ideally by chaining a follow-up query with "
"previous_interaction_id: "
+ ", ".join(parsed["low_confidence_fields"])
)
return response
# Quick search tool for fast factual lookups during synthesis
quick_search = ParallelWebSearchTool()
The tool does three things beyond a raw API call. It calls parse_basis(result) to extract per-field citations and the names of any low-confidence fields. It surfaces those names as an explicit low_confidence_warning in the tool's return value, so the calling subagent's reasoning loop can decide to chain a follow-up. And it returns the interaction_id so the chained call can anchor to the same research thread via previous_interaction_id.
该工具相比原始API调用多了三项功能:一是调用parse_basis(result)提取逐字段引用和所有低置信度字段的名称;二是将这些名称作为明确的low_confidence_warning(低置信度警告)放在工具返回值中,供调用子智能体的推理循环决定是否发起后续查询;三是返回interaction_id,使串联的调用可通过previous_interaction_id锚定到同一调研线程。
Defining the research subagents定义调研子智能体
Each research track gets its own subagent with a specialized system prompt and access to the research_task tool.每条调研轨道都配备专属子智能体,拥有专门的系统提示词,可调用research_task工具。
corporate_profile_subagent = {
"name": "corporate-profile",
"description": "Research corporate structure, leadership, founding history, and headcount",
"system_prompt": """You are a corporate research analyst.
Given a company, use the research_task tool to find:
- Legal entity name, incorporation state/country, founding date
- Current CEO and key executives (names, titles, approximate tenure)
- Headquarters location and major office locations
- Employee headcount (current and recent trend)
- Corporate structure (parent company, major subsidiaries)
For the output_description parameter, request these as structured fields.
If the result includes a low_confidence_warning, chain a follow-up query
using the returned interaction_id to verify the flagged fields.
Write your findings (including citations_by_field) to corporate-profile.md.""",
"tools": [research_task],
}
The other Phase-1 subagents (financial-health, litigation-regulatory, news-reputation, competitive-landscape) follow the same shape with their own focused prompts. The full set is in agent.py.其余第一阶段子智能体(财务健康、诉讼监管、新闻声誉、竞争格局)采用相同结构,配备各自聚焦的提示词。完整代码集在agent.py文件中。
The Phase-2 fan-out subagent is invoked once per competitor identified by competitive-landscape:第二阶段分发子智能体会针对竞争格局轨道识别的每个竞争对手各调用一次:
competitor_analysis_subagent = {
"name": "competitor-analysis",
"description": "Produce a focused profile of one named competitor",
"system_prompt": """You are a competitive intelligence researcher.
The orchestrator will pass you a single competitor name and the original
DD target. Make one research_task call requesting:
- Corporate snapshot (HQ, public/private, headcount, founding year)
- Most recent revenue and growth signals
- Funding or market cap status
- Product / positioning vs. the original DD target
- Recent strategic moves in the last 12 months
- Notable strengths and weaknesses relative to the target
Write your findings to competitor-<slug>.md.""",
"tools": [research_task],
}
Creating the orchestrator agent创建编排器智能体
The main agent coordinates the subagents, reviews findings for contradictions, and produces the final report. We back it with a FilesystemBackend so workpapers and the final memo persist to disk under ./reports/ rather than evaporating with the agent state.主智能体负责协调子智能体、审核发现的矛盾点并生成最终报告。我们为其配置FilesystemBackend,使工作底稿和最终备忘录持久化存储在./reports/目录下,不会随智能体状态消失。
from pathlib import Path
from deepagents import create_deep_agent
from deepagents.backends.filesystem import FilesystemBackend
REPORTS_DIR = Path("./reports")
REPORTS_DIR.mkdir(parents=True, exist_ok=True)
diligence_instructions = """\
You are a senior due diligence analyst managing a team of specialized
researchers. Your job is to produce a comprehensive company intelligence
report with verifiable claims.
## Your Process
1. **Plan the research**: Use write_todos to lay out the diligence as a
checklist. Phase 1 dispatches the five Phase-1 subagents. Phase 2
dispatches one competitor-analysis subagent per competitor identified
by competitive-landscape.
2. **Phase 1 — parallel research**: Use the task tool to dispatch
corporate-profile, financial-health, litigation-regulatory,
news-reputation, and competitive-landscape concurrently.
3. **Phase 2 — competitor fan-out**: Read competitive-landscape.md and
parse the three named competitors. Dispatch a separate
competitor-analysis subagent instance per competitor, in parallel.
4. **Review and cross-reference**: Read every workpaper. Look for
contradictions, low-confidence findings, and gaps. Use quick_search
for ad-hoc lookups during synthesis.
5. **Synthesize the report** with: executive summary, corporate profile,
financial overview, litigation and regulatory risk assessment, news
and reputation analysis, competitive landscape (with per-competitor
sub-sections), confidence and verification notes, and key risk flags.
## Citation and Confidence Guidelines
- Include source URLs for key claims.
- Call out any finding where confidence was low. These need human verification.
- If two tracks produced contradictory information, note the discrepancy
explicitly with citations from both sources.
"""
agent = create_deep_agent(
model="anthropic:claude-sonnet-4-6",
tools=[quick_search],
subagents=[
corporate_profile_subagent,
financial_health_subagent,
litigation_subagent,
news_reputation_subagent,
competitive_landscape_subagent,
competitor_analysis_subagent,
],
system_prompt=diligence_instructions,
backend=FilesystemBackend(root_dir=REPORTS_DIR, virtual_mode=True),
)
Running the agent运行智能体
result = agent.invoke({
"messages": [{
"role": "user",
"content": "Conduct a full due diligence report on Rivian Automotive",
}]
})
print(result["messages"][-1].content)
Streaming execution progress流式输出执行进度
For long-running diligence runs, stream the agent's progress to see planning, tool calls, and subagent activity in real time. Pass subgraphs=True to receive events from inside subagent execution.针对耗时较长的尽职调查运行,可流式输出智能体进度,实时查看规划、工具调用和子智能体活动。传入subgraphs=True参数可接收子智能体执行内部的事件。
for chunk in agent.stream(
{"messages": [{"role": "user", "content": "Conduct a full due diligence report on Rivian Automotive"}]},
stream_mode="updates",
subgraphs=True,
version="v2",
):
if chunk.get("type") == "updates":
source = f"[subagent: {chunk['ns']}]" if chunk.get("ns") else "[orchestrator]"
print(f"{source} {chunk.get('data')}")
Observability with LangSmith通过LangSmith实现可观测性
Why observability matters for FSI可观测性对金融服务行业的重要性
In FSI, regulators, auditors, and risk teams increasingly expect firms to reconstruct how AI-assisted outputs were produced, especially when those outputs influence material business decisions. Six months from now, an internal auditor, compliance reviewer, model-risk team, investment committee, or regulator may ask how an AI-assisted diligence memo was produced. Which sources informed each material conclusion? What confidence was attached? Where did a human review or override the output? Was the agent’s process logged well enough to reconstruct? In FSI, “the agent gave me an answer” is not a defensible control posture.在金融服务行业,监管机构、审计人员和风险团队越来越要求企业能够重建AI辅助输出的生成过程,尤其是当这些输出影响重大业务决策时。六个月后,内部审计人员、合规审核人员、模型风险团队、投资委员会或监管机构可能会追问一份AI辅助尽职调查备忘录是如何生成的:每项重大结论参考了哪些来源?对应的置信度是多少?人类在哪些环节进行了审核或覆盖了输出?智能体的流程记录是否足够完善以支持重建?在金融服务行业,“智能体给了我一个答案”这种说法无法构成可辩护的控制立场。
The agent compounds non-determinism (LLM output, prompt sensitivity, the open web), spends real money on real web research, and ends in a memo a regulator may eventually audit. Every claim has to map back to a primary source with an explicit confidence label, and that mapping has to remain auditable months after the run finishes. Once the agent reaches production, most of its failures surface there too, where pre-launch testing rarely catches them. The trace is the artifact that survives the run.该智能体叠加了多种不确定性因素(大模型输出、提示词敏感性、开放网络),会消耗真实成本开展真实网络调研,最终生成的备忘录可能被监管机构审计。每项结论都必须能映射到带明确置信度标签的一手来源,且这种映射关系在运行结束数月后仍需可审计。智能体上线后,大部分问题也会在生产环境中暴露,而上线前测试很难捕捉到这些问题。运行轨迹是运行结束后唯一留存的可验证产物。
This is why the trace matters in FSI specifically:这正是运行轨迹在金融服务行业尤为重要的原因:
- Logging is increasingly mandated. The EU AI Act requires automatic event logging for high-risk AI systems, and US bank regulators apply model risk management expectations to AI agents in practice even where formal scope is unsettled. The trace is the artifact both frameworks contemplate.日志记录的要求正日益严格。欧盟《人工智能法案》要求高风险AI系统必须自动记录事件日志,美国银行监管机构在实践中已将模型风险管理要求适用于AI智能体,即便正式适用范围尚未明确。运行轨迹是这两套框架都认可的可验证产物。
- Decision explainability requires per-claim grounding. When AI input feeds a regulated decision such as consumer credit, investment recommendations, or any process subject to fiduciary obligations, the institution has to explain how that input was formed. The basis payload (source URLs and per-output confidence) is what makes that explanation reproducible months after the run.决策可解释性要求每项结论都有依据支撑。当AI输入用于支撑消费信贷、投资建议等受监管决策,或任何受信托义务约束的流程时,机构必须解释该输入的形成过程。基础载荷(来源URL和逐输出置信度)是让该解释在运行结束数月后仍可复现的关键。
- Third-party AI requires ongoing supervision. The stack uses an external model provider and an external research API (Parallel). A trace records what was sent to each provider, what came back, and how those outputs influenced the final memo, supporting issue investigation and vendor oversight.第三方AI需要持续监督。本技术栈使用了外部模型提供商和外部调研API(Parallel)。运行轨迹会记录发送给每个提供商的内容、返回结果,以及这些输出如何影响最终备忘录,为问题排查和供应商监管提供支持。
- Operational resilience depends on fast root-cause analysis. If an agent failure contributes to a material operational disruption or reportable ICT incident, the trace gives teams a concrete starting point for reconstruction, remediation, and reporting.运营韧性取决于快速的根因分析。如果智能体故障引发了重大运营中断或可报告的ICT事件,运行轨迹可为团队提供重建、修复和上报的具体起点。
How compliance and audit work today当前合规与审计的工作模式
FSI teams already have a system for proving how a research memo was produced: analyst workpapers, citation lists, source approvals, version history, and compliance review. That model works because the analyst is the unit of accountability. When an examiner, auditor, or compliance reviewer asks how a conclusion was reached, the analyst can walk through the reasoning, with workpapers and citations backing up the final deliverable. AI agents change that model.金融服务行业团队已经有一套证明调研备忘录生成过程的体系:分析师工作底稿、引用列表、来源审批、版本历史和合规审核。这套模式之所以有效,是因为分析师是责任主体。当审查人员、审计人员或合规审核人员追问结论的得出过程时,分析师可以逐步梳理推理逻辑,用工作底稿和引用支撑最终交付物。AI智能体改变了这一模式。
The “analyst” is no longer just a person. It is a graph of LLM calls, tool invocations, retrieved sources, intermediate outputs, and state transitions. Unless those steps are captured at runtime, the final memo may survive, but the process that produced it can disappear into logs, context windows, and vendor calls that are difficult to reconstruct later. The trace restores the attach point. It becomes the machine-side workpaper: an inspectable record of which sources informed each material conclusion, what confidence was attached, which tools were called, where human review occurred, and how the final output was produced.“分析师”不再仅仅是人类。它现在是大模型调用、工具调用、检索到的来源、中间输出和状态转换的图谱。除非这些步骤在运行时被捕获,否则最终备忘录可能留存下来,但生成它的流程可能消失在日志、上下文窗口和供应商调用中,后续难以重建。运行轨迹恢复了可追溯的锚点,它成为机器侧的工作底稿:一份可核查的记录,标注了每项重大结论参考了哪些来源、对应置信度是多少、调用了哪些工具、人类审核发生在哪些环节,以及最终输出是如何生成的。
What LangSmith capturesLangSmith记录的内容
LangSmith records every Deep Agents step and every ParallelTaskRunTool invocation in this agent: the prompt the subagent constructed, the URLs Parallel returned, the basis payload with confidence, and the structured findings, with no changes to the agent code. Each run is also broken down into per-node cost across every model call, tool call, and subagent, so you can see exactly which step drove which share of tokens and time. When two runs come back at very different cost, the trace shows whether the difference lives in subagent reasoning, additional Parallel calls, or the final synthesis pass.LangSmith会记录该智能体中每一个Deep Agents步骤和每一次ParallelTaskRunTool调用:子智能体构建的提示词、Parallel返回的URL、带置信度的基础载荷,以及结构化调研结果,无需修改智能体代码。每次运行还会拆分出每个节点的成本,涵盖所有模型调用、工具调用和子智能体,你可以清晰看到哪些步骤消耗了多少token和时间。当两次运行的成本差异很大时,运行轨迹会显示差异来自子智能体推理、额外的Parallel调用,还是最终综合环节。
What the trace shows运行轨迹展示的内容
Open any run and the first thing you see is the orchestrator's plan: a four-phase TODO that lays out the research strategy before any subagent runs.打开任意一次运行记录,首先看到的是编排器的计划:一个四阶段待办列表,在任意子智能体运行前就明确了调研策略。

Phase 1 then dispatches all five research subagents in parallel: corporate-profile, financial-health, litigation-regulatory, news-reputation, and competitive-landscape. Each subagent receives a focused mission described in plain English in the dispatch tool call. Click into any of those task nodes in the trace and you can see exactly what that subagent is doing: the prompt it issued, the Parallel calls it made, and the sources that came back.第一阶段会并行派发全部五个调研子智能体:企业概况、财务健康、诉讼监管、新闻声誉、竞争格局。每个子智能体都会收到派发工具调用中用平实英语描述的聚焦任务。点击轨迹中的任意任务节点,就能清晰看到该子智能体的具体工作内容:它发出的提示词、发起的Parallel调用,以及返回的来源。

After Phase 1 completes, the orchestrator fans out per-competitor analyses (Phase 2), cross-references workpapers for contradictions (Phase 3), and synthesizes the final memo (Phase 4). Every tool call is captured along the way.第一阶段完成后,编排器会分发逐竞品分析(第二阶段)、交叉比对工作底稿查找矛盾点(第三阶段)、综合生成最终备忘录(第四阶段)。全程所有工具调用都会被记录。
Selecting any subagent's research_task shows the full structured findings Parallel returned: every field, every excerpt, and every URL, including content beyond the summary that lands in the workpaper.选中任意子智能体的research_task,即可查看Parallel返回的完整结构化调研结果:每个字段、每条摘录、每个URL,包含未进入工作底稿摘要的全部内容。

Citations and confidence引用与置信度
For a compliance reviewer, the relevant view is the basis payload inside parallel_task_run. Parallel attaches each output with source URLs, a confidence label (high / medium / low), and a one-line reasoning trace explaining how the answer was assembled.对合规审核人员而言,相关视图是parallel_task_run内部的基础载荷。Parallel会为每个输出附加来源URL、置信度标签(高/中/低),以及一行解释答案组装过程的推理轨迹。

In the Rivian corporate-profile call shown above, the agent's medium-confidence output is grounded in four sources: Rivian's 10-K and 2026 annual report on SEC.gov, a third-party reproduction of the 2026 proxy statement, and Wikipedia. That mix of two primary SEC filings, one secondary reproduction, and one tertiary source is exactly the kind of grounding pattern a compliance reviewer would want to flag. With the trace, the grounding is inspectable per claim, and sourcing patterns like this one become correctable across runs. A workpaper without this layer would list the same four URLs flat, with no signal about which were primary.以上述Rivian企业概况调用为例,智能体的中置信度输出基于四个来源:SEC.gov上的Rivian 10-K文件和2026年年报、2026年代理声明书的第三方复刻版,以及维基百科。这种包含两份SEC一手备案文件、一份二手复刻文件、一份三级来源的组合,正是合规审核人员希望标记的依据模式。借助运行轨迹,每项结论的依据都可核查,这类来源模式也可在多次运行中修正。没有这一层的工作底稿只会平铺列出这四个URL,无法区分哪些是一手来源。
Beyond a single trace超越单次运行轨迹
For one DD memo, the trace is the audit trail. For a portfolio of memos run across a quarter, you also need pattern discovery: which subagent produces the most low-confidence outputs, which targets force the most chained Parallel follow-ups, which sources have started returning thinner content. LangSmith builds on the trace foundation with cross-run analytics for exactly that. For an FSI team running diligence at scale, that capability turns an audit trail into an operating discipline.针对单份尽职调查备忘录,运行轨迹是审计轨迹。针对一个季度内生成的多份备忘录组合,你还需要模式发现能力:哪个子智能体产生的低置信度输出最多、哪些目标公司触发了最多的Parallel串联后续查询、哪些来源开始返回更少的内容。LangSmith在运行轨迹的基础上提供了跨运行分析功能,正好满足这一需求。对于大规模开展尽职调查的金融服务行业团队而言,这一能力将审计轨迹转化为运营规范。
Who this is for适用对象
This architecture applies to any team running structured research workflows on companies, including deal screening, credit underwriting, KYB/KYC onboarding, M&A target evaluation, and vendor risk assessment.该架构适用于所有开展公司结构化调研工作的团队,包括交易筛选、信贷承销、KYB/KYC准入、并购目标评估和供应商风险评估。
The five research tracks here are a starting point. Swap in tracks relevant to your workflow: add management background checks and beneficial ownership tracing for compliance-heavy diligence, add IP portfolio analysis for M&A screening, add SOC 2 verification for vendor assessment. Each additional track is a new subagent dict with a system prompt and the same research_task tool.本文的五条调研轨道是起点。你可以根据自身工作流程替换轨道:在合规要求高的尽职调查中增加管理层背景调查和实益所有权追溯;在并购筛选中增加知识产权组合分析;在供应商评估中增加SOC 2认证核查。每新增一条轨道,就是一个带系统提示词、可使用相同research_task工具的新子智能体配置。
Resources相关资源
- Full source code完整源代码
- Deep Agents documentationDeep Agents文档
- Parallel Task APIParallel Task API
- Parallel Basis and citationsParallel Basis与引用功能
- Parallel interactive researchParallel交互式调研
langchain-parallelSDKlangchain-parallel SDK- Get a Parallel API key获取Parallel API密钥








.png)