Server-Side Tool Use in Practice: A Guide for LLM Applications

    This guide explains how server-side tool use moves common capabilities such as web search, URL reading, multi-format file input, and content moderation from client-side glue code into the model service itself. It covers the five high-frequency built-in tool categories, how to choose among chat-completion, response-object, and Messages-style protocols, and how to orchestrate standalone search and fetch APIs. A practical engineering checklist on fallback, budget control, observability, caching, citations, data compliance, and evaluation rounds out the article.

    1. From “Models That Only Talk” to “Models That Act”

    Over the past two years, the dominant form of LLM applications has been conversation: the user sends text, and the model returns text. Real business scenarios go well beyond that. Users paste a URL, upload a document dozens of pages long, or ask about news from yesterday. If the client had to implement all of these capabilities itself, developers would need to maintain a retrieval service, a web parsing service, a document parsing service, and a moderation service, then stitch their outputs into the prompt. The longer the pipeline, the more failure points it has.

    Server-side tool use takes a different approach: these high-frequency actions are pushed down to the model service side. The client only declares which tools are allowed in the request. During inference, the model decides on its own whether a tool call is needed, how many calls to make, and what arguments to use, then folds the results into the final answer. For developers, this means less code. For the model, because tool calls and reasoning happen on the same side, context stays more tightly connected and multi-turn retrieval is more coherent.

    It is worth stressing that this capability is not exclusive to any single vendor; it is a general design pattern that the industry has gradually converged on. Understanding its layered structure is more valuable than memorizing the name of a specific toggle.

    2. Understanding Five Categories of Built-In Capabilities

    Once you declare a web-search tool, the model automatically issues a search when it needs factual or time-sensitive information, and it adds source citations in the answer. Two engineering points matter here. First, recall quality for time-sensitive questions depends heavily on retrieval ranking. Second, source citations must be real and traceable; otherwise they undermine credibility.

    2.2 Retrieval During Reasoning

    This goes a step beyond “search first, then answer”: the model can issue searches during its thinking phase, open candidate pages, locate passages within a page, and then decide whether to keep searching. It suits research-oriented questions, at the cost of higher latency and more calls, so you typically control thinking effort and retrieval budget through request parameters.

    2.3 URL Content Reading

    When a user pastes a link, the model fetches and reads the main content instead of seeing just a string of characters. The key engineering issue is extraction quality: navigation, ads, and comment sections can all be mistakenly pulled in. For production, the recommended approach is two-stage: first fetch the page into structured text, then store it or place it into context, which makes caching and auditing easier.

    2.4 Multi-Format File Input

    The common pattern is to upload a file first to get a file identifier, then reference that identifier in the conversation messages. Supported formats usually include documents, spreadsheets, presentations, e-books, plain text and code, and images. In practice, long documents need chunking plus retrieval; spreadsheet files rely more on structured parsing; images involve layout and text recognition. The three have completely different failure modes, and their monitoring metrics should be tracked separately.

    2.5 Content Safety Moderation

    The server moderates both the input and the complete output, and refuses to answer when a risk is detected. Developers should not treat this as an after-the-fact patch. Define refusal wording, fallback paths, and an appeals process during product design, so users do not run into unexplained blank replies.

    3. Protocol Layer: One Capability, Multiple Access Styles

    So that clients on different tech stacks can all connect, the mainstream approach is to support several request protocols at once: one in a chat-completion style, one in a response-object style, and one that uses a Messages structure with tool definition blocks. The differences lie mainly in field naming, the granularity of streaming events, and how tool results are returned.

    A schematic request skeleton (pseudocode, structure only):

    1. {
    2. "model": "<model identifier>",
    3. "messages": [
    4. { "role": "user", "content": "Summarize the key conclusions of this industry report" }
    5. ],
    6. "tools": [
    7. { "type": "web_search" },
    8. { "type": "read_url" }
    9. ],
    10. "thinking": { "budget": "medium" }
    11. }

    Selection guidance: if you already have a chat-style application, staying with the existing protocol means the fewest changes. If you need fine-grained streaming rendering (showing the thinking process separately from the main text), pick the protocol with richer event types. For parallel tool calls that need structured tool-call blocks, the Messages-style protocol is more convenient.

    4. Exposing Low-Level Capabilities as Standalone APIs

    Beyond being built into the conversation, capabilities like retrieval and fetching are often also exposed as standalone APIs, so they can be orchestrated individually inside an agent framework. Two are typical:

    • Search API: returns a list of results with summaries, usually with scores such as relevance and authority, which makes threshold filtering easy.
    • Fetch API: takes a URL and outputs plain text or Markdown content that is easy for a model to consume.

    The value of standalone APIs is control: you can cache, rerank, run canary releases, and rate-limit them separately. A solid combination is “standalone search API for recall → local reranking and deduplication → put only the top N documents into context,” balancing cost and quality.

    1. # Pseudocode: two-stage retrieval orchestration
    2. results = search_api(query=q, top_k=10)
    3. docs = [fetch_api(url=r.url) for r in results if r.score > 0.6]
    4. context = rerank_and_dedup(docs)[:5]
    5. answer = chat_api(messages=build_prompt(q, context))

    5. Production Implementation Checklist

    1. Layered fallback: when a built-in tool is unavailable, fall back to a standalone API or a pure model answer to keep the service available.
    2. Budget control: set upper limits on the number of searches, fetch volume, and thinking effort to prevent latency and cost from spiraling.
    3. Observability: track search hit rate, fetch success rate, parsing failure types, and refusal rate separately, instead of only looking at overall success rate.
    4. Caching strategy: cache search results and page content by content fingerprint, which significantly reduces repeated calls.
    5. Citation standards: sources in the answer should map one-to-one to retrieval results, making manual verification easy.
    6. Data compliance: define retention periods and access boundaries for uploaded files, and prefer private or dedicated deployment for sensitive scenarios.
    7. Evaluation loop: build a fixed evaluation set containing time-sensitive questions, long-document questions, and questions with links, and run a regression after every parameter change.

    6. Conclusion

    The essence of server-side tool use is turning “application-layer glue code” into “standard platform-layer capabilities.” What developers really need to master is capability layering, protocol differences, budget and fallback design, and using general cloud product capabilities (such as object storage, message queues, log services, and monitoring and alerting) on cloud platforms like Baidu AI Cloud to make this pipeline stable and observable. With this methodology in hand, the migration cost of switching the underlying model or cloud vendor genuinely goes down.