{
  "schema_version": 2,
  "id": "develop/ai/agent-builder/agent-concepts",
  "title": "How agents work",
  "url": "https://redis.io/docs/latest/develop/ai/agent-builder/agent-concepts/",
  "summary": "Learn how AI agents work and why Redis is the perfect foundation for building intelligent systems",
  "tags": [
    "docs",
    "develop",
    "ai"
  ],
  "last_updated": "2026-10-02T07:18:00-07:00",
  "page_type": "content",
  "content_hash": "3b9051de5128f8948ec026aee6f3cbadd1a50113d815af2ae8f95b5e35ec378e",
  "sections": [
    {
      "id": "how-ai-agents-work",
      "title": "How AI agents work",
      "role": "overview",
      "text": "AI agents are autonomous systems that go far beyond simple chatbots. They combine large language models (LLMs) with external tools, memory, and planning capabilities to accomplish complex tasks.\n\n**Key differences from chatbots:**\n- Maintain state across multiple conversations\n- Reason through problems step-by-step\n- Take actions in the real world\n- Learn and adapt from interactions"
    },
    {
      "id": "core-agent-architecture",
      "title": "Core agent architecture",
      "role": "content",
      "text": "![AI agent architecture](https://redis.io/docs/latest/images/ai_agent/ai-agent-architecture-diagram.svg)"
    },
    {
      "id": "the-agent-processing-cycle",
      "title": "The agent processing cycle",
      "role": "content",
      "text": "Every user interaction follows a 6-step cycle that makes agents intelligent:\n\n![AI agent processing cycle](https://redis.io/docs/latest/images/ai_agent/simple-processing-cycle.svg)\n\nWhy this cycle matters:\n- Maintains context across multiple conversations\n- Learns from experience to improve future responses\n- Handles complex tasks that require multiple steps\n- Recovers from failures and adapts plans in real-time\n\n> Example: When you ask \"Book me a flight to Paris and find a hotel,\" the agent breaks this into separate tasks, remembers your travel preferences, searches for options, and coordinates the booking process."
    },
    {
      "id": "why-redis-powers-ai-agents",
      "title": "Why Redis powers AI agents",
      "role": "content",
      "text": "Redis is the **ideal foundation** for AI agents because it excels at the three things agents need most: **speed**, **memory**, and **search**."
    },
    {
      "id": "redis-powers-every-part-of-your-agent",
      "title": "Redis powers every part of your agent",
      "role": "content",
      "text": "<div class=\"grid grid-cols-1 md:grid-cols-3 gap-4 my-6\">\n  <div class=\"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700\">\n    <h4 class=\"font-semibold text-black dark:text-white mb-2\">Planner</h4>\n    <p class=\"text-sm text-black dark:text-white\">Stores workflow templates and agent plans as Hashes or JSON. Enables complex multi-step reasoning.</p>\n  </div>\n\n  <div class=\"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700\">\n    <h4 class=\"font-semibold text-black dark:text-white mb-2\">Retriever</h4>\n    <p class=\"text-sm text-black dark:text-white\">Vector Search finds semantically similar documents instantly. Supports hybrid search for better results.</p>\n  </div>\n\n  <div class=\"bg-gray-50 dark:bg-gray-800 p-4 rounded-lg border border-gray-200 dark:border-gray-700\">\n    <h4 class=\"font-semibold text-black dark:text-white mb-2\">Executor</h4>\n    <p class=\"text-sm text-black dark:text-white\">Stores conversation history, user preferences, and intermediate results. Maintains state across workflows.</p>\n  </div>\n</div>"
    },
    {
      "id": "key-advantages",
      "title": "Key advantages",
      "role": "content",
      "text": "**Ultra-fast response times**\n- Sub-millisecond data access keeps conversations flowing naturally\n- In-memory processing eliminates disk I/O bottlenecks\n- Optimized data structures for different use cases\n\n**Built-in vector search**\n- Native vector indexing with HNSW, FLAT, and SVS-VAMANA algorithms\n- SVS-VAMANA leverages Intel hardware acceleration for enhanced performance\n- Hybrid search combining vector similarity with metadata filtering\n- Real-time updates without index rebuilds\n- [Learn more about Redis Vector Search →](https://redis.io/docs/latest/develop/ai/search-and-query/vectors)\n\n**Agent memory**\n- **Short-term**: Conversation context and session state\n- **Long-term**: User preferences and learned patterns\n- Flexible data structures (Hashes, Lists, Streams, JSON) for different memory types\n- **Managed option**: The [Redis Iris Context Engine](https://redis.io/docs/latest/develop/ai/context-engine/agent-memory) provides short-term (session) and long-term memory as a managed service — with semantic long-term search — so you don't have to build the vector index and storage yourself\n- [Explore Redis data structures →](https://redis.io/docs/latest/develop/data-types)"
    },
    {
      "id": "managed-agent-context-with-redis-iris",
      "title": "Managed agent context with Redis Iris",
      "role": "content",
      "text": "You can build each part of an agent's context layer yourself from Redis data structures, or use the [Redis Iris context engine](https://redis.io/docs/latest/develop/ai/context-engine) services as a pre-built solution. Each service runs fully managed on Redis Cloud, or self-managed on your own infrastructure, and has a REST API.\n\n| Agent need | Build it yourself with Redis | Redis Iris service |\n|:--|:--|:--|\n| Remember the user across sessions | Streams, Hashes, and vector search for session and long-term memory | [Agent Memory](https://redis.io/docs/latest/develop/ai/context-engine/agent-memory) stores session events, summarizes long sessions, and extracts long-term memories in the background. |\n| Avoid repeat LLM calls | Vector search plus your own cache logic | [LangCache](https://redis.io/docs/latest/develop/ai/context-engine/langcache) returns a cached response when a new prompt is semantically similar to a cached one. |\n| Query business data safely | Hand-written tools or generated queries per agent | [Context Retriever](https://redis.io/docs/latest/develop/ai/context-engine/context-retriever) generates tools from a data model you define once. Agents call them over MCP (Model Context Protocol), and agent keys limit what each agent can reach. |\n| Keep that data current | Your own sync jobs from the source database | [Data Integration](https://redis.io/docs/latest/develop/ai/context-engine/data-integration) streams changes from relational databases into Redis within seconds. |\n\nLangCache, Agent Memory, and Context Retriever are currently in preview. To see where each service fits in a single request, see [how a request flows through Redis Iris](https://redis.io/docs/latest/develop/ai/context-engine/concepts/request-flow)."
    },
    {
      "id": "types-of-agents-you-can-build",
      "title": "Types of agents you can build",
      "role": "content",
      "text": "<div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 my-8\">\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Conversational assistants</h3>\n\nBuild chatbots and virtual assistants that:\n- Maintain natural conversations with context and memory\n- Provide personalized responses based on user history\n\n[Build a conversational agent →](../)\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Recommendation engines</h3>\n\nCreate intelligent recommendation systems that:\n- Learn from user behavior and preferences\n- Provide real-time personalized suggestions\n\n[Build a recommendation agent →](../)\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Knowledge assistants (RAG)</h3>\n\nBuild retrieval-augmented generation agents that:\n- Ingest documents and answer questions with citations\n- Combine vector search with semantic caching for fast, grounded responses\n\n[Build a knowledge assistant →](../)\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Redis Iris conversational assistants</h3>\n\nBuild conversational agents backed by managed Redis Iris Agent Memory that:\n- Get session and long-term memory without building a vector index\n- Extract durable memories automatically in the background\n\n[Build a Redis Iris agent →](../)\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Task automation agents</h3>\n\nAutomate complex workflows and business processes:\n- Execute multi-step tasks with decision-making\n- Integrate with APIs and external systems\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Data analysis agents</h3>\n\nProcess and analyze large datasets intelligently:\n- Perform statistical analysis and pattern recognition\n- Handle real-time data streams\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Customer support agents</h3>\n\nProvide intelligent customer service:\n- Answer questions using knowledge bases\n- Route complex issues to human agents\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Research and retrieval agents</h3>\n\nFind and synthesize information from multiple sources:\n- Search across documents, databases, and web content\n- Summarize findings and extract key insights\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Monitoring and alerting agents</h3>\n\nWatch systems and notify when action is needed:\n- Detect anomalies and security threats\n- Send intelligent alerts with context\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Personal productivity agents</h3>\n\nHelp users manage tasks and information:\n- Schedule meetings and manage calendars\n- Organize and prioritize tasks\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Trading and financial agents</h3>\n\nMake intelligent financial decisions:\n- Analyze market data and trends\n- Execute trades based on predefined strategies\n</div>\n\n<div class=\"bg-gray-50 p-4 rounded-lg border border-gray-200\">\n<h3 class=\"no-toc\">Content generation agents</h3>\n\nCreate and manage content at scale:\n- Generate articles, summaries, and documentation\n- Adapt content for different audiences and formats\n</div>\n\n</div>"
    },
    {
      "id": "agent-architecture-patterns",
      "title": "Agent architecture patterns",
      "role": "content",
      "text": ""
    },
    {
      "id": "single-agent-systems",
      "title": "Single-agent systems",
      "role": "content",
      "text": "Simple agents that handle all tasks within one system:\n- Easier to develop and maintain\n- Good for focused use cases\n- All logic contained in one place\n- Suitable for most applications"
    },
    {
      "id": "multi-agent-systems",
      "title": "Multi-agent systems",
      "role": "content",
      "text": "Multiple specialized agents working together:\n- Each agent handles specific domains or tasks\n- agents can communicate and coordinate\n- More complex but more scalable\n- Good for enterprise applications"
    },
    {
      "id": "hierarchical-agents",
      "title": "Hierarchical agents",
      "role": "content",
      "text": "Agents organized in layers with different responsibilities:\n- High-level agents handle planning and coordination\n- Low-level agents execute specific tasks\n- Clear separation of concerns\n- Easier to debug and maintain"
    },
    {
      "id": "redis-data-structures-for-agent-memory",
      "title": "Redis data structures for agent memory",
      "role": "content",
      "text": "Understanding how to map agent memory needs to Redis data structures is crucial for building efficient agents:"
    },
    {
      "id": "redis-streams-for-conversation-history",
      "title": "Redis streams for conversation history",
      "role": "content",
      "text": "- Use case: Ordered conversation logs with timestamps and metadata\n- Key benefits: Automatic ordering, range queries, consumer groups, guaranteed delivery\n- Implementation: Store user/agent message pairs with rich contextual metadata\n- Retention: Use XTRIM for automatic cleanup based on age or count limits\n- [Learn about Redis Streams →](https://redis.io/docs/latest/develop/data-types/streams)"
    },
    {
      "id": "redis-hashes-for-user-profiles",
      "title": "Redis Hashes for User Profiles",
      "role": "content",
      "text": "- Use case: Structured user data with frequent partial updates and atomic operations\n- Key benefits: Memory efficient field-level operations, atomic updates, O(1) field access\n- Implementation: Multi-layered profile system with preferences, behavior patterns, and learned data\n- Scaling: Hash tags for cluster distribution, field expiration for data lifecycle management\n- [Learn about Redis Hashes →](https://redis.io/docs/latest/develop/data-types/hashes)"
    },
    {
      "id": "redis-json-for-complex-state",
      "title": "Redis JSON for Complex State",
      "role": "content",
      "text": "- Use case: Nested data structures, complex agent workflows, hierarchical configurations\n- Key benefits: JSONPath queries, atomic nested updates, schema validation, efficient storage\n- Implementation: Multi-step task orchestration, complex decision trees, dynamic configurations\n- Querying: Advanced JSONPath expressions for complex data retrieval and manipulation\n- [Learn about Redis JSON →](https://redis.io/docs/latest/develop/data-types/json)"
    },
    {
      "id": "redis-sets-for-relationships-and-tags",
      "title": "Redis Sets for Relationships and Tags",
      "role": "content",
      "text": "- Use case: Entity relationships, user interest tracking, session management, feature flags\n- Key benefits: O(1) membership testing, efficient set operations, automatic deduplication\n- Implementation: Complex relationship modeling, real-time recommendation engines, access control\n- Operations: Union, intersection, difference for advanced analytics and personalization\n- [Learn about Redis Sets →](https://redis.io/docs/latest/develop/data-types/sets)"
    },
    {
      "id": "redis-vector-sets-for-semantic-search",
      "title": "Redis Vector Sets for Semantic Search",
      "role": "content",
      "text": "- Use case: Embedding storage, similarity search, semantic retrieval, content recommendations\n- Key benefits: High-performance vector similarity search, multiple distance metrics, real-time indexing\n- Implementation: RAG systems, semantic memory, content discovery, personalized recommendations\n- Queries: K-nearest neighbor search, range queries, hybrid filtering with metadata\n- [Learn about Redis Vector Sets →](https://redis.io/docs/latest/develop/data-types/vector-sets)"
    },
    {
      "id": "redis-sorted-sets-for-rankings-and-priorities",
      "title": "Redis Sorted Sets for Rankings and Priorities",
      "role": "content",
      "text": "- Use case: Dynamic scoring systems, priority queues, leaderboards, time-series data\n- Key benefits: O(log N) insertions, range queries by score/rank, atomic score updates\n- Implementation: Real-time recommendation scoring, task prioritization, performance analytics\n- Queries: Range by score, rank, lexicographical order, and complex aggregations\n- [Learn about Redis Sorted Sets →](https://redis.io/docs/latest/develop/data-types/sorted-sets)"
    },
    {
      "id": "reliability-features",
      "title": "Reliability features",
      "role": "content",
      "text": "Production-ready agents include built-in reliability features:"
    },
    {
      "id": "error-handling",
      "title": "Error handling",
      "role": "errors",
      "text": "- Gracefully handle API failures and unexpected inputs\n- Provide helpful error messages when things go wrong\n- Continue functioning even when some components fail"
    },
    {
      "id": "retry-logic",
      "title": "Retry logic",
      "role": "content",
      "text": "- Automatically retry failed operations with exponential backoff\n- Handle temporary network issues and rate limiting\n- Ensure important operations complete successfully"
    },
    {
      "id": "logging-and-monitoring",
      "title": "Logging and monitoring",
      "role": "content",
      "text": "- Track what your agent does for debugging and improvement\n- Monitor performance metrics like response times\n- Log errors and unusual behavior for investigation"
    },
    {
      "id": "performance-optimization",
      "title": "Performance optimization",
      "role": "performance",
      "text": "- Cache frequently accessed information\n- Cache LLM responses semantically, so paraphrased questions skip the model call. [LangCache](https://redis.io/docs/latest/develop/ai/context-engine/langcache) does this as a managed service\n- Use efficient data structures for fast retrieval\n- Scale resources based on demand"
    },
    {
      "id": "production-deployment-considerations",
      "title": "Production deployment considerations",
      "role": "content",
      "text": ""
    },
    {
      "id": "monitoring-and-observability",
      "title": "Monitoring and Observability",
      "role": "content",
      "text": "- Agent performance metrics: Response times, success rates, user satisfaction\n- Redis metrics: Memory usage, connection counts, operation latencies\n- LLM usage tracking: Token consumption, API costs, rate limiting\n- Business metrics: Task completion rates, user engagement, conversion"
    },
    {
      "id": "security-and-privacy",
      "title": "Security and Privacy",
      "role": "security",
      "text": "- Data encryption: Encrypt sensitive data at rest and in transit\n- Access controls: Implement proper authentication and authorization\n- Governed data access: Give agents defined tools instead of direct database access. [Context Retriever](https://redis.io/docs/latest/develop/ai/context-engine/context-retriever/concepts) generates these tools and uses access tags to filter what each agent can see\n- Data retention: Automatic cleanup of personal data per regulations\n- Sensitive data in memory: Keep information such as payment card numbers out of long-term memory. Agent Memory [sensitive-data exclusions](https://redis.io/docs/latest/operate/iris/agent-memory/create-service#sensitive-data-exclusions) guide automatic extraction away from it\n- Audit logging: Track all data access and modifications\n- Memory integrity: Validate content before it is written to agent memory and verify protected records on read. Memory written from tool results, web pages, or other agents can carry instructions that are replayed into later prompts ([OWASP Top 10 for Agentic Applications, ASI06](https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/); [MITRE ATLAS AML.T0080.000](https://atlas.mitre.org/techniques/AML.T0080.000)). [OWASP Agent Memory Guard](https://github.com/OWASP/www-project-agent-memory-guard) is an open-source guard for this with adapters for LangChain, OpenAI Agents SDK, AutoGen, CrewAI, and mem0"
    },
    {
      "id": "scaling-strategies",
      "title": "Scaling Strategies",
      "role": "content",
      "text": "- Horizontal scaling: Multiple agent instances with shared Redis state\n- Load balancing: Distribute requests across agent instances\n- Redis clustering: Scale data storage across multiple nodes\n- Caching layers: CDN for static content, Redis for dynamic data\n- [Learn about Redis scaling →](https://redis.io/docs/latest/operate/rs/clusters)"
    },
    {
      "id": "cost-optimization",
      "title": "Cost Optimization",
      "role": "content",
      "text": "- LLM cost management: Use appropriate models for different tasks, and serve repeat questions from a semantic cache such as [LangCache](https://redis.io/docs/latest/develop/ai/context-engine/langcache)\n- Redis memory optimization: Efficient data structures and TTL policies\n- API rate limiting: Prevent excessive external API calls\n- Resource monitoring: Track and optimize compute and storage costs\n- [Redis performance optimization →](https://redis.io/docs/latest/operate/rs/databases/memory-performance)\n\n---"
    },
    {
      "id": "key-takeaways",
      "title": "Key takeaways",
      "role": "content",
      "text": "<div class=\"bg-gray-50 p-6 rounded-lg border border-gray-200 my-8\">\n\n**What makes agents different:**\nAgents maintain memory, plan multi-step tasks, and learn from interactions—unlike simple chatbots.\n\n**Why Redis is perfect:**\nSub-millisecond data access, built-in vector search, and flexible data structures designed for agent workflows.\n\n**What you can build:**\nConversational assistants, recommendation engines, and complex multi-agent systems.\n\n</div>"
    },
    {
      "id": "next-steps",
      "title": "Next steps",
      "role": "content",
      "text": "Ready to build your AI agent with Redis?\n\n**Get started:**\n- [Use the agent builder](https://redis.io/docs/latest/develop/ai/agent-builder) to generate your code and get started\n- [Redis quick start guide](https://redis.io/docs/latest/develop/get-started) for setting up Redis\n\n**Learn more:**\n- [Redis Iris Context Engine — Agent Memory](https://redis.io/docs/latest/develop/ai/context-engine/agent-memory) for managed session and long-term agent memory\n- [Redis Iris concepts](https://redis.io/docs/latest/develop/ai/context-engine/concepts) for how memory, caching, and governed data access work together\n- Interactive demos for [Agent Memory](https://redis.io/docs/latest/develop/ai/context-engine/agent-memory/interactive-demo), [LangCache](https://redis.io/docs/latest/develop/ai/context-engine/langcache/interactive-demo), and [Context Retriever](https://redis.io/docs/latest/develop/ai/context-engine/context-retriever/interactive-demo) that run in your browser\n- [Redis Vector Search documentation](https://redis.io/docs/latest/develop/ai/search-and-query/vectors)\n- [RedisVL Python library](https://redis.io/docs/latest/develop/clients/redis-vl) for vector operations and AI workflows\n- [Redis data structures guide](https://redis.io/docs/latest/develop/data-types)\n- [Redis client libraries](https://redis.io/docs/latest/develop/clients) for your programming language\n\n**Deploy and scale:**\n- [Redis Cloud](https://redis.io/docs/latest/operate/rc) for managed Redis hosting\n- [Redis Software](https://redis.io/docs/latest/operate/rs) for on-premises deployment\n- [Performance optimization](https://redis.io/docs/latest/operate/rs/databases/memory-performance) best practices"
    }
  ],
  "examples": []
}
