AI Agent Proxy

The AI Agent Proxy State in xFlow is designed to facilitate the integration of AI agents developed using any framework or programming language into xFlow workflows. This state acts as an intermediary, allowing for seamless communication and execution of AI agents regardless of their underlying technology stack. This documentation explains the purpose of the AI Agent Proxy State, how it supports integration with various AI agent frameworks, and provides guidance on implementing this state in xFlow workflows. For detailed information on integrating AI agents using the AI Agent Proxy State, refer to the AI Agent Proxy Integration Guide.

Purpose of AI Agent Proxy State

The AI Agent Proxy State serves as a bridge between xFlow workflows and AI agents developed externally. Its primary purposes include:

  1. Interoperability: Enables AI agents built with different frameworks and languages to be integrated into xFlow workflows, promoting interoperability and flexibility.

  2. Abstraction: Provides an abstraction layer that simplifies the interaction between the workflow and the AI agent, hiding the complexities of the underlying AI agent implementation.

  3. Scalability: Supports distributed execution and scaling of AI agent tasks, leveraging xFlow’s workflow engine capabilities.

  4. Standardization: Ensures that AI agent interactions follow a standardized protocol, making it easier to manage and maintain integrations.

Supported AI Agent Frameworks

The AI Agent Proxy State can integrate AI agents developed using various frameworks and languages, including but not limited to:

  • Langchain: A popular framework for building language models and conversational AI applications.

  • Spring AI: An extension of the Spring framework tailored for developing AI applications in Java.

  • LlamaIndex: A framework for building and deploying large language models.

  • Custom Implementations: Any AI agent developed using custom code in languages such as Python, JavaScript, Java, etc.

Properties of AI Agent Proxy State

Agent Name

  • Name: agentName

  • Type: string

  • Description: The name of the AI agent to be invoked. This is used to identify the specific AI agent within the workflow.

  • Example:

    agentName: "MyCustomAgent"

System Message

  • Name: systemMessage

  • Type: string

  • Description: The system message that provides context or instructions to the AI agent. This message is typically used to prime the AI agent with necessary background information.

  • Example:

    systemMessage: "You are an AI assistant designed to provide technical support."

User Message

  • Name: userMessage

  • Type: string

  • Description: The message from the user that the AI agent will process. This is dynamically populated based on the workflow’s data.

  • Example:

    userMessage: '${ "User: " + .request.question }'

Execution

  • Name: execution

  • Type: object

  • Description: Defines how the AI agent’s actions are to be executed, including the function reference and any necessary arguments.

  • Example:

    execution:
      functionRef:
        refName: "ExecuteCustomAgent"
        arguments:
          input: "${ .request.data }"

Output

  • Name: output

  • Type: object

  • Description: The expected output schema from the AI agent, defining how the AI agent’s response should be structured.

  • Example:

    output: 
      schema: 
        type: "object"
        properties: 
          response: 
            type: "string"
            description: "The AI agent's response to the user query"
        required: ["response"]

How to Implement AI Agent Proxy State

To integrate an AI agent using the AI Agent Proxy State, follow these steps:

  1. Define the AI Agent Proxy State: In your workflow definition, add an AI Agent Proxy State with the necessary properties such as agentName, systemMessage, userMessage, execution, and output.

  2. Configure the Execution: Specify the functionRef to define how the AI agent should be invoked. This includes the reference name and any arguments that need to be passed to the AI agent.

  3. Handle the Output: Define the output schema to specify the expected structure of the AI agent’s response. This ensures that the workflow can correctly process and utilize the data returned by the AI agent.

Example Workflow Configuration

- name: CustomAIProxyState
  type: aiagentproxy
  agentName: "MyCustomAgent"
  systemMessage: "You are an AI assistant designed to provide technical support."
  userMessage: '${ "User: " + .request.question }'
  execution:
    functionRef:
      refName: "ExecuteCustomAgent"
      arguments:
        input: "${ .request.data }"
  output: 
    schema: 
      type: "object"
      properties: 
        response: 
          type: "string"
          description: "The AI agent's response to the user query"
      required: ["response"]
  transition: 
    nextState: "HandleResponseState"

For more detailed information and advanced configurations, refer to the AI Agent Proxy State Documentation and the AI Agent Proxy Integration Guide.

Last updated