Server-Side Hosting for LLM Web Search: Engineering Practice and Pitfalls
This article breaks down the shift from client-built retrieval pipelines to server-side hosted web search for large language models. It compares the two runtime modes (thinking off and thinking on), outlines integration and protocol compatibility, and highlights the engineering constraints teams must design for: unpredictable latency and cost, tool-call round limits, faithful pass-through of result blocks, sampling parameters being overridden, and per-page document parsing trade-offs. It closes with a practical launch checklist.
1. From Self-Built Pipelines to Server-Side Hosting: The Responsibility Boundary Shifts
Adding web capability to a model used to mean building a retrieval-augmented pipeline on the client side: call a search API for candidate links, fetch each page’s body text, clean it up, extract and truncate passages, stitch the cleaned text back into the context, and implement your own logic for deciding when to trigger retrieval during multi-turn follow-ups. Very little of that chain is actually about “intelligence”; most of it is glue code and fault tolerance.
The server-side hosting approach hands the decisions of whether to search, how many rounds to search, and which pages to read to the model itself. The client only needs to submit the user’s question. The division of responsibilities looks like this:
- Client responsibilities: session management, authentication, storing and returning result blocks as-is, and rendering citations in the frontend.
- Server responsibilities: tool orchestration, retrieval round control, web page body extraction, and citation generation.
The engineering value of this shift is that the retrieval strategy is no longer hard-coded in client code. It evolves together with the model’s capabilities, so integrators don’t need to ship a release just to adjust the strategy.
2. Two Runtime Modes: Thinking Off and Thinking On
With thinking mode off, the model triggers web search or reverse image search one or more times as needed, and attaches source citations to its answer. This suits latency-sensitive, factually clear question answering.
With thinking mode on, retrieval is interleaved into the reasoning process: the model first does a rough search to build a global understanding, then opens candidate sites to find specific numbers, and if the information is incomplete it switches keywords and searches again within the page, forming a “reason — supplement — reason again” loop. The official example illustrates this with a comparison of the heights of two towers; in that demo, tool calls can reach around twenty before it converges.
This introduces two engineering constraints that must be designed for in advance:
- Latency and cost are unpredictable. Multi-round tool calls make single-request time climb in steps, so the frontend needs streaming feedback and timeout fallbacks.
- Round and budget caps are required. Enforce hard limits on the number of tool calls and pages fetched at the gateway, to prevent an abnormal question from triggering a call storm.
A schematic call skeleton (pseudocode, structure only):
resp = client.chat(model="...",messages=history,tools=["web_search", "read_url"],stream=True,)# Key: push the returned thinking blocks, search blocks, and page-read blocks onto the stack in fullhistory.append(assistant_message_with_all_blocks(resp))
3. Integration and Protocol Compatibility
The mainstream approach is to align with the common message protocol shapes used across the industry, so existing code can migrate with little or no modification. This typically covers three types: a messages-style interface, a responses-style interface, and a general chat completions interface. On the tool side, capabilities are usually split into two orthogonal functions: one handles web search and image search, and the other reads the body text of links the user pastes directly. The benefit of this split is clear permission and billing boundaries, and it makes differentiated rate limiting easier at the gateway layer.
4. The Most Common Pitfall: Result Blocks Must Be Returned As-Is
The documentation emphasizes that thinking blocks, search result blocks, and page-read result blocks returned by the server must be carried back unchanged in the next turn. The reason is straightforward: these blocks are the only proof of “what the model has seen.”
If a self-built gateway in the middle filters these blocks out for log redaction, size compression, or format validation, the request will still return successfully, but the model will “lose its memory”: it remembers that it searched, yet cannot read what it found, so answer quality drops off a cliff and is extremely hard to diagnose. The recommendation is to treat “block fidelity” as an invariant in your gateway implementation, and add an assertion-style test case in the test environment that compares whether the block sequence is exactly identical before and after the round trip.
5. Side Effects of Sampling Parameters Being Taken Over
Once you enable tool calls, automatic title generation, or a high security level, the server takes over the sampling cadence, and sampling parameters carried in the request such as temperature and top_p will be ignored. This means strategies that rely on tuning parameters to stabilize output style will stop working. The way to handle it is to move controllability forward into the prompt and structured output constraints — for example, using explicit output format requirements, field enumerations, and examples to constrain behavior, rather than relying on randomness parameters.
6. Document Parsing: Cost Trade-offs Under Per-Page Billing
The file types billed per page typically include documents and images, and parsing comes in two tiers:
- Plain text extraction: low cost, but charts and diagrams in the layout are discarded entirely, so the model sees no graphical information.
- Layout-aware parsing: automatically crops out chart and diagram regions and reinserts them at their original position in the text, so the model can answer chart-related questions; the cost is that the cropped images are billed as image input tokens, and it relies on automatic detection, so when cropping is missed the model still can’t see them.
Take financial report Q&A as an example: with plain text extraction only, the revenue trend chart is completely missing, and questions like “which year had the highest growth rate” will inevitably be answered incorrectly. The practical recommendation is tiered handling: first use plain text mode for coarse filtering, upgrade only the documents that genuinely need chart semantics to layout-aware parsing, and record the miss rate on the business side as a quality metric.
7. Launch Checklist
- Store all result blocks in full within the session state; prohibit any form of intermediate-layer trimming.
- Set a triple cap for thinking mode: tool rounds, pages fetched, and total timeout.
- Complete the prompt and structured output rework before sampling parameters stop taking effect.
- Tier document parsing by business value; avoid enabling the high-cost mode across the board.
- Build observability: record retrieval rounds, fetch success rate, citation coverage, and per-request cost.
