A Practical Guide to Coordinating Agent Planning with External Retrieval
This article presents a reusable engineering approach for connecting an AI agent's planning module with an external retrieval channel. It explains why parameterized model knowledge needs a separate perception path for time-sensitive tasks, then breaks the system into four layers: planning, retrieval intent, execution, and synthesis. Key topics include structured retrieval intent, automatic query rewriting, source trust tiers, time-range filtering, evidence backfilling, conflict resolution, observability, and evaluation. Readers will find practical guardrails and a checklist of common pitfalls for building verifiable, up-to-date agent workflows.
1. Background: Knowledge Has Boundaries, Tasks Do Not
A large language model’s parameterized knowledge stops at its training cutoff, while real business tasks often demand “facts as of today.” When an agent is asked about live market data, recent announcements, new regulations, or version changelogs, relying only on internal memory leads to three typical failures:
- Staleness: answering new questions with outdated conclusions.
- Hallucinated completion: inventing plausible-sounding details when recall fails.
- Unverifiability: outputs with no traceable sources, leaving stakeholders unable to judge trustworthiness.
An agent architecture therefore needs an independent external perception channel. This channel is not about stuffing search results into a prompt. It must be tightly coupled with the planning module: the planner decides when retrieval is needed, what to retrieve, and when retrieval is sufficient, while the executor performs the calls, cleaning, and backfilling. This article offers a reusable, engineering-oriented approach from a general technical perspective.
2. Overall Architecture: Dividing Responsibilities Between the Planner and the Retrieval Executor
Split the system into four layers with clear boundaries so each can evolve and be load-tested independently:
- Planning layer: task decomposition, dependency ordering, and retrieval requirement annotation (whether to go online, how many hops, acceptance criteria).
- Retrieval intent layer: translating natural-language needs into structured query conditions, including keywords, time range, source tier, language, and result count.
- Execution layer: calling external retrieval capabilities with concurrency control, timeouts and retries, result normalization, and deduplication.
- Synthesis layer: evidence selection, conflict resolution, citation annotation, answer generation, and confidence assessment.
The key design principle is “planning does not touch details, execution does not make decisions.” The planner outputs only structured intent, and the executor returns only an evidence list with metadata. This avoids scattering business judgment across prompts and making the system hard to maintain.
3. Structured Representation of Retrieval Intent
To keep retrieval controllable, define a unified data structure instead of concatenating strings. Example:
{"task_id": "t-1024","query": "new data compliance rules in the target industry over the last 30 days","rewrite": ["target industry data compliance rules 2025", "data compliance regulatory requirements latest"],"time_range": {"start": "now-30d", "end": "now"},"source_policy": {"min_trust": "authoritative", "exclude": ["aggregator"]},"top_k": 8,"need_snippet": true}
Here, source_policy filters for authoritative sources, time_range constrains the time window, and rewrite holds candidate queries for automatic rewriting. Once structured, retrieval quality becomes measurable, regression-testable, and eligible for gradual rollout.
4. Automatic Query Rewriting: Three Strategies to Improve Recall
User phrasing is often colloquial and incomplete, so direct retrieval yields low recall. In practice, combine three types of rewriting:
- Synonym expansion: add domain terms and abbreviations to reduce surface-form mismatch.
- Time anchoring: resolve vague expressions such as “recently” or “lately” into absolute times or relative windows.
- Sub-question splitting: break a compound question into independently retrievable sub-queries, then merge the evidence.
Rewriting needs guardrails: a cap on the number of candidate queries, a total timeout budget, and a fallback rule that reverts to the original query when results differ too much before and after rewriting. This prevents rewriting from steering the intent off course.
5. Source Trust and Time-Range Filtering
For factual tasks, trustworthiness depends heavily on evidence sources. Introduce source tiers: authoritative institutions and first-party releases as tier one, mainstream media as tier two, and aggregators and forums as tier three. Allow the threshold to be set dynamically based on task risk. High-risk tasks (compliance, medical, financial) accept only tier-one sources, while low-risk exploratory tasks can relax the bar.
Time-range filtering must align with business semantics: regulations follow the effective date, market data follows the data timestamp, and versions follow the release date. In engineering terms, preserve the original time fields in evidence metadata and normalize to a single time zone at the synthesis layer to prevent “old news used as new.”
6. Evidence Backfilling and Conflict Resolution
Multiple retrieved pieces of evidence often contradict each other. The recommended flow is: first deduplicate and merge near-duplicates, then sort by source tier and recency, then extract key snippets into evidence cards, and finally let the synthesis layer generate the answer with per-sentence citation numbers. If a key fact is in conflict and cannot be resolved, explicitly output “disagreement exists” rather than forcing a single conclusion. This is the baseline for verifiability.
7. Observability and Evaluation
Before launch, build an evaluation set covering three sample types: time-sensitive, source-sensitive, and no-answer (should refuse). Metrics include recall hit rate, citation accuracy, time-sensitive accuracy, and refusal accuracy. In production, use logging services and monitoring alerts to observe retrieval latency, empty-result rate, and rewrite fallback rate, forming a closed iteration loop.
8. Common Pitfalls Checklist
- Treating retrieval as a cure-all patch, which makes the planning layer lazy and degrades task decomposition.
- Sorting only by relevance while ignoring source and time, producing answers that “look right but are already outdated.”
- Rewriting without budget control, amplifying latency and cost.
- Lacking a refusal mechanism and fabricating answers when evidence is insufficient.
9. Conclusion
Making an agent “get online” is only the starting point. The real engineering challenge is bringing external retrieval into a closed loop that is plannable, constrainable, and verifiable. With structured intent as the contract, source tiers and time windows as guardrails, and evidence cards plus citation annotation as the delivery standard, agents can reliably produce trustworthy results on time-sensitive tasks. To carry retrieval logs, evidence caches, and evaluation data, teams can build an elastic foundation using general cloud product categories such as object storage, message queues, container platforms, logging services, and monitoring alerts. Baidu AI Cloud also offers mature capabilities in these general categories for teams to combine as needed.
