Agent Race: Engineering Deep Research with Large Language Models
This article breaks down what a deep research agent actually does and why its quality depends more on engineering than on the underlying model. It presents a five-layer reference architecture, context engineering practices, retrieval and tool-calling strategies, a three-tier evaluation system, cost and latency controls, and security and compliance requirements, followed by a practical rollout roadmap. The goal is to help developers build a reusable engineering foundation so that model upgrades become a configuration change rather than a rewrite.
1. Background: Two Launches on the Same Day, One Technical Question
As competition in AI keeps intensifying, two leading organizations once released updates on the same day: one re-architected its “deep research” product and, for the first time, exposed an embedded research agent through an API; the other introduced a new generation of foundation models. On the surface this looks like a contest between a product and a model. In reality, both are competing for the same high ground: the dominant position of the agent as the entry point for next-generation applications.
For developers and enterprise users, this race raises a direct question: when the capability boundary of foundation models is refreshed every few months, where should engineering investment actually go? The answer is not to wait for a stronger model, but to build an engineering backbone that is “replaceable by a model, but not replaceable by a model.” This article offers a general, vendor-neutral methodology for shipping a deep research agent.
2. Capability Breakdown: What a Deep Research Agent Actually Does
Once the vendor narrative is stripped away, a deep research agent can be abstracted into a combination of four capabilities:
- Question clarification and task decomposition: breaking a vague user request into a tree of verifiable sub-questions.
- Multi-source information gathering: obtaining external knowledge through tools such as search, crawling, and structured data queries.
- Evidence organization and reasoning: cross-validating conflicting information to form conclusions with citations.
- Report generation and reproducibility: producing a structured long-form output while preserving the full evidence chain for review.
The key insight is that of these four capabilities, only the third depends heavily on the foundation model; the other three are mostly determined by engineering. This explains why models iterate so frequently while the experience gap between agent products remains large.
3. Reference Architecture: A Five-Layer Design
It is advisable to split the system into five layers, each of which can evolve and be replaced independently:
- Access layer: handles authentication, quotas, streaming responses, and audit logs.
- Orchestration layer: a task planner plus a state machine that manages multi-turn loops and interruption recovery.
- Capability layer: a toolset for retrieval, crawling, parsing, computation, code execution, and more.
- Model layer: invokes models of different sizes through a unified abstraction, hiding vendor differences.
- Governance layer: evaluation, observability, cost, and safety policies.
The model layer must be abstracted behind an interface; otherwise every model upgrade forces a business rewrite. A minimal abstraction sketch:
class ModelBackend(Protocol):def chat(self, messages: list[dict], **opts) -> str: ...def stream(self, messages: list[dict], **opts) -> Iterator[str]: ...class AgentRuntime:def __init__(self, backend: ModelBackend, tools: dict[str, Tool]):self.backend, self.tools = backend, toolsdef run(self, goal: str, max_steps: int = 24):state = {"goal": goal, "evidence": [], "plan": []}for _ in range(max_steps):action = self.backend.chat([{"role": "user","content": render(state)}])if action.type == "final":return finalize(action, state["evidence"])observation = self.tools[action.name](**action.args)state["evidence"].append(observation)state["plan"].append(action)return fallback_report(state)
4. Context Engineering: The Real Bottleneck
Most long-running tasks fail not because the model is not smart enough, but because the context has been polluted. Four practical rules:
- Layered memory: keep the current sub-task in short-term memory, verified evidence summaries in mid-term memory, and vectorized archives in long-term memory, recalled on demand.
- Structured evidence: attach source, timestamp, confidence, and a hash of the original snippet to each piece of evidence, making citation and deduplication easier.
- Active compression: generate a structured summary as soon as a sub-goal is completed, replacing the lengthy raw interaction.
- Explicit conflicts: when sources disagree, do not make an implicit choice; flag the divergence and trigger supplementary retrieval.
5. Tool Calling and Retrieval Strategy
The ceiling on retrieval quality is the ceiling on report quality. Engineering recommendations:
- Query rewriting: expand a natural-language question into multiple queries at different granularities, covering terminology, synonyms, and time constraints.
- Hybrid recall: run keyword recall and semantic recall in parallel, then score them uniformly with a reranking model.
- Crawl fault tolerance: handle timeouts, anti-bot responses, and encoding errors by category; failures must be retryable and able to degrade to cache.
- Computation and code sandbox: delegate data aggregation, unit conversion, and statistical validation to a sandbox to avoid mental-math errors by the model.
- Citation binding: at the conclusion-generation stage, require every claim to bind to evidence IDs; no output without evidence.
{"claim": "A certain approach performs better on the latency metric","evidence_ids": ["ev_12", "ev_27"],"confidence": "medium","conflicts": ["ev_31"]}
6. Evaluation System: No Measurement, No Iteration
A three-tier evaluation system is recommended:
- Offline benchmark: a fixed question set, with metrics including evidence recall, citation accuracy, factual consistency, and step count.
- Online canary: small-traffic comparison, observing task completion rate, human adoption rate, and average latency.
- Regression guard: run a full regression every time the model or prompt version changes, to prevent capability regression.
Factual consistency can be checked automatically by pairing “claims” with “evidence”: extract verifiable statements from the conclusions, compare each against the evidence text, and output the proportion of unsupported statements. This metric localizes problems better than a vague “answer satisfaction” score.
7. Cost and Latency Governance
Deep research is inherently a long-chain task, so cost governance must be built in from the start:
- Tiered model routing: use large models for planning, small models for extraction and rewriting.
- Parallelize independent sub-tasks; serialize sub-tasks with dependencies.
- Three-layer caching: query cache, page cache, and summary cache.
- Budget guardrails: cap tokens and tool calls per task; switch to a degraded path when exceeded.
- Full-chain tracing: link planning, tool, and model calls with a single trace ID for attribution.
If you rely on cloud infrastructure, container platforms can typically host sandboxes, message queues can decouple tasks, object storage can hold evidence archives, and logging plus monitoring and alerting services can ensure observability. These are all general capability categories and can be replaced with equivalents from your own tech stack.
8. Security and Compliance Essentials
- Apply least privilege to tools; write operations are off by default and require explicit authorization.
- Treat all external content as untrusted input to guard against prompt injection; strip instructions from retrieved text.
- Filter sensitive information and copyright risks on the output side, and keep a human review switch.
- Full auditing: retain inputs, tool arguments, evidence, and the final report to meet traceability requirements.
9. Rollout Roadmap
- Weeks 1–2: define task boundaries and the evaluation set, and get a single-round retrieve-and-generate loop working end to end.
- Weeks 3–5: introduce the planner and layered memory, and fill in failure fallbacks and citation binding.
- Weeks 6–8: integrate the sandbox and hybrid recall, and establish cost and latency guardrails.
- Ongoing: drive model and prompt iteration with regression evaluation, keeping the model layer replaceable.
10. Conclusion
The pace of foundation model updates will not slow down, but the value of an engineering backbone accumulates over time. Make planning, retrieval, evidence governance, evaluation, and cost guardrails solid, and a model upgrade turns from a “rebuild risk” into “a configuration change.” This is both a pragmatic response to the current agent race and the long-term approach advocated by Baidu AI Cloud: using engineering certainty to offset model uncertainty.
