Rebuilding Search for the Agent Era: Trusted Retrieval Practices
Agents can now handle coding, reporting, troubleshooting, and security analysis, but moving from demonstration to production still often fails at fact retrieval. This article analyzes common search failures in agent workflows, describes the shift from human-oriented search to agent-facing structured retrieval, and outlines four core requirements: coverage, multi-source unification, structured and traceable results, and stable contracts with latency budgets. It then presents a practical design using a unified search interface, layered retrieval, structured evidence payloads, offline and online evaluation, and engineering controls for caching, failure semantics, prompt-injection defense, privacy, observability, and staged rollout.
1. The Capability Ceiling of Agents Is Reached at Search
In 2026, the capability boundary of agents is expanding almost month by month. Tasks such as code generation, report writing, log troubleshooting, and vulnerability scanning previously required close human guidance. Now, agents can independently complete a large part of many workflows.
However, moving from “works in a lab” to “reliable in production” often depends less on the reasoning model and more on fact acquisition.
Three common failure scenarios are especially typical:
- Looking up a company’s equity structure: search results often return marketing pages and press releases from the company website, without verifiable business registration or shareholder contribution information. The agent can only make uncertain guesses.
- Finding a production-grade implementation: search results often point to beginner tutorials or reposted blog content. Code snippets may lack dependencies or error handling, and directly adopting them can introduce risks.
- Analyzing threat intelligence for a suspicious IP: results often remain at the level of explanatory articles, without recent behavioral observations, associated samples, or confidence labels.
On the surface, the problem appears to be “slow and shallow search.” At a deeper level, three issues fail at the same time:
- Insufficient index coverage: long-tail pages, code hosting content, community discussions, and specialized databases are not effectively included.
- Intent understanding bias: a natural-language retrieval intent is reduced to keyword matching.
- Results are not structured: web page text cannot be directly consumed by tool chains, and citation chains cannot be traced.
2. Four Shifts in Retrieval: From Serving Humans to Serving Agents
Looking back at the evolution of retrieval technology, it can be summarized into four stages:
- Directory navigation: human-curated site categorization, with low coverage and delayed updates. In essence, humans select results for other humans.
- Keyword inverted matching: ranking based on term frequency and link relationships, optimized for human reading habits. Summaries usually contain only titles and snippets.
- Semantic vector retrieval: dense representations and hybrid retrieval, such as keyword search plus vector search plus reranking, address paraphrasing issues. This is the main foundation of current retrieval-augmented generation, or RAG.
- Agent-oriented structured and trustworthy retrieval: the goal is no longer to return “a web page,” but to return “a set of evidence with sources, timestamps, structured fields, and content that programs can directly verify.”
The key difference in the fourth shift is not on the model side, but in the interface contract. The first three stages output products meant for human reading. The fourth stage requires the search service to output machine-verifiable contracts: every field must be traceable, every conclusion must link back to a source, and failures must have clear error semantics.
This shift does not conflict with RAG. RAG addresses how retrieved content constrains generation. Structured trustworthy retrieval addresses what counts as qualified evidence during retrieval.
3. Four Hard Requirements for Agent-Facing Search
Coverage
Long-tail content and “deep web pages” must be reachable, including specialized sources that require interaction or authorized access. Evaluation should use a layered question set:
- general questions;
- vertical-domain facts;
- code snippets;
- real-time updates;
- community experience.
Recall should be measured separately for each layer.
Multi-Source Unification
Text pages, code repositories, Q&A communities, market data, vulnerabilities, and threat intelligence differ greatly in structure. The correct engineering approach is to define a unified evidence model and use different adapters to normalize heterogeneous results into the same schema. Agents should not be forced to adapt to every data source.
Structured and Traceable Results
This is the most easily underestimated point. Agents do not need “a summary.” They need key-value pairs that can be inserted into later computation, such as:
- equity ratio;
- company entity identifier;
- function signature;
- version number;
- CVE number;
- observation time window;
- confidence level.
Contract Stability and Latency Budget
Agents usually call search multiple times inside a larger loop. Each call consumes end-to-end latency and context window capacity. If interface fields change, the entire tool chain may degrade silently. Versioning, timeout budgets, and observability must be designed in advance.
4. Practical Design: A Unified Search Interface Contract
The first step is to abstract search into a stable contract. The following is an illustrative code example. Actual fields can be adjusted according to business needs.
from abc import ABC, abstractmethodfrom dataclasses import dataclass, field@dataclassclass SearchRequest:query: strscope: str = "auto" # auto / code / community / market / securitytop_k: int = 5freshness: str = "any" # any / recent / windowmin_trust: float = 0.0deadline_ms: int = 1500 # hard timeout for a single call@dataclassclass Evidence:title: strurl: strsnippet: strsource_type: str # web page / code / community / data APItrust_score: float # source credibility scorepublished_at: str | Nonepayload: dict = field(default_factory=dict) # structured payload areaclass SearchProvider(ABC):@abstractmethoddef search(self, req: SearchRequest) -> list[Evidence]: ...
The second layer is layered retrieval. A low-cost path should be used first to obtain candidates quickly. If the hit count is insufficient or confidence is low, the system should escalate to a deeper path. This avoids performing the most expensive search on every request.
def layered_search(provider: SearchProvider, query: str, budget_ms: int = 3000) -> list[Evidence]:fast = provider.search(SearchRequest(query=query, top_k=5, deadline_ms=800))if fast and sum(e.trust_score for e in fast) / len(fast) >= 0.7:return fastdeep = provider.search(SearchRequest(query=query, scope="auto",top_k=10, deadline_ms=budget_ms - 800))return dedup(fast + deep) # deduplicate by normalized URL / content fingerprint
The third layer is structured payloads. For vertical-domain results such as equity data, intelligence, and code, the payload field should be constrained by a fixed schema. This allows downstream systems to perform numerical computation and rule-based judgment directly.
{"evidence_id": "ev_8f3c","source_type": "registry","published_at": "2026-03-12","trust_score": 0.91,"payload": {"entity": "Example Company","shareholders": [{"name": "Shareholder A", "ratio": 0.34}]}}
5. Evaluate with Data, Not Intuition: Offline and Online Measurement
Search is a capability whose gaps often become clear only after use. It must be quantified. A recommended approach is to maintain a fixed human-annotated question set covering the layered scenarios described earlier and run regression tests after every change.
| Dimension | Metric | Explanation |
|---|---|---|
| Quality | Evidence hit rate, answer accuracy | Measured by scenario, with vertical domains analyzed separately |
| Quality | Source traceability rate, structured field completeness rate | Determines whether the agent can trust the evidence |
| Quality | Duplication rate, outdated result ratio | Reflects deduplication and freshness strategies |
| Performance | P50 / P95 latency, timeout rate, failure rate | Critical for end-to-end latency budgets |
| Cost | Token consumption per call, tool-call rounds | Directly affects task cost |
For online evaluation, a small-scale controlled experiment can be run: the same batch of tasks is routed to different search configurations, and task completion rate, manual intervention count, and average number of rounds are compared.
Note that only strategies and configurations should be compared. Do not assume in advance that any particular approach must be better.
6. Engineering Checklist: Control, Observe, and Roll Back
- Context budget: evidence injected into a single prompt should be summarized or truncated. Keep the title, source, timestamp, and key fields. Avoid allowing long web page text to consume too much reasoning space.
- Caching and idempotence: cache results for the same normalized query, write them into a unified key space, and set a TTL. This prevents time-sensitive results from being reused for too long.
- Failure semantics: distinguish between “no results,” “timeout,” “insufficient permissions,” and “rate limited.” Agents should be able to take different remedial actions instead of blindly retrying.
- Prompt-injection protection: retrieved web pages, comments, and code comments are untrusted inputs. Place external content inside clear delimiters, declare that it is data rather than instructions, filter imperative text, and use source whitelisting when necessary.
- Compliance and privacy: limit the range of sources that can be fetched or called, redact personal information in returned results, and retain audit records for calls.
- Observability: use logging to record the query, hit sources, latency, and structured field completeness rate for each search. Use monitoring and alerts for timeout rate and failure rate thresholds.
In a self-hosted cloud environment, this pipeline can generally be assembled from common capabilities such as container platforms, message queues, vector search, and object storage. It does not need to depend on a vendor-specific implementation. General cloud platforms such as Baidu AI Cloud also provide these capability categories as options for selection.
7. Common Pitfalls
- Treating search as a secondary feature: using one keyword call instead of a complete search strategy can cause agents to reason over incorrect evidence for a long time.
- Looking only at summaries, not structure: readable text for humans does not mean the result can be consumed by programs.
- Ignoring freshness and deduplication: outdated conclusions can be repeatedly amplified.
- Having no regression baseline: after a model upgrade, teams may mistakenly blame search quality degradation.
8. Phased Rollout Recommendations
Phase 1: Establish a unified contract and dual-track measurement. First make the system comparable.
Phase 2: Add vertical-domain adapters and structured payloads. Connect high-value scenarios.
Phase 3: Introduce layered retrieval, caching, and rate limiting. Optimize latency and cost.
Phase 4: Consolidate security policies, audit mechanisms, and rollback mechanisms into the platform layer.
Search may look like an unremarkable component, but it determines how much of the world an agent can reach. Building search as infrastructure—with a unified interface contract, verifiable structured evidence, and quantifiable quality baselines—is a key step for agents to move from “summarizing web pages” to “connecting with reality.”
