How AI Agents Automate Multi-Tenant Infrastructure Provisioning for Data Teams
Autonomous Agentic Approach for Multi-Tenant Infrastructure Provisioning Agentic AI is a form of artificial intelligence (AI) that allows AI applications to reason, learn, adapt, and take actions similar to humans. Unlike traditional hard-coded AI systems, agents use Large Language Models (LLMs) to dynamically choose the next best action, effectively emulating human behaviors. They plan a sequence of actions, remember the state of their execution path, and utilize external tools to accomplish tasks. Components of an Agentic System Task: The specific goal the agent aims to achieve. LLMs as the Brain: The LLMs provide the reasoning and decision-making capabilities. Tools: External resources or functions that the agent uses to execute tasks. Memory: The agent's ability to retain and recall past actions and states. Planning: The agent's capability to define and follow a series of steps to achieve the task. Demonstration: Automating Multi-Tenant Infrastructure Provisioning To illustrate the potential of agentic AI in real-world applications, let's consider a simple use case of provisioning infrastructure for a multi-tenant environment. This scenario involves creating a new project environment for different user roles, such as Data Engineers, Data Scientists, and Data Analysts. Pre-requisites First, we need to install the required Python libraries: python %pip install -U -qq langchain-databricks langchain==0.3.7 langchain-community==0.3.7 langchain-experimental==0.3.3 %restart_python Setting Up the LLM We'll use the Databricks ecosystem with a specific LLM: python from langchain_databricks import ChatDatabricks llm_llama = ChatDatabricks(endpoint="databricks-meta-llama-3-1-8b-instruct", max_tokens=2500) Creating Tools A custom Python tool, request_tenant_tool, is defined to interact with a GitHub CI/CD pipeline. This tool selects the appropriate workflow based on the user role and triggers the pipeline. ```python from langchain_core.tools import tool import requests @tool("request_tenant_tool", description="Creates the tenant request for a given project and user persona") def request_tenant_tool(project_code: str, user_persona: str) -> str: trigger_action_persona_map = { "DATA ENGINEER": "sample_deploy_de_tenant.yaml", "DATA SCIENTIST": "sample_deploy_ds_tenant.yaml" } tenant_request_status = "Tenant Request not created" input_validation = [project_code == "", user_persona == ""] if any(input_validation): tenant_request_status = "Tenant creation request failed. Input parameters are invalid." else: workflow_name = trigger_action_persona_map.get(user_persona.upper(), "") if workflow_name: url = f"https://api.github.com/repos/user/repository/actions/workflows/{workflow_name}/dispatches" headers = { "Accept": "application/vnd.github+json", "Authorization": f"Bearer {token}", "Content-Type": "application/json" } data = f'{{"ref":"main", "inputs":{{"project_code": "{project_code}"}}}}' response = requests.post(url, headers=headers, data=data) if response.status_code == 204: tenant_request_status = f"Tenant Request Successfully Created using workflow {workflow_name}. Once the request is complete, you will get an email notification with all relevant environment setup details." else: tenant_request_status = "Tenant setup request failed" return tenant_request_status ``` Defining the Plan The plan for the agent is constructed using the ReAct pattern, which enables the model to generate reasoning traces and take actions to complete tasks. The plan is defined as a series of instructions: ```python from langchain.prompts import PromptTemplate template = """ Answer the following questions as best you can. Use the following format: Question: the input question you must answer Thought: you should always think about what to do Action: the action to take, should be one of (request_tenant_tool) Action Input: the input for the action Observation: the result of the action ... (This Thought/Action/Action Input/Observation can repeat N times) Thought: I know the final answer Final Answer: the final answer to the original input question """ prompt = PromptTemplate.from_template(template) ``` Constructing the Agent The agent is then constructed by combining the LLM, tools, and the plan: ```python from langchain.agents import AgentExecutor, create_tool_calling_agent tools = [request_tenant_tool] agent = create_tool_calling_agent(llm_llama, tools, prompt) platform_assistant = AgentExecutor(agent=agent, tools=tools, verbose=True, max_iterations=5) ``` Task Execution The agent can now be invoked to create a new project environment for a specific user persona. For instance, creating an environment for data engineers working on the "sales" project: python response = platform_assistant.invoke({ "input": "I need a new project environment setup for developing new data products. My project name is sales. This environment is to let data engineers develop data products. The output must be the result of executed code. Finally, share the status of the tenant request based on the tool output. While parsing input, use uppercase for persona and project code and map personas like DATA ENGINEER, DATA SCIENTIST, etc." }) print(response["output"]) Results The agent successfully interpreted the user input and executed the request_tenant_tool function autonomously. Here’s the output: ``` Entering new AgentExecutor chain... Invoking: request_tenant_tool with {'project_code': 'SALES', 'user_persona': 'DATA ENGINEER'} Tenant Request Successfully Created using workflow sample_deploy_de_tenant.yaml. Once the request is complete, you will get an email notification with all details relevant to the environment setup. Finished chain. ``` The agent not only created the tenant request but also managed to check the status of the request and provide a final confirmation. This demonstrates the agent's ability to reason, plan, and execute tasks dynamically without explicit instruction. Industry Evaluation and Company Profiles Industry experts view agentic AI as a transformative technology for automating complex tasks in tech environments. The demonstration highlights the potential of LLMs in reducing manual intervention and ensuring consistent and reliable infrastructure provisioning across multi-tenant scenarios. Companies like LangChain and Databricks are at the forefront of integrating AI with cloud and data platforms, offering robust solutions for developers and data professionals. LangChain provides a powerful framework for building agents and integrating them with various tools, making it a preferred choice for developers looking to automate tasks. Databricks, known for its unified data and AI platform, has developed specialized LLMs that can be fine-tuned for specific use cases, enhancing the capabilities of these agents. The ability of agents to handle tasks autonomously, coupled with their dynamic reasoning and memory features, opens up numerous possibilities for improving efficiency and scalability in multi-tenant infrastructure provisioning and other critical tech workflows. This approach is expected to become increasingly prevalent as organizations seek to optimize their cloud and data operations.
