Server-Side Tool Use for LLMs: Web Search and Document Parsing in Practice

    This article explains how web search and document parsing are moving from client-side pipelines into the LLM server side, and what that shift means for engineering teams. It covers the two main modes (direct-answer retrieval and iterative search during deep thinking), protocol compatibility and tool declarations, the requirement to pass context blocks back unchanged, the constraints that appear when sampling parameters are taken over by the server, and the trade-offs of page-based document parsing with layout restoration. It closes with a practical checklist and cost model for timeouts, observability, and quality control.

    1. From Self-Built Pipelines to Server-Side Tools: The Capability Boundary Is Shifting

    Building a web-enabled chat experience around a model used to require developers to assemble an entire pipeline on their own: call a search API to get candidate links, fetch page content, clean and denoise the text, chunk it, stitch it back into the context, and handle timeouts, retries, quotas, and caching. This pipeline looks simple, but it consumes a large amount of engineering effort and is only loosely coupled to the model inference itself.

    The recent direction of technical evolution is to push these “peripheral capabilities” down into the model server. The client only sends the user’s question; whether retrieval is needed, how many rounds to run, and when to stop are all decided by the model during inference. The engineering implication is straightforward: business code retreats from “orchestrating a workflow” to “expressing intent,” and complexity is compressed significantly.

    It is worth emphasizing that this is a general architectural pattern, not a proprietary feature of any single vendor. Common industry approaches include server-hosted tool calls and clients that only declare the available tool set. This article discusses the design logic and implementation considerations from a neutral perspective.

    Server-side tool use typically takes two forms, and understanding the difference is the prerequisite for designing the conversational experience.

    The first is the direct-answer mode with deep thinking disabled. The model triggers one or more retrievals on demand (web search or reverse image search), organizes an answer from the results, and attaches source citations. It has low latency and predictable behavior, making it suitable for customer support Q&A, factual lookups, and similar scenarios.

    The second is the iterative follow-up mode with deep thinking enabled. Retrieval actions are interleaved into the reasoning chain: the model forms a preliminary judgment, launches a query when it finds the evidence insufficient, and may even open a specific page to run an in-page keyword search or re-query with different keywords. A typical example is comparing the heights of two towers: the model first searches broadly, then opens each official page to get the numbers, and if the information is incomplete, it switches keywords and keeps looking within the page. Tool calls can reach the order of a dozen or more before converging.

    This creates a new engineering problem: the number of calls is no longer controlled by the client but decided autonomously by the model. Capacity planning, timeout budgets, and cost estimates therefore all have to be modeled for the worst case rather than the average.

    3. Protocol Compatibility and Integration

    To lower migration costs, server-side tool use is generally compatible with mainstream conversational protocol shapes in the industry, such as message-based protocols, response-based protocols, and general chat completion protocols. Most existing authentication, retry, and logging systems can be reused.

    For tool declarations, a common combination is one web search tool that handles keyword search and reverse image search, and one link-reading tool that parses URLs the user pastes directly. A schematic request structure looks like this (structure only, not a specific API):

    1. {
    2. "model": "<your-model-name>",
    3. "messages": [{"role": "user", "content": "Compare the heights of two towers and cite sources"}],
    4. "tools": ["web_search", "read_url"],
    5. "thinking": {"type": "enabled"}
    6. }

    4. The Easiest Pitfall: Context Blocks Must Be Passed Back As-Is

    One constraint that is specifically flagged in the documentation deserves repeated emphasis: the thinking blocks, retrieval result blocks, and page fetch result blocks returned by the server must be passed back unchanged in the next turn of the conversation.

    The reason is not hard to understand. These blocks are the only evidence of what the model has “seen.” If a self-built gateway filters them out for the sake of slimming down, redaction, or format validation, the request will still return successfully, but the model “loses its memory”—it remembers that it reasoned, yet cannot access the evidence. The result is vague answers, missing citations, or self-contradiction.

    Engineering recommendations:

    • Treat the server-returned content as an opaque payload: save it in full and do not rewrite it into a structure;
    • Have the gateway layer only pass through and rate-limit, without trimming content;
    • Retain the complete block sequence in session storage and set an expiration policy that matches the business;
    • Add a regression test before launch: after multiple turns, verify that citations still exist.

    5. Implicit Constraints When Sampling Parameters Are Taken Over

    Another easily overlooked behavior: once tool calls are enabled, conversation titles are generated automatically, or a higher safety level is set, the sampling cadence is usually taken over by the server. Explicitly set temperature, top_p, and similar parameters in the request are ignored.

    This means the practice of relying on parameter tuning to “adjust the model’s temperament” stops working. A viable alternative is to move the control points forward into the prompt and tool descriptions: use clear role definitions, output format constraints, and refusal boundaries to stabilize behavior, rather than relying on randomness parameters. At the same time, fix this premise during load testing and canary releases; otherwise the experiment results are not reproducible.

    6. Document Parsing: Page-Based Billing vs. Layout Restoration

    File inputs are usually billed per page, covering both documents and images. Parsing is generally split into two tiers: plain text extraction and extraction with layout recognition.

    Take a financial report as an example. With plain text extraction only, the revenue trend chart is discarded entirely; the model sees no graphical information and can only infer from the caption and body text. If the business genuinely needs to understand charts, you have to choose the mode with layout restoration, where the system crops out image regions and inserts them back at their original positions, giving the model multimodal input.

    The cost is equally clear: the cropped images are billed as image input tokens; and because charts rely on automatic detection, there is a possibility of missed crops, and any missed portion effectively does not exist for the model. So for critical documents, the safer approach is to keep original page-number references and, when necessary, have the business side add manual review or structured data as a fallback.

    7. Implementation Recommendations and Cost Model

    Synthesizing the above, here is an actionable practice checklist:

    1. First decide whether deep thinking is needed: prefer direct answers for factual Q&A, and enable iterative follow-up search only for research tasks;
    2. Set timeouts and budgets based on the worst-case number of tool calls, and configure circuit breaking;
    3. Pass all context blocks through in full and include this in regression tests;
    4. Write behavioral constraints into prompts and tool descriptions instead of relying on sampling parameters;
    5. Tier document parsing by value: use plain text for ordinary material, and layout restoration with spot checks for critical material;
    6. Build observability: log tool call rounds, retrieval hit rate, parsed page counts, and token consumption, and close the loop with monitoring alerts and logging services.

    The essence of server-side tool use is turning “retrieval engineering” into “intent expression.” What developers truly need to invest in has shifted from writing scraping pipelines to context integrity, cost boundaries, and quality evaluation—these three points are what determine the quality of web-enabled Q&A.