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:

    1. Insufficient index coverage: long-tail pages, code hosting content, community discussions, and specialized databases are not effectively included.
    2. Intent understanding bias: a natural-language retrieval intent is reduced to keyword matching.
    3. 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:

    1. Directory navigation: human-curated site categorization, with low coverage and delayed updates. In essence, humans select results for other humans.
    2. Keyword inverted matching: ranking based on term frequency and link relationships, optimized for human reading habits. Summaries usually contain only titles and snippets.
    3. 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.
    4. 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.

    1. from abc import ABC, abstractmethod
    2. from dataclasses import dataclass, field
    3. @dataclass
    4. class SearchRequest:
    5. query: str
    6. scope: str = "auto" # auto / code / community / market / security
    7. top_k: int = 5
    8. freshness: str = "any" # any / recent / window
    9. min_trust: float = 0.0
    10. deadline_ms: int = 1500 # hard timeout for a single call
    11. @dataclass
    12. class Evidence:
    13. title: str
    14. url: str
    15. snippet: str
    16. source_type: str # web page / code / community / data API
    17. trust_score: float # source credibility score
    18. published_at: str | None
    19. payload: dict = field(default_factory=dict) # structured payload area
    20. class SearchProvider(ABC):
    21. @abstractmethod
    22. def 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.

    1. def layered_search(provider: SearchProvider, query: str, budget_ms: int = 3000) -> list[Evidence]:
    2. fast = provider.search(SearchRequest(query=query, top_k=5, deadline_ms=800))
    3. if fast and sum(e.trust_score for e in fast) / len(fast) >= 0.7:
    4. return fast
    5. deep = provider.search(SearchRequest(query=query, scope="auto",
    6. top_k=10, deadline_ms=budget_ms - 800))
    7. 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.

    1. {
    2. "evidence_id": "ev_8f3c",
    3. "source_type": "registry",
    4. "published_at": "2026-03-12",
    5. "trust_score": 0.91,
    6. "payload": {
    7. "entity": "Example Company",
    8. "shareholders": [{"name": "Shareholder A", "ratio": 0.34}]
    9. }
    10. }

    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

    1. 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.
    2. Looking only at summaries, not structure: readable text for humans does not mean the result can be consumed by programs.
    3. Ignoring freshness and deduplication: outdated conclusions can be repeatedly amplified.
    4. 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.”