{"id":17001,"date":"2025-04-01T08:00:17","date_gmt":"2025-04-01T15:00:17","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=17001"},"modified":"2025-06-13T16:39:40","modified_gmt":"2025-06-13T23:39:40","slug":"build-your-first-open-source-ai-agent-with-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/","title":{"rendered":"Build Your First Open Source AI Agent with Couchbase"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">If 2024 was the year of AI chatbots, then 2025 is the year of AI agents. At first glance, they may seem similar, but nothing could be farther from the truth. While you may interact with an AI agent in the same manner you interact with an AI chatbot, perhaps through a web interface, the differences between them are stark.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">AI agents can autonomously act to fulfill your request. That\u2019s right, I said it: <em>autonomously<\/em>. AI acting on your behalf figuring out what to do and what its next steps should be without your intervention.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Want to find a good restaurant for a date night and book a table? Let your AI agent do it for you, from the research to the booking.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Need to track new customer engagements in your CRM and send customized and personalized email outreach? Let your AI agent do it for you, from the tracking to composing the email all the way to sending it.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Essentially, agents can do just about anything for you online. You can even have multiple agents working in tandem. All they need is a <\/span><i><span style=\"font-weight: 400;\">task<\/span><\/i><span style=\"font-weight: 400;\"> that you set them off with and they will go about completing that task.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You may think that building or using agentic AI will cost you a fortune, and you wouldn\u2019t be wrong for thinking that. Companies, some of the largest in the space, are offering these services for very high monthly fees. Yet, with some knowledge of Python and JavaScript, you can build a full stack AI agent web user interface for free. Best of all, you can easily incorporate Couchbase for performant data storage, retrieval and full text search capabilities. Couchbase Capella, the fully managed database as a service, even offers a fully free forever tier, that you can use in your application.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><a href=\"https:\/\/github.com\/hummusonrails\/browser-use-agent-with-couchbase\/blob\/main\/README.md\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-17002 alignright\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-1024x675.png\" alt=\"\" width=\"412\" height=\"272\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-1024x675.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-300x198.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-768x506.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-1536x1012.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-2048x1350.png 2048w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/Screenshot-2025-03-31-at-4.24.40\u202fPM-1320x870.png 1320w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/a>Did I pique your interest? Well, great news! You don\u2019t even have to build it from scratch. You can find the full application in my <a href=\"https:\/\/github.com\/hummusonrails\/browser-use-agent-with-couchbase\">open source browser agent GitHub repository<\/a> &#8211; <\/span><span style=\"font-weight: 400;\">with instructions on how to start using it.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s take a look at the architecture of the application, and how it is built. A better understanding of how it works will empower you to adapt it for your own personal use case.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The application is made up of a React frontend and a Python backend. We\u2019ll focus on the backend as that is where the work of the agent and the interactions with Couchbase happen. You can explore the frontend freely on GitHub, which provides a mobile-first design.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Exploring how it works<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The foundation of this application is a harmonious blend of a React frontend and a Python backend. While the frontend ensures a smooth and responsive user experience, the backend is where the AI agent operates, handling user requests and interacting with Couchbase for data management.<\/span><\/p>\n<h3><span style=\"font-weight: 400;\">The AI agent with browser use<\/span><\/h3>\n<p><span style=\"font-weight: 400;\">At the core of the AI agent is the integration of the <a href=\"https:\/\/browser-use.com\/\">open-source Python library from Browser Use<\/a>. This library empowers the agent to perform a variety of tasks by simulating browser actions. Whether it&#8217;s navigating to a restaurant&#8217;s website to book a table or accessing the CRM to track customer engagements, Browser Use provides the necessary tools for the agent to interact with web resources effectively.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Initializing a Browser Use AI agent only takes a few lines of code in your Python backend:<\/span><\/p>\n<pre class=\"nums:false lang:python decode:true\">async def run_browser_agent(task: str):\r\n\u00a0\u00a0\u00a0\u00a0\"\"\"\r\n\u00a0\u00a0\u00a0\u00a0Runs the browser agent and returns its results in a JSON-serializable format.\r\n\u00a0\u00a0\u00a0\u00a0\"\"\"\r\n\u00a0\u00a0\u00a0\u00a0agent = Agent(task=task, llm=llm, use_vision=True, max_failures=3, retry_delay=5)\r\n\u00a0\u00a0\u00a0\u00a0history = await agent.run(max_steps=50)\r\n\r\n\u00a0\u00a0\u00a0\u00a0serialized_results = []\r\n\u00a0\u00a0\u00a0\u00a0if history and history.history:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for step in history.history:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if step.result:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if isinstance(step.result, list):\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for res in step.result:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialized_results.append(vars(res))\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0serialized_results.append(vars)\r\n\r\n\u00a0\u00a0\u00a0\u00a0return serialized_results<\/pre>\n<p><span style=\"font-weight: 400;\">The Agent is instantiated with several parameters, including:<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The specific task you want it to do<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The large language model it will use to analyze the results of its independent research (the project currently supports Anthropic, OpenAI, DeepSeek, Qwen, Azure, Gemini and others)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">A boolean value for <\/span><span style=\"font-weight: 400;\">vision<\/span><span style=\"font-weight: 400;\">, which gives the agent the ability to also analyze images from its research<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">The number of failures you will tolerate before exiting the task unsuccessfully\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">How long to wait in seconds in between retries<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">How many steps you give permission for the agent to execute in order to attempt to complete the task<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">The rest of the code for instantiating the agent is just concerned with returning the results.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">That\u2019s all it takes to create an agent and put it out in the world. A few lines of Python, really.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When the AI agent receives a task, such as booking a restaurant or sending personalized emails, it utilizes the Browser Use library to perform the necessary actions online. This involves navigating websites, filling out forms, and even parsing information, all executed programmatically to fulfill user requests efficiently.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Data persistence and search are fundamental features of modern applications. Not only can you persist the data for user purposes, like chat history, but you could also provide further context to your agent with the persisted data with a methodology called <a href=\"https:\/\/www.couchbase.com\/blog\/ai-powered-recommendation-engine-llm-rag\/\">Retrieval Augmented Generation (RAG)<\/a>. I recommend reading <a href=\"https:\/\/www.couchbase.com\/blog\/ai-powered-recommendation-engine-llm-rag\/\">this article<\/a> <\/span><span style=\"font-weight: 400;\">if you\u2019re interested in exploring that topic further.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For now, let\u2019s introduce data persistence and search functionality into your agent user interface with Couchbase.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Interacting with Couchbase for Full Text Search<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Couchbase plays a pivotal role in managing and retrieving chat data efficiently. Leveraging Couchbase Full Text Search (FTS) capabilities, the backend can swiftly search through extensive chat histories to find relevant conversations based on user queries. Here&#8217;s a streamlined example of how the backend interacts with Couchbase for FTS using the Couchbase Python SDK:<\/span><\/p>\n<pre class=\"nums:false lang:python decode:true\">from typing import List\r\nfrom couchbase.search import QueryStringQuery, SearchOptions\r\nimport logging\r\n\r\ndef search_chats(user_id: str, search_text: str) -&gt; List[dict]:\r\n\u00a0\u00a0\u00a0\u00a0\"\"\"\r\n\u00a0\u00a0\u00a0\u00a0Searches chats for a given user based on the search_text using Couchbase FTS.\r\n\r\n\u00a0\u00a0\u00a0\u00a0Args:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user_id (str): The ID of the user.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0search_text (str): The text to search within chat names.\r\n\r\n\u00a0\u00a0\u00a0\u00a0Returns:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0List[dict]: A list of chat documents that match the search criteria.\r\n\u00a0\u00a0\u00a0\u00a0\"\"\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0try:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Execute the search query against the specified FTS index\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0search_result = cluster.search_query(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"bucket-name.scope-name.search-index-name\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0QueryStringQuery(search_text),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SearchOptions(fields=[\"chat_id\", \"user_id\", \"name\", \"messages.content\", \"messages.timestamp\", \"messages.sender\"])\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0results = []\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for row in search_result.rows():\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chat = row.fields.copy()\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Extract message details\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0messages_content = chat.get(\"messages.content\", [])\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0messages_timestamp = chat.get(\"messages.timestamp\", [])\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0messages_sender = chat.get(\"messages.sender\", [])\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Ensure all message lists are aligned\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if len(messages_content) == len(messages_timestamp) == len(messages_sender):\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chat[\"messages\"] = [\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"content\": content,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"timestamp\": timestamp,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"sender\": sender\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0for content, timestamp, sender in zip(messages_content, messages_timestamp, messages_sender)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.warning(\"Mismatch in message fields. Including only content.\")\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chat[\"messages\"] = [{\"content\": content} for content in messages_content]\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Clean up redundant fields\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chat.pop(\"messages.content\", None)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chat.pop(\"messages.timestamp\", None)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0chat.pop(\"messages.sender\", None)\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0results.append(chat)\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Filter chats belonging to the specified user\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0user_chats = [chat for chat in results if chat.get(\"user_id\") == user_id]\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.info(f\"Search returned {len(user_chats)} chats for user '{user_id}'.\")\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return user_chats\r\n\r\n\u00a0\u00a0\u00a0\u00a0except Exception as e:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0logging.error(f\"Error during search: {e}\")\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return []<\/pre>\n<p><span style=\"font-weight: 400;\">In this snippet, the<\/span><em><span style=\"font-weight: 400;\"> search_chats<\/span><\/em><span style=\"font-weight: 400;\"> function is pivotal in retrieving relevant chat conversations based on user input. When a user enters a search query, the function constructs a search request targeting the FTS index within Couchbase. It specifies the fields to retrieve, ensuring that all necessary information, such as <\/span><em><span style=\"font-weight: 400;\">chat_id<\/span><\/em><span style=\"font-weight: 400;\">, <\/span><em><span style=\"font-weight: 400;\">user_id<\/span><\/em><span style=\"font-weight: 400;\">, <em>name<\/em>, and <\/span><em><span style=\"font-weight: 400;\">message<\/span><\/em><span style=\"font-weight: 400;\"> details, are included in the search results.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-17003 alignright\" style=\"border: 1px solid Gainsboro;\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/chat_interface_example.png\" alt=\"\" width=\"268\" height=\"574\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/chat_interface_example.png 406w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/chat_interface_example-140x300.png 140w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/chat_interface_example-300x643.png 300w\" sizes=\"auto, (max-width: 268px) 100vw, 268px\" \/>As the function processes each search result, it meticulously organizes the message content, timestamps, and senders, ensuring that the data structure remains consistent and reliable. This careful handling guarantees that the frontend receives well-structured data, ready to be displayed to the user without any hiccups.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The interaction between the AI agent and Couchbase ensures that all user interactions are stored securely and can be retrieved swiftly when needed. Whether it&#8217;s fetching chat histories or updating user preferences, Couchbase provides the scalability and performance required to handle a growing user base without compromising on speed or reliability.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When a user initiates a search from the frontend, the React application sends the query to the backend. The AI agent processes this request, interacts with Couchbase to fetch the relevant chats, and sends the results back to the frontend. This round-trip ensures that users receive accurate and timely information, enhancing their overall experience with the application.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">By combining the capabilities of the Browser Use library with the data management features of Couchbase, the application delivers a comprehensive AI agent experience. Users can manage their online tasks, engage in meaningful conversations with their agent, and rely on the system to handle complex operations behind the scenes.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This architecture not only provides immediate functionality but also lays a solid foundation for future enhancements. As the application evolves, the integration between the frontend, AI agent, and Couchbase ensures that it remains adaptable, scalable, and responsive to user needs.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Wrapping up<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The next time you see AI agent services out in the wild and you feel the FOMO because your credit card just can\u2019t quite take the monthly bill, remember with just a bit of Python and a bit of JavaScript, you can have your own agent at your disposal.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Want to get started? Head on over to the project on <a href=\"https:\/\/github.com\/hummusonrails\/browser-use-agent-with-couchbase\">GitHub<\/a><\/span><span style=\"font-weight: 400;\">, clone it to your computer, and follow the instructions in the README to give it a spin.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">What time saving tasks will you have your agent do for you? Join us on our active and growing Discord community to share what you\u2019ve built!<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Start using the AI capabilities in <a href=\"https:\/\/cloud.couchbase.com\">Couchbase Capella<\/a> today, for free<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>If 2024 was the year of AI chatbots, then 2025 is the year of AI agents. At first glance, they may seem similar, but nothing could be farther from the truth. While you may interact with an AI agent in [&hellip;]<\/p>\n","protected":false},"author":85356,"featured_media":17004,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[10123,10122,1815,2165,9973,9139],"tags":[9924],"ppma_author":[9985],"class_list":["post-17001","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-agentic-ai-apps","category-artificial-intelligence-ai","category-best-practices-and-tutorials","category-full-text-search","category-generative-ai-genai","category-python","tag-rag-retrieval-augmented-generation"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Build Your First Open Source AI Agent with Couchbase - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"Build an open-source AI agent with Python, JavaScript, and Couchbase. Automate tasks and deploy your own AI assistant\u2014completely free!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Build Your First Open Source AI Agent with Couchbase\" \/>\n<meta property=\"og:description\" content=\"Build an open-source AI agent with Python, JavaScript, and Couchbase. Automate tasks and deploy your own AI assistant\u2014completely free!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-01T15:00:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-13T23:39:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/blog_header_images_2025-13.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1256\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ben Greenberg, Senior Developer Evangelist\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ben Greenberg, Senior Developer Evangelist\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/\"},\"author\":{\"name\":\"Ben Greenberg, Senior Developer Evangelist\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/48efa1524aec97312d92f65a270c255d\"},\"headline\":\"Build Your First Open Source AI Agent with Couchbase\",\"datePublished\":\"2025-04-01T15:00:17+00:00\",\"dateModified\":\"2025-06-13T23:39:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/\"},\"wordCount\":1323,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2025\\\/03\\\/blog_header_images_2025-13.png\",\"keywords\":[\"RAG retrieval-augmented generation\"],\"articleSection\":[\"Agentic AI Applications\",\"Artificial Intelligence (AI)\",\"Best Practices and Tutorials\",\"Full-Text Search\",\"Generative AI (GenAI)\",\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/\",\"name\":\"Build Your First Open Source AI Agent with Couchbase - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2025\\\/03\\\/blog_header_images_2025-13.png\",\"datePublished\":\"2025-04-01T15:00:17+00:00\",\"dateModified\":\"2025-06-13T23:39:40+00:00\",\"description\":\"Build an open-source AI agent with Python, JavaScript, and Couchbase. Automate tasks and deploy your own AI assistant\u2014completely free!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2025\\\/03\\\/blog_header_images_2025-13.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2025\\\/03\\\/blog_header_images_2025-13.png\",\"width\":2400,\"height\":1256},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/build-your-first-open-source-ai-agent-with-couchbase\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build Your First Open Source AI Agent with Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/48efa1524aec97312d92f65a270c255d\",\"name\":\"Ben Greenberg, Senior Developer Evangelist\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2024\\\/06\\\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpegc9bda12524045d12a5878a2ef3fbe0de\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2024\\\/06\\\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2024\\\/06\\\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpeg\",\"caption\":\"Ben Greenberg, Senior Developer Evangelist\"},\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/bengreenberg\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Build Your First Open Source AI Agent with Couchbase - The Couchbase Blog","description":"Build an open-source AI agent with Python, JavaScript, and Couchbase. Automate tasks and deploy your own AI assistant\u2014completely free!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/","og_locale":"en_US","og_type":"article","og_title":"Build Your First Open Source AI Agent with Couchbase","og_description":"Build an open-source AI agent with Python, JavaScript, and Couchbase. Automate tasks and deploy your own AI assistant\u2014completely free!","og_url":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2025-04-01T15:00:17+00:00","article_modified_time":"2025-06-13T23:39:40+00:00","og_image":[{"width":2400,"height":1256,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/blog_header_images_2025-13.png","type":"image\/png"}],"author":"Ben Greenberg, Senior Developer Evangelist","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ben Greenberg, Senior Developer Evangelist","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/"},"author":{"name":"Ben Greenberg, Senior Developer Evangelist","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/48efa1524aec97312d92f65a270c255d"},"headline":"Build Your First Open Source AI Agent with Couchbase","datePublished":"2025-04-01T15:00:17+00:00","dateModified":"2025-06-13T23:39:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/"},"wordCount":1323,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/blog_header_images_2025-13.png","keywords":["RAG retrieval-augmented generation"],"articleSection":["Agentic AI Applications","Artificial Intelligence (AI)","Best Practices and Tutorials","Full-Text Search","Generative AI (GenAI)","Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/","name":"Build Your First Open Source AI Agent with Couchbase - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/blog_header_images_2025-13.png","datePublished":"2025-04-01T15:00:17+00:00","dateModified":"2025-06-13T23:39:40+00:00","description":"Build an open-source AI agent with Python, JavaScript, and Couchbase. Automate tasks and deploy your own AI assistant\u2014completely free!","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/blog_header_images_2025-13.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2025\/03\/blog_header_images_2025-13.png","width":2400,"height":1256},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/build-your-first-open-source-ai-agent-with-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Build Your First Open Source AI Agent with Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/48efa1524aec97312d92f65a270c255d","name":"Ben Greenberg, Senior Developer Evangelist","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/06\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpegc9bda12524045d12a5878a2ef3fbe0de","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/06\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpeg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/06\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpeg","caption":"Ben Greenberg, Senior Developer Evangelist"},"url":"https:\/\/www.couchbase.com\/blog\/author\/bengreenberg\/"}]}},"acf":[],"authors":[{"term_id":9985,"user_id":85356,"is_guest":0,"slug":"bengreenberg","display_name":"Ben Greenberg, Senior Developer Evangelist","avatar_url":{"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/06\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpeg","url2x":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2024\/06\/T024FJS4M-U075H3NTJUR-b4c321d902e2-512.jpeg"},"0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/17001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/85356"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=17001"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/17001\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/17004"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=17001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=17001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=17001"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=17001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}