Who Runs Web Search and File Parsing in Server-Side Tool Calling

    When an LLM must look things up before answering, retrieval, page fetching, and file parsing can live in the client or on the server. This article explains the two control paths, how tool declarations differ from forced invocation, how thinking mode changes search behavior, and what observability, citations, and fallbacks you still need.

    From “just answer” to “look it up, then answer”

    Letting a model answer from its parameters is a different engineering problem from making it retrieve first. The first path is a single message and a generation. The second needs retrieval, page fetching, body extraction, noise cleanup, context-length control, and stuffing evidence back into the conversation. When the model returns a tool-call intent, the application usually has to run the next action and loop.

    Some model APIs now move parts of that loop onto the server: search, link reading, and context assembly can complete in the same request as inference. You still build the app, but you do not have to implement every network hop as a client-side cycle.

    Two paths behind a research question

    Imagine an assistant that compares product changelog pages: the user pastes an official URL and asks what the update fixed. This is a process example, not a benchmark.

    Path 1: Client-side orchestration

    1. The app detects the URL in the user message.
    2. The app fetches the page and handles timeouts, download failures, anti-bot measures, and redirects.
    3. The app extracts the body, strips ads, and compresses length.
    4. The app injects the cleaned material into context and calls the model.
    5. If the model still needs search, the app calls a search API, consumes results, and continues.

    The model decides; the app actually runs tools. Ownership is clear, but boilerplate, error branches, and state are heavy.

    Path 2: Server-side tool fill-in

    The client declares allowed capabilities. The server executes them and fills results into context. Judgment and execution remain separate; developers just stop shuttling payloads between the two.

    Who owns the control flow decides where the work lives. If you need full control of query terms, fetch timing, and cache policy, use standalone search/fetch APIs. If you want the model to decide when to go online, use in-conversation server-side tools.

    Declaring a tool is not forcing a call

    Network tools are typically declared explicitly. Common capabilities are search and reading URLs in the user message. If you only need a given link, declare read-only access to avoid extra search cost.

    Platform details differ; follow the official documentation. Typical constraints:

    • These server tools often cannot be pinned to one specific tool via tool-choice; forcing a choice may be rejected with a 400-class error.
    • Whether search or URL read actually runs is the model’s decision given the question.
    • Setting tool choice to none turns these capabilities off.
    • With several tools declared, the model may combine them in one reasoning pass.

    Product implication: a UI badge that “web search is on” only means the capability is available, not that this answer used external sources. Verify with tool events, citations, and structured fields—not confident wording.

    1. # Illustrative structure only; not a specific vendor API
    2. resp = client.chat(
    3. model="...",
    4. messages=[{"role": "user", "content": "What did this update fix? https://example.org/changelog"}],
    5. tools=["web_search", "read_url"], # allowed server-side capabilities
    6. tool_choice="auto", # model decides whether to call
    7. )
    8. for ev in resp.events:
    9. if ev.type == "tool_call":
    10. audit_log(ev) # record search/read for observability
    11. elif ev.type == "tool_result":
    12. citations.extend(ev.sources) # collect sources for the UI

    Thinking mode changes retrieval

    With the same search tools, thinking mode changes behavior. Without it, the model often searches once and cites. With it, it may search, open pages, and locate snippets across multiple steps.

    Multi-step flow allows follow-up checks, but it also raises latency and cost, and a longer chain does not make every claim true. Outputs need citation alignment and sampling review.

    Files: parse first, then talk

    Sending a filename is not enough. PDFs, office docs, and images need text extraction or layout parse (tables, OCR for scans) before context assembly. Engineering points:

    • Parse quality is the ceiling: multi-column layout, tables that span pages, headers and footers are common noise.
    • Chunk and retrieve: long docs need chunking plus vector or keyword recall, then on-demand injection.
    • Cite with anchors: keep page/paragraph locators so answers map back to source.
    • Make failure visible: parse errors must be explicit, not silent empty context.

    Practical checklist

    1. Choose by control: independent search/fetch for query and cache control; server tools for lower integration cost.
    2. Observability: log tool events, latency, source domains, and cited snippets; alert on them.
    3. Citation checks: map key claims to sources or degrade to “no supporting evidence.”
    4. Degrade on failure: on timeout or parse failure, tell the user; do not let the model invent.
    5. Safety: domain allowlists and isolation against prompt injection from pages; size and type limits on uploads.
    6. Cost: cap tool calls per turn and context length; reuse static assets via object storage and cache.

    Takeaway

    Who executes web search and file parse is a question of process ownership. Server-side tools fold execution and fill-in into one request and lower integration cost. Independent retrieval APIs keep full orchestration. Either way, observability, citation tracing, and failure fallbacks are required: being able to search is not the same as having searched; only a citable source is verifiable.