TroubleshootingOfficial documentation13 min readDecision matrix

Separating External Reads and Writes in FastGPT

Compare strategies for external system integration using direct HTTP requests for reads and model-driven tool calls for writes to manage data and state.

FastGPT provides distinct mechanisms for interacting with external systems: direct HTTP requests and model-driven tool calls. The choice between these approaches depends on whether an operation is a read-only query or a state-changing write, and how much context the model requires to formulate the request. A direct HTTP request offers precise control over every part of the call, making it suitable for structured, repeatable queries. Tool calls give the model more autonomy to select and parameterize an operation based on conversational context, which is useful for more dynamic interactions but requires careful definition of the tool's purpose and boundaries.

Contrasting HTTP Requests and Tool Calls

The HTTP Request module is designed for explicit, pre-defined interactions with external APIs. The implementation involves configuring the request address, method, headers, and body according to the external system's contract. This approach is effective for tasks like fetching data from a known endpoint where the query structure is consistent. Variables from global settings, system states, or the output of previous nodes can be referenced to populate the request, but the fundamental structure of the call is fixed within the application's design. Authentication credentials should be injected through secure configurations, not hardcoded into the request definition.

Tool calls, conversely, delegate the decision to initiate an external interaction to the language model. The application designer provides the model with a set of available tools, each with a description of its function, its parameters, and conditions for its use. The model then interprets the user's intent and determines whether to invoke a tool, which one to use, and what arguments to pass. This method is better suited for workflows where the specific action depends on a complex or conversational context that is not easily mapped to a fixed request structure. For example, if a user's request could be fulfilled by one of several different APIs, a model can use the tool descriptions to make the appropriate selection. The model may not invoke a tool if it determines that required parameters are missing, potentially attempting to gather them through further interaction.

Proposed Implementation Paths

The decision between a direct HTTP call and a model-driven tool call creates distinct implementation paths for separating read and write operations. The following table outlines three proposed strategies for managing these interactions. These paths are conceptual models, not pre-configured modes within FastGPT. Each path carries different responsibilities for defining the operation, handling state, and validating the outcome. Combining these approaches is possible; for instance, a tool call could be used to gather information (a read), which then informs a subsequent, strictly defined HTTP request to perform a write operation.

CriterionPath 1: Explicit Read (HTTP Request)Path 2: Conditional Write (Tool Call)Path 3: Hybrid Read-then-Write
Primary Use CaseFetching structured data from a known, stable API endpoint for informational purposes.Executing a state-changing operation where the model selects the action based on conversational context.Performing a write operation that depends on data first retrieved from an external system.
Configuration MethodDefine the full request: address, method, headers, and body. Use variables for dynamic values.Define a tool with a clear description, parameters, and connection to an underlying API call.Configure an HTTP Request node for the read, followed by a Tool Calling node for the write.
Model's RoleThe model does not construct the call; it may use the data returned by the call in its response.The model interprets user intent to select the tool and construct its parameters before invocation.The model uses the output from the initial read to decide if and how to call the subsequent write tool.
Control over ExecutionHigh. The application logic dictates exactly when and how the API call is made.Moderate. The model decides whether to call the tool, but the tool's definition constrains its function.Layered. The initial read is explicitly controlled, while the subsequent write is model-dependent.
Handling FailureThe application flow must handle HTTP errors or unexpected responses from the fixed endpoint.The tool's description should guide the model on when not to call it. The application must handle execution failures.Requires separate error handling for both the initial data retrieval and the conditional write operation.

Implementation and Verification Considerations

When implementing either pattern, it is critical to verify the actual values being passed. For HTTP requests, this involves checking the final address, parameters, and body structure against the external API's contract. For tool calls, it means inspecting the request that the model formulates to confirm it aligns with the intended operation. The description provided for a tool is a guide for the model, not an execution guarantee, and the model's decision-making depends on its interpretation of that guide.

In advanced orchestration, multiple tools can be made available to a Tool Calling module. It is advisable to begin debugging with a small set of tools to isolate behavior. A termination node can be used to explicitly end a tool-calling sequence, which also prevents the AI from generating a summary of the tool's results. In test mode, chatId and responseChatItemId are unavailable. Their absence in a request does not by itself establish the execution mode or the outcome of a business operation; inspect the run context and external response separately. The separation of read and write operations is ultimately an architectural choice, enforced by using the appropriate FastGPT module for each distinct part of the business process.