Integrating Server-Managed Web Search and Document Parsing into LLM Applications

    This article explains how to shift from self-built search pipelines to server-managed web search and document parsing when integrating large language models (LLMs). It covers the working modes of on-demand and deep search, the required tool declarations, two common integration pitfalls (context block pass-through and ignored sampling parameters), and the cost/quality trade-offs between plain-text extraction and layout-aware document parsing. Practical engineering recommendations are provided for stable deployment.

    From Self-Built Pipelines to Server-Managed Services: An Architectural Shift

    For a long time, developers who wanted LLMs to answer questions with live web data had to assemble and maintain a full pipeline:

    1. Determine whether the user’s question required web retrieval;
    2. Call a search API to obtain a list of relevant pages;
    3. Fetch and extract the meaningful text from each page;
    4. Concatenate the results into the conversation context and feed them to the model for response generation.

    This process was tedious and error-prone: deduplicating search results, handling extraction failures, and managing multi-round supplementary searches all had to be coded and maintained manually.

    Today, the mainstream approach has shifted toward server-managed services. Agent platforms or model providers handle the actual “search the web, search images, read links” operations. The client simply sends the user’s question to the server; whether to search, how many rounds to run, and which keywords to use are all decided and executed by the model on the server side. This significantly reduces the architectural burden on developers:

    • The client no longer maintains search and scraping pipelines, which drastically reduces code volume;
    • The orchestration of multi-round retrieval (what to search first, what to do if not enough information is found) is handled by the model’s reasoning capabilities, improving robustness;
    • Retrieved results and generated answers naturally include source citations, which is convenient for frontend display and traceability.

    How Server-Managed Search Works

    1. Disabled Thinking Mode: On-Demand Retrieval

    When deep thinking is disabled, the model calls web search or image search as needed and then generates an answer with cited sources. This mode suits simple factual questions—it offers fast response times and low token consumption.

    2. Enabled Thinking Mode: Reasoning with Interleaved Lookups

    With thinking mode enabled, retrieval actions are interwoven into the reasoning process, similar to an in-app “deep search” experience. In a typical scenario—comparing the heights of two landmarks—the model’s workflow typically follows these steps:

    • It starts with a broad search to gather preliminary information;
    • After identifying authoritative sources, it directly accesses the relevant official page to find exact numbers;
    • If the first round is not sufficient, it searches within the page or tries different search terms to continue;
    • It repeats several rounds until the information converges, and only then produces a final answer.

    As shown in official documentation examples, such deep retrieval tasks may involve up to about twenty consecutive tool calls. This has practical implications:

    • The frontend must be prepared for waiting and process display: During long tasks, show intermediate states (e.g., “searching,” “reading webpages”) so users do not think the request is stuck;
    • Streaming output is almost mandatory: Only by streaming reasoning and tool-call blocks can users see the ongoing process.

    3. Access Method: Protocol Compatibility and Tool Declarations

    The integration cost for these server-managed tools is low. Common mainstream conversation protocols (such as Messages-style, Responses-style, and Chat Completions-style) typically support them directly. Configuration usually requires two tool declarations:

    • One for “search” (covering web search and image search);
    • One for “read link” (when a user provides a URL directly in the conversation, the model can read the content of that link before answering).

    A representative request structure is shown below in pseudocode:

    1. {
    2. "model": "your-model",
    3. "messages": [{"role": "user", "content": "Compare the heights of two towers"}],
    4. "tools": [
    5. {"type": "web_search"},
    6. {"type": "url_reader"}
    7. ]
    8. }

    The First Pitfall: Context Blocks Must Be Returned As-Is

    One critical constraint deserves special attention: Thinking blocks, search result blocks, and webpage extraction blocks returned by the server must be passed back unchanged in subsequent conversation requests.

    Many teams place a gateway between their application and the model service for authentication, rate limiting, log sanitization, etc. If that gateway filters out these “non-standard” content blocks when forwarding responses, a subtle failure emerges:

    • The request succeeds with no error;
    • However, the model “forgets” which webpages it just read, leading to repeated searches, irrelevant answers, or even fabricated sources.

    When troubleshooting this issue, consider the following steps:

    1. Capture and compare the original response with the response forwarded by the gateway to identify structural differences;
    2. In the gateway, adopt a “pass-through” policy for unknown content block types instead of dropping them;
    3. Build regression test cases that specifically cover multi-turn conversations with tool calls.

    The Second Pitfall: Sampling Parameters Are Ignored

    Another limitation to be aware of: once managed capabilities such as tool calling, automatic conversation title generation, or high security levels are enabled, the server takes control of the sampling behavior. As a result, sampling parameters like temperature and top_p set in the request are silently ignored.

    In other words, trying to fine-tune the model’s output randomness or determinism via these parameters will not work in this mode. Engineering responses include:

    • Control output style through prompt engineering rather than relying on sampling parameters;
    • If your business has a strong need for custom sampling (e.g., creative generation scenarios), evaluate whether to disable some managed capabilities—weigh the trade-off between functionality and controllability;
    • Clearly document this behavioral difference in internal team documentation to prevent repeated trial and error.

    Document Parsing: Two Modes and Cost Trade-offs

    Beyond web search, server-managed document parsing (for PDF, Word, PPT, images, etc., usually billed per page) also offers two modes. Choosing the wrong mode directly affects answer quality and cost.

    1. Plain Text Extraction Mode

    This mode extracts only the textual content from the document. The downside is that charts and graphics are lost. For example, consider a financial report: with plain text extraction, the revenue trend chart is invisible to the model, so questions like “what is the revenue trend?” cannot be answered correctly.

    2. Layout-Aware Parsing Mode

    When layout recognition (an option like “rich layout recognition”) is enabled, the system automatically crops images from the document and reinserts them into their original text positions, allowing the model to “see” charts and figures. However, this introduces two costs:

    • Higher cost: Cropped images are billed as image input tokens—the more charts, the higher the expense;
    • No guarantee of complete extraction: Chart detection relies on automatic recognition; if some images are missed, the model still cannot see the corresponding content.

    3. Practical Recommendations

    • Use plain text extraction for problems that can be solved with text alone—this keeps costs under control;
    • For documents where charts are critical (financial reports, research papers, design documents), enable layout-aware parsing and explicitly instruct the model in the prompt to state whether answers are based on chart data, which facilitates later verification;
    • For key charts, consider pre-processing steps such as manual screenshots or transcriptions to supplement the automatic detection, rather than relying solely on it;
    • If your billing is cost-sensitive, run a small test first to estimate per-page costs before deciding on a bulk strategy.

    Summary

    Server-managed search and document parsing reduce the previously tedious “search—scrape—concatenate” pipeline into simple tool declarations. Integration is easy, and the upper bound on the user experience is high. However, two hidden engineering constraints must be kept in mind: first, thinking and tool result blocks must be passed back unchanged—filtering them at a gateway will cause the model to “lose memory”; second, once managed capabilities are active, sampling parameters become ineffective, so tuning must shift to prompt engineering. For document parsing, the choice between plain text and layout-aware modes must balance the need for charts against the cost budget. By mastering these three points, you can reliably deploy intelligent question-answering and deep retrieval scenarios in most practical settings.