AI agents have become the talk of the town lately for all the good reasons. AI agents give enterprises the super power they need with their autonomous decision making capabilities. As we know, AI agents can easily sense users’ queries/prompts and take necessary actions autonomously — in many cases, without any human interaction.
That’s what makes them highly intelligent and usable for many complex or redundant tasks. This shift toward intelligent automation reflects an exciting step forward in how technology can independently manage tasks, coordinate multiple functions and adapt to changing conditions with minimal guidance.

That’s where CrewAI and SingleStore come together beautifully to help you build robust agentic applications. CrewAI provides an elegant way to define agents, tasks and workflows. SingleStore serves as a high-performance SQL + vector database that agents can safely query in real time.
In this guide, you’ll build your first agentic application — an AI-powered product analyst that connects to SingleStore, runs SQL queries safely and returns live insights in JSON format.
What is an AI agent?

AI agents represent sophisticated software systems designed to operate independently, making intelligent decisions and executing tasks without constant human oversight. At their core, these systems function as autonomous entities that can analyze situations, formulate strategies and take appropriate actions based on predetermined objectives.
Core architecture of AI agents

The foundation of any AI agent rests on three interconnected pillars that enable seamless autonomous operation:
Environmental awareness (perception). This foundational layer enables agents to gather and process information from their surroundings. Through various sensors, data feeds and input mechanisms, agents continuously monitor their environment to maintain situational awareness.
Cognitive processing (decision-making engine). The central intelligence hub where complex reasoning occurs. This component analyzes incoming data, evaluates options and formulates strategic approaches to achieve desired outcomes. Large Language Models (LLMs) often power this cognitive layer, enabling sophisticated analysis and strategic thinking.
Executive functions (implementation/action). The operational arm that transforms decisions into concrete actions. This component manages task execution, tool integration and external system interactions to bring plans to fruition.
Practical application example

Consider a scenario where someone requests affordable athletic footwear: specifically, Nike running shoes in blue, priced below $500. The AI agent would initiate by parsing this request into structured parameters: brand preference (Nike), product category (running shoes), color specification (blue) and budget constraint (under $500).
The cognitive engine would then orchestrate a multi-step strategy: identifying suitable product categories, researching available inventory and establishing evaluation criteria based on the specified requirements.
During execution, the agent would systematically query product databases, analyze customer reviews, compare pricing across platforms and assess product specifications. This iterative process continues as the system refines its search parameters and evaluation methods.
Throughout this process, the agent leverages its accumulated knowledge and real-time environmental data to optimize results — ultimately presenting curated recommendations that precisely match the user's specifications while maximizing value and satisfaction.
This example demonstrates how AI agents transform simple requests into comprehensive, autonomous problem-solving processes that deliver targeted outcomes through intelligent automation.
CrewAI

CrewAI is an open-source Python framework designed to organize multiple AI agents to work collaboratively as a team, known as a "Crew." Unlike single-agent systems, CrewAI assigns specific roles to each AI agent, like researcher, writer, analyst or manager, with distinct expertise and responsibilities tailored to particular tasks. The framework's architecture promotes specialization and cooperation among agents, reducing AI hallucinations and improving overall accuracy.
CrewAI operates by breaking down complex tasks into smaller, manageable jobs distributed among agents within a crew. It manages workflows through a process manager that controls task execution patterns, allowing agents to work sequentially, in parallel or hierarchically. Agents communicate and build upon each other's work via predefined channels, enhancing collaboration.
Key features include role-based specialized agents, flexible tooling for integration with external systems, intelligent collaboration and sophisticated task management with options for sequential or parallel workflows. CrewAI also supports event-driven control mechanisms called Flows that orchestrate precise, conditional and reliable task execution alongside autonomous crews.
SingleStore

