> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentforcemcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Request-Response Flow

> Illustrating the typical data flow and lifecycle of an Agentforce Context Protocol interaction.

The Agentforce Context Protocol (ACP) defines a standardized flow for how Agentforce agents request actions and receive results from various systems. Understanding this request-response lifecycle is key to grasping how ACP enables seamless communication.

The flow typically involves an AI Agent, the [ACP Registry](/core-concepts/acp-registry), a [Connector](/core-concepts/connectors), and the target system the Connector interfaces with.

## Overview of the Flow

Here's a step-by-step breakdown of a typical ACP interaction when an AI agent decides to use a [Tool](/core-concepts/tools):

1. **Agent Identifies Need & Discovers Tool:**
   * The AI Agent determines a need to perform an action or retrieve information (e.g., based on user input or its internal logic).
   * The Agent queries the **ACP Registry** to find a suitable Tool that can fulfill this need. The Registry provides the Tool's schema (name, description, input/output parameters) and the identity of the Connector that exposes it.

2. **Agent Prepares ACP Request:**
   * Using the Tool's schema, the Agent constructs an **ACP Request**. This request is a standardized message typically containing:
     * `toolName`: The name of the Tool to be invoked.
     * `parameters`: A structured object (e.g., JSON) containing the input values required by the Tool.
     * `context`: Optional contextual information, such as user identity or session details, which might be necessary for the Connector or target system.

3. **Agent Sends Request to Connector:**
   * The Agent sends the ACP Request to the specific **Connector** identified during the discovery phase. The communication channel might vary (e.g., an HTTP call to a Connector's endpoint).

4. **Connector Processes Request:**
   * The Connector receives the ACP Request and performs several actions:
     * **Validation:** Checks if the request is well-formed and if all required parameters are present.
     * **Authentication/Authorization (if applicable):** Verifies the Agent's credentials and permissions to use the Tool and access the target system. This might involve interacting with Salesforce's Named Credentials or other identity services.
     * **Translation:** Maps the standardized ACP Request and its parameters into the specific format and protocol required by the target system's API (e.g., a REST API call, a SOAP request, a database query).

5. **Connector Interacts with Target System:**
   * The Connector sends the translated request to the **Target System** (e.g., Salesforce Sales Cloud, Marketing Cloud, an external API).
   * The Target System processes the request and performs the underlying action.

6. **Connector Receives Response from Target System:**
   * The Target System sends a response back to the Connector. This response is in the native format of the target system.

7. **Connector Prepares ACP Response:**
   * The Connector receives the native response and translates it back into a standardized **ACP Response**. This response typically includes:
     * `status`: Indicates the outcome of the Tool invocation (e.g., "success", "error").
     * `data`: If successful, this contains the output data from the Tool, structured according to the Tool's defined output schema.
     * `error`: If an error occurred, this provides details about the error (e.g., error code, message).

8. **Connector Sends Response to Agent:**
   * The Connector sends the ACP Response back to the AI Agent.

9. **Agent Processes Response:**
   * The AI Agent receives the ACP Response.
   * It processes the `data` if the request was successful or handles the `error` appropriately.
   * The Agent then uses this information to continue its task, provide an answer to the user, or decide on subsequent actions.

## Key Principles of the Flow

* **Standardization:** The Agent always interacts using the standardized ACP Request and Response formats, regardless of the underlying Connector or target system.
* **Abstraction:** The Agent doesn't need to know the specific API details of each target system; the Connector handles this complexity.
* **Decoupling:** Agents, Connectors, and the Registry are decoupled components, allowing for flexibility and scalability.

This request-response flow ensures that Agentforce agents can reliably and consistently interact with a wide array of enterprise capabilities through the Agentforce Context Protocol.

Return to [Core Concepts Overview](/core-concepts/overview).
