Web Search and File Reading: Should Execution Happen on the Client or the Server?

    Modern AI applications can either orchestrate web search and file processing on the client or delegate part of that work to server-side tools. This article compares both approaches, explains how tool control and auditability work, examines how multi-step reasoning affects verification, and outlines engineering considerations for reliable file parsing, retrieval, observability, cost, and compliance.

    1. From “Answer Directly” to “Search Before Answering”

    Having a model answer a question directly and having it research the question first are two very different engineering tasks. The first requires only a message. The second may involve connecting to a search service, downloading web pages, extracting their main content, removing noise, managing context length, and inserting the resulting material back into the conversation.

    Historically, applications handled almost all of these steps. The model decided whether it needed to search and what it should search for, while the client was responsible for actually running the tools.

    A recent set of application-facing APIs from a model provider moves this boundary forward. Some retrieval, link-reading, and context-assembly tasks can now run on the server alongside model inference within a single request. Developers still define the application flow, but they no longer need to implement every web interaction as a client-side loop.

    Understanding this boundary is one of the most practical lessons when building retrieval-augmented applications.

    2. Two Execution Paths: Who Orchestrates and Who Executes?

    Consider a “product update comparison assistant.” A user submits a link to an official website and asks what problem the update solves. This example illustrates the workflow only and does not represent any actual test result.

    Path A: Client-Side Orchestration

    1. The application identifies the link in the user’s message.
    2. The application sends a fetch request and handles timeouts, redirects, and download failures.
    3. The application extracts the main content and removes navigation elements, advertisements, and footers.
    4. The application adds the cleaned material to the prompt and calls the model.
    5. If the model determines that the information is insufficient and returns a tool call, the application invokes the retrieval API, receives the result, and starts another round.

    The defining characteristic of this path is that the model makes decisions, while the application runs the tools and repeatedly moves results between the model and the tools.

    Path B: Server-Side Tool Injection

    The client declares the capabilities it allows in the request. The server then executes the tools and inserts the resulting material into the context. Model decision-making and tool execution remain separate stages, but the transfer of results is handled on the server.

    An illustrative request structure is shown below. The placeholder tool names are descriptive only and do not represent real interface names:

    1. {
    2. "messages": [{"role": "user", "content": "What problem does this update solve? https://example.org/notes"}],
    3. "tools": ["<server-side web search tool>", "<server-side link-reading tool>"]
    4. }

    The official documentation distinguishes between two types of entry points:

    • If you want the model to decide when to search the web, use server-side tools within the conversation.
    • If the application needs to control the query terms and receive search or fetch results directly, use separate search and retrieval APIs.

    The choice ultimately depends on one question: who controls the workflow?

    3. Control Boundaries: Declaring a Tool Does Not Force Its Use

    Server-side tools may look like ordinary functions, but their control model differs from that of custom tools. This is one of the easiest areas to misunderstand:

    • You cannot use tool_choice to name a specific server-side tool. Doing so causes the request to be rejected with a 400 error.
    • Whether the model actually searches or reads a link is determined by the model. The client cannot force the action.
    • Setting tool_choice to none disables these server-side tools as well as custom functions.

    This leads to an important product conclusion: displaying “web access enabled” in the interface only means that the capability is available. It does not prove that the current response used external sources.

    To determine whether retrieval actually occurred, inspect the returned tool events and citation information instead of assuming that a confident-sounding answer has been verified. At the application layer, it is useful to maintain a structured audit record:

    1. turn_id | declared capabilities | actual tool events | citation sources | failure or empty-result status

    This record supports both observability and future quality-regression testing.

    4. How Reasoning Modes Affect Verification

    Even when retrieval is enabled, behavior can differ depending on whether a reasoning mode is active.

    Without reasoning mode, the model will typically search once when the question requires it and then provide an answer with citations. With reasoning mode enabled, the model can search repeatedly across multiple reasoning steps, open pages, and locate relevant passages.

    A multi-step workflow provides more opportunities for verification, but it does not guarantee that every conclusion will be correct. More steps also mean higher latency and more tool calls, and errors may accumulate along the chain.

    A practical approach is to enable multi-step verification for time-sensitive questions or questions that require cross-checking. For stable factual questions, a single-step workflow may be preferable to reduce cost and latency.

    5. File Reading Starts with Usable Source Material

    File input is not simply a matter of sending a filename to the model. PDFs, Office documents, images, and similar materials must first go through text extraction or layout analysis before they can be added to the conversation context.

    A reliable pipeline generally includes the following steps:

    1. Format normalization: Convert files into a consistent, parseable intermediate representation.
    2. Layout and structure analysis: Distinguish headings, paragraphs, tables, and captions. Preserve table structure whenever possible.
    3. Chunking and indexing: Split content at semantic boundaries while retaining source-location information.
    4. Context budgeting: Limit the amount of injected content. For oversized files, retrieve the most relevant passages first.
    5. Failure handling: Use OCR for scanned documents, and explicitly tell the user when parsing fails instead of silently returning empty content.

    Citations should point to specific page numbers or passages. Users are more likely to trust an answer when they can verify its source. This is also what separates a production-grade file-reading capability from a simple demonstration.

    6. Selection Criteria and Engineering Recommendations

    • Prioritize control: Choose separate search and retrieval APIs when you need to customize queries, deduplicate results, rank sources, implement caching, or run gradual rollouts.
    • Prioritize delivery speed: For interactive question answering and internal knowledge assistants, server-side tools within the conversation can reduce implementation effort.
    • Support compliance and auditing: Regardless of the execution path, record sources, timestamps, and failure reasons.
    • Manage cost and reliability: Set timeouts, retries, and fallback strategies for fetching and parsing. When retrieval returns no results, clearly state that no supporting evidence was found.
    • Use platform infrastructure where appropriate: Capabilities such as file parsing, retrieval caching, logging, and monitoring can rely on general-purpose cloud services provided by platforms such as Baidu AI Cloud, including object storage, message queues, logging, and monitoring services. This avoids rebuilding common infrastructure.

    7. Conclusion

    The question of who performs web search and file reading is no longer a simple choice between the client and the server. It is a matter of assigning responsibilities:

    • The model controls the decision about whether to use a tool.
    • The client or server controls tool execution.
    • The application remains responsible for workflow control and verification.

    Rather than debating which path is more advanced, it is more valuable to make tool events, citations, and parsing failures observable. Retrieval that can be verified is retrieval that can be relied upon.