How to Retrieve the Right Web Passages for a Developer Support Agent
A practical retrieval design for developer-support agents that need exact, version-correct documentation passages—not merely related pages.
The retrieval problem is more specific than “find relevant docs”
A developer-support agent rarely succeeds by returning a page that is merely about the same product. It needs the precise evidence that resolves the ticket: the right API symbol, the applicable version, a configuration constraint, an error explanation, or a code example with the correct language and platform assumptions.
Consider this question:
Why does
createSession()returnAUTH_SCOPE_INVALIDafter upgrading the Java SDK to v2?
A broad semantic match might retrieve an authentication overview. A keyword-only search might retrieve an old troubleshooting page because it contains the error code. Neither result is sufficient if the answer actually depends on a v2 migration note and the API reference for the new scope format.
The retrieval objective should therefore be explicit:
- Discover the canonical documentation pages that could answer the question.
- Retrieve passages containing the supporting details.
- Enforce product, version, access, and lifecycle constraints.
- Select a small evidence set that covers the user’s question without adding contradictory context.
This is a retrieval system for support evidence, not a generic “similarity search” feature.
Build an index that preserves support-critical context
Passage text alone is usually not enough to distinguish good support evidence from a dangerous near-match. Each indexed passage should retain a structured record of where it came from and what it applies to.
A useful document shape looks like this:
{
"passage": "In SDK v2, requested scopes must use the resource-qualified format...",
"title": "Migrate authentication from SDK v1 to v2",
"heading_path": ["Authentication", "Scope migration"],
"canonical_url": "https://docs.example.dev/sdk/java/v2/auth-migration",
"product": "java-sdk",
"version": "2",
"language": "java",
"platform": "server",
"document_type": "migration-guide",
"release_status": "current",
"last_modified": "2026-08-14",
"api_symbols": ["createSession"],
"error_codes": ["AUTH_SCOPE_INVALID"]
}
The exact schema will vary, but several fields deserve special treatment:
- Canonical URL prevents duplicate mirrors, localized copies, and alternate routes from competing as distinct sources.
- Version and release status let the retriever exclude archived or incompatible documentation before answer generation.
- API symbols, CLI flags, configuration keys, and error codes preserve literal technical signals.
- Heading path and document type give a reranker enough context to distinguish an API reference from a conceptual overview.
Canonical selection matters because duplicate pages can dilute signals and expose contradictory content. Google’s guidance on duplicate URLs similarly emphasizes identifying a preferred canonical URL for equivalent content (Google Search Central). For developer documentation, this becomes a correctness control: do not let an agent casually combine archived v1 guidance with current v2 reference material.
Use hybrid retrieval for literal terms and developer phrasing
Developer tickets contain two very different forms of relevance:
- Literal relevance:
AUTH_SCOPE_INVALID,--no-verify,createSession, package names, parameter names, and stack-trace fragments. - Conceptual relevance: “login fails after migration,” “how do I restrict a token,” or “why is the callback rejected?”
Lexical retrieval is valuable for the first category. Pinecone’s relevance guidance specifically calls out full-text search for exact product names, technical IDs, phrases, and domain jargon (Pinecone). Vector retrieval is valuable for the second category, where customer language and documentation language differ.
Use both. In a hybrid design, keyword and vector searches retrieve candidate passages in parallel, then their rankings are combined. Azure AI Search describes this approach as combining text and vector queries in one request and merging the result sets with Reciprocal Rank Fusion (Microsoft Learn).
For the example ticket, a practical retrieval request might include:
Lexical query:
"AUTH_SCOPE_INVALID" "createSession" Java SDK v2
Semantic query:
Java SDK v2 authentication scope invalid after migration
Filters:
product = "java-sdk"
version = "2"
language = "java"
release_status = "current"
The lexical side makes the error code and method name difficult to miss. The semantic side can still find a migration guide that explains the underlying change even if it does not repeat the user’s full phrasing.
Filter before relevance becomes misleading
Filtering is not a cosmetic refinement after search. It is part of relevance. A perfect passage for the wrong operating system, account tier, package version, or deployment mode is not support evidence for the current case.
Apply hard filters whenever the ticket or surrounding session supplies reliable values:
- selected product and package
- target version or release channel
- programming language and runtime
- cloud, self-hosted, or platform variant
- audience or entitlement scope
- current versus archived documentation
If a version is unknown, avoid silently assuming “latest.” Instead, retrieve multiple eligible versions, label their applicability, and ask a clarifying question when the evidence materially differs. This is safer than producing a fluent answer that happens to solve a different version of the problem.
Expand queries selectively, not automatically
Query expansion can close the gap between a ticket and the phrasing used in documentation. For example, “token scope broken after upgrade” might be expanded into implementation-oriented variants such as:
AUTH_SCOPE_INVALIDcreateSession scopesresource-qualified scopeSDK v2 scope migration
This is more useful than a loose list of synonyms. For code-related support, expansions should reflect the representations developers search for: possible symbols, flags, error identifiers, configuration keys, and minimal invocation patterns.
Research on query expansion and reranking shows potential gains from enriching a query and connecting that process to downstream retrieval (ACL Findings 2023). Query2doc also reports that generated pseudo-documents can help sparse and dense retrieval by adding context and resolving ambiguity (ACL 2023).
But expansion is not a universal improvement. A later study found that generative query and document expansion can help in some settings and harm in others, depending on the retriever, domain, and dataset (ACL Findings 2024). Treat expansions as retriever inputs to test, not facts to trust.
A disciplined policy is:
- Keep the original query intact.
- Generate a small number of typed variants: identifier, API, conceptual, and migration variants.
- Give exact identifiers a lexical boost rather than replacing them with generated prose.
- Reject expansions that introduce an unobserved product, version, or API symbol.
- Measure whether each expansion family improves correct-page recall and version accuracy.
Rerank a manageable candidate set with support context
First-stage retrieval should favor recall: it must surface all plausible passages. Reranking should favor precision: it should put the best evidence at the top.
This two-stage pattern is standard in modern retrieval systems. Pinecone describes reranking as retrieving candidates first and then reordering them using a semantic relevance model (Pinecone). Elastic likewise recommends semantic reranking as a refinement over keyword, semantic, or hybrid retrieval and notes that it is best applied to a relatively small top-k set due to its cost (Elastic).
Do not send only raw chunk text to the reranker. Construct a support-oriented representation:
Title: Migrate authentication from SDK v1 to v2
Heading: Authentication > Scope migration
Applies to: Java SDK v2, current
Type: Migration guide
Symbols: createSession
Passage: In SDK v2, requested scopes must use...
That framing helps distinguish a passage that is semantically similar from one that is applicable. A troubleshooting article for the Python SDK may explain the same error code, but its language and version fields should pull it below the Java v2 migration passage.
Reranking cannot fix a candidate-generation failure. Azure’s semantic ranking documentation is clear that reranking operates on an existing result set rather than searching the whole corpus anew (Microsoft Learn). Track first-stage recall separately from reranker quality, and increase or diversify candidate retrieval when the correct page does not enter the candidate pool.
Need a practical way to inspect source pages before designing your retrieval flow? Try PagePith.
Select evidence as a set, not a fixed top-k list
The top three highest-scoring passages are not necessarily the best context for an answer. A support question can require multiple complementary pieces of evidence:
- an error-code definition,
- a versioned migration rule, and
- a code sample or parameter reference.
Conversely, five passages repeating the same conceptual explanation consume context while adding little support.
After reranking, select passages with a set-level policy:
- include the passage that directly answers the question;
- add only passages that cover a missing sub-question or prerequisite;
- prefer a source with explicit version and applicability information;
- penalize near-duplicate passages from the same page;
- reject passages that conflict on version, product, or release status;
- stop when the evidence budget is covered, not when a fixed count is reached.
Return extractive evidence wherever possible: the original passage, its heading path, canonical URL, and applicability metadata. Azure’s semantic ranking documentation describes captions and answers as extractive rather than newly created content (Microsoft Learn). That is the right model for support citations: the agent may synthesize an explanation, but the retriever should preserve the source wording that supports it.
Evaluate retrieval before judging the final answer
An answer may look helpful while being grounded in the wrong version. Evaluate retrieval as its own system with tickets drawn from real support patterns: errors, setup failures, upgrades, API usage, configuration, and multi-part debugging.
For each test item, label the expected page, valid version or product scope, and one or more acceptable supporting passages. Then report:
| Layer | Useful measures |
|---|---|
| Page discovery | correct canonical page hit rate and recall@k |
| Passage retrieval | passage recall@k and reciprocal rank |
| Applicability | product, version, language, and lifecycle accuracy |
| Evidence selection | support coverage, duplication rate, and conflict rate |
| End-to-end support | citation-supported resolution rate and escalation rate |
Passage-retrieval research commonly uses top-k accuracy to assess whether a target passage appears in the retrieved results (Dense Passage Retrieval). For a support agent, add applicability metrics because finding the right text from the wrong release is a distinct failure mode.
Review failures by stage. Was the canonical page missing from the index? Did a filter exclude it? Did hybrid retrieval fail to nominate it? Did reranking prefer a broader page? Did the selection policy omit a needed second passage? Each diagnosis leads to a different fix.
Managed stack or custom pipeline?
A managed search stack can be a sensible choice when the team needs hybrid retrieval, metadata filtering, semantic reranking, and operational controls without owning every retrieval component. A custom pipeline is justified when documentation sources, access rules, ranking signals, or evaluation requirements require deep control.
Choose based on concrete questions:
- Can it apply hard filters for version, product, and access scope?
- Does it preserve lexical matching for code-like identifiers?
- Can it combine lexical and semantic candidates?
- Can you inspect candidates, scores, applied filters, and selected citations?
- Can indexing reflect documentation freshness and canonical URL changes?
- Can you evaluate page recall separately from reranking and answer quality?
The important choice is not “vector database versus search engine.” It is whether the system gives you enough control to retrieve applicable, citeable support evidence reliably.
A limited PagePith demonstration
The supplied PagePith proof shows a fetch-tier retrieval of Microsoft’s “Create a Hybrid Query - Azure AI Search” page. The fetched record includes a title, a reported content length of 29,233, and a Markdown excerpt stating that text and vector queries execute in parallel and are merged with Reciprocal Rank Fusion. That source is available at Microsoft Learn.
This demonstrates source-page extraction into readable Markdown that a retrieval workflow could inspect or index. It does not demonstrate PagePith configuring hybrid search, performing reranking, enforcing version filters, or measuring retrieval quality. Those remain responsibilities of the retrieval design and the systems connected to it.
A dependable developer-support agent starts with that discipline: retrieve the applicable page, preserve exact technical evidence, rank passages in context, and only then draft an answer.
Want to start working with extracted web content for your own workflow? Sign up for PagePith.
Sources
- Create a Hybrid Query - Azure AI SearchMicrosoft Learn
- Semantic Ranking Overview - Azure AI SearchMicrosoft Learn
- Increase Search RelevancePinecone Documentation
- Rerank resultsPinecone Documentation
- Semantic rerankingElastic Documentation
- Expand, Rerank, and Retrieve: Query Reranking for Open-Domain Question AnsweringAssociation for Computational Linguistics
- Query2doc: Query Expansion with Large Language ModelsAssociation for Computational Linguistics
- When do Generative Query and Document Expansions Fail?Association for Computational Linguistics