SingleStore is a high-performance, distributed SQL database designed to handle both transactional and analytical workloads in a single platform. SingleStore combines the scalability of NoSQL systems with the familiar relational SQL structure. It features a scale-out architecture that enables horizontal scaling across commodity hardware or cloud environments, allowing users to manage massive data volumes and concurrent queries efficiently.
SingleStore supports both in-memory rowstore tables optimized for transactional processing and disk-based columnstore tables tailored for analytical queries, enabling hybrid transactional and analytical processing (HTAP). Its distributed design includes aggregator nodes that coordinate queries and distribute workloads to leaf nodes, which store data partitions and execute queries in parallel. Key features include lock-free distributed ingest for streaming and bulk data, tiered storage, a sophisticated query optimizer, workload management for CPU and memory resources and extensive support for varied data types including relational, JSON, geospatial and time-series data.
For building agentic applications, SingleStore serves as a robust all-in-one database by providing real-time data ingestion, fast query performance and elastic scalability, thereby supporting the complex and dynamic data needs of autonomous AI agents. Its capability to handle diverse workloads in a unified environment simplifies data infrastructure and accelerates decision-making processes in AI-driven systems, making it an ideal foundation for scalable, data-intensive agentic applications.
Learn more about how SingleStore can help you build real-time AI applications.
Why CrewAI and SingleStore?

Building agentic applications is more than just plugging an LLM into a chat interface. True agentic systems require orchestration, context and actionability. That’s exactly where CrewAI and SingleStore shine — they complement each other to form a powerful stack for intelligent, data-driven applications.
CrewAI gives developers a structured way to define agents with clear goals, tools and backstories, and assign them tasks that can be executed autonomously or collaboratively. Instead of manually chaining prompts, you get a declarative, scalable workflow that is easy to reason about, debug and extend. CrewAI’s abstraction of “Crews” allows multiple agents to coordinate — making it a perfect foundation for multi-step analytics, customer support bots or any use case requiring reasoning + action loops.

But even the smartest agent is useless without reliable, real-time data. That’s where SingleStore comes in. It’s not just a SQL database — it’s a distributed, low-latency data platform capable of handling analytical and transactional workloads at scale. With support for SQL queries, JSON data and even vector search, SingleStore provides a unified, developer-friendly way to store and retrieve the data your agents need.
Together, CrewAI and SingleStore enable you to build production-ready AI agents that don’t just think, but act — querying live data, generating insights and responding in milliseconds. The result? Applications that are not only intelligent, but grounded, reliable and enterprise-ready.
Now that SingleStore has a native integration with crewAI, it is very easy to create agentic applications.
Agentic app with SingleStore and CrewAI: Tutorial!

In this tutorial you’ll build a tiny but real agentic application: a product insights agent that talks to SingleStore and answers natural-language questions by safely running read-only SQL. We’ll use CrewAI to define an agent, task and crew (the orchestrator), and crewai-tools’ SingleStoreSearchTool for pooled, validated SELECT/SHOW queries. You’ll keep credentials in a .env file, seed a products table with demo data and run the agent interactively (e.g., “Top 3 most expensive electronics”). The end result is a clean, extensible skeleton you can grow into multi-table analytics, NL→ SQL, or a full UI.
Prerequisites
Free SingleStore account
OpenAI API key
Step-by-step flow
Step 1: Login to SingleStore, create a workspace and a database

My workspace name is ‘pavappy-workspace-1
’ and my database name is ‘crew’
Step 2: Make sure your database has a products
table
Next, go to ‘Query Editor’ from the SingleStore dashboard and create a ‘New SQL file’.

Once you get into the SQL editor, make sure to select your workspace and database from the dropdown. Create a table (named products) and insert some products into the table.

The data under your database’s table should look like this.

1python3 -m venv venv2source venv/bin/activate
1SINGLESTOREDB_HOST="<add your SingleStore host url>"2SINGLESTOREDB_USER="admin"3SINGLESTOREDB_PASSWORD="<add your SingleStore password>"4SINGLESTOREDB_DATABASE=crew5OPENAI_API_KEY="sk-your-openai-key-here"
Step 5: Main CrewAI logic
main.py
is our entry point and where the CrewAI logic is orchestrated. Think of it as the “director” that wires everything together and kicks off a run.
main.py
wires the app together: it instantiates the SingleStoreSearchTool, then creates an agent with the role “Analyst” (plus a goal, backstory, allowed tools and chosen LLM) and defines a Task using the user’s query and expected output. Finally, a Crew orchestrates the agent running that task — turning your natural-language prompt into SQL, querying SingleStore and returning the result.
1import warnings2import asyncio3 4# --- Suppress Deprecation Warnings globally ---5warnings.simplefilter("ignore", category=DeprecationWarning)6 7# --- Ensure an event loop exists (avoids asyncio warning on Python 3.12) ---8try:9 asyncio.get_event_loop()10except RuntimeError:11 asyncio.set_event_loop(asyncio.new_event_loop())12 13from crewai import Agent, Task, Crew14from crewai_tools import SingleStoreSearchTool15from config import SINGLESTORE_CONFIG16 17def run_agentic_app(query: str):18 """Run a CrewAI agentic workflow with SingleStoreSearchTool for a given query."""19 20 # 1. Setup Tool21 tool = SingleStoreSearchTool(22 # restrict to 'products' table; ensure it exists in DB23 tables=["products"],24 host=SINGLESTORE_CONFIG["host"],25 user=SINGLESTORE_CONFIG["user"],26 password=SINGLESTORE_CONFIG["password"],27 database=SINGLESTORE_CONFIG["database"],28 )29 30 # 2. Setup Agent31 agent = Agent(32 role="Analyst",33 goal=f"Answer the question: {query}",34 backstory=(35 "A data analyst who knows how to write SQL and retrieve insights "36 "from SingleStore in a safe and optimized way."37 ),38 tools=[tool],39 llm="gpt-4o-mini", # can be changed to gpt-4, gpt-3.5-turbo, etc.40 verbose=True,41 )42 43 # 3. Setup Task44 task = Task(45 description=query,46 expected_output="Return results in JSON or a clean, tabular summary",47 agent=agent,48 )49 50 # 4. Setup Crew51 crew = Crew(agents=[agent], tasks=[task], verbose=True)52 53 # 5. Kick off and return result54 return crew.kickoff()55 56if __name__ == "__main__":57 print("\n:mag_right: Product Insights Agent (CrewAI + SingleStore)")58 print("--------------------------------------------------")59 60 user_query = input("Ask me anything about products: ")61 result = run_agentic_app(user_query)62 63 print("\n=== Result ===")64 print(result)65 print("\n:white_check_mark: Query complete!")
Step 6: Load your .env file
config.py
is a tiny helper that loads your .env file and exposes the SingleStore connection settings (host, user, password, database) so the rest of your app can import them without hard-coding secrets.
1import os2from dotenv import load_dotenv3 4# Load .env file5load_dotenv()6 7SINGLESTORE_CONFIG = {8 "host": os.getenv("SINGLESTOREDB_HOST"),9 "user": os.getenv("SINGLESTOREDB_USER"),10 "password": os.getenv("SINGLESTOREDB_PASSWORD"),11 "database": os.getenv("SINGLESTOREDB_DATABASE"),12}
1crewai2crewai-tools[singlestore]3python-dotenv
Install them through this code
1pip install -r requirements.txt
1python main.py
This is what you should see as output.




Our agent took the prompt “Show top 3 most expensive products,” generated the SQL SELECT * FROM products ORDER BY price DESC LIMIT 3
, executed it via SingleStoreSearchTool and returned the rows as clean JSON. The output lists the three priciest items (with id, name, category, price, in_stock, updated_at), confirming the end-to-end agent → SQL → SingleStore → result flow worked.
By the end of this walkthrough, you’ve seen how little code it takes to turn an LLM into a useful, data-grounded agent. CrewAI gives you the orchestration primitives — agents, tasks and a clean execution model — while SingleStore supplies a fast, scalable and reliable data layer the agent can safely query. Together they move you beyond toy prompts to production-ready agentic behavior: plan → query → reason → respond. The same pattern scales naturally — add more tools (files, web search, Slack), more tables (orders, customers) or NL→SQL for free-form questions; then wrap it in FastAPI/Streamlit for a shareable UI. CrewAI + SingleStore provides a pragmatic foundation to ship quickly, iterate safely, and grow into richer multi-agent systems over time.
Sign up to SingleStore and start building your robust agentic applications/systems today!