{"id":14413,"library":"agent-framework-redis","title":"Redis Integration for Microsoft Agent Framework","description":"agent-framework-redis provides robust Redis integration for the Microsoft Agent Framework, offering persistent storage for conversational history and a flexible context provider for long-term memory. It leverages Redis for efficient, thread-safe chat message storage and advanced context management, including optional vector search capabilities. The library is part of the broader Microsoft Agent Framework ecosystem and is actively developed, with its release cadence tied to the main framework.","status":"active","version":"1.0.0b260409","language":"en","source_language":"en","source_url":"https://github.com/microsoft/agent-framework","tags":["ai","agents","redis","microsoft","memory","context","chat-history"],"install":[{"cmd":"pip install agent-framework-redis","lang":"bash","label":"Install `agent-framework-redis`"}],"dependencies":[{"reason":"Core Redis client for communication.","package":"redis","optional":false},{"reason":"Provides backports of standard library typing features.","package":"typing-extensions","optional":false},{"reason":"Required for Azure AD authentication when using `CredentialProvider` with Azure Managed Redis.","package":"azure-identity","optional":true}],"imports":[{"symbol":"RedisChatMessageStore","correct":"from agent_framework.redis import RedisChatMessageStore"},{"note":"Used for context management and long-term memory, potentially with vector search. `RedisChatMessageStore` is for chat history.","symbol":"RedisProvider","correct":"from agent_framework.redis import RedisProvider"}],"quickstart":{"code":"import asyncio\nimport os\nfrom agent_framework.redis import RedisChatMessageStore\nfrom agent_framework.core.message import Message, Role\n\nasync def main():\n    # Connect to Redis. Replace with your Redis URL or environment variable.\n    # For local Redis, use redis://localhost:6379\n    redis_url = os.environ.get('REDIS_URL', 'redis://localhost:6379')\n    session_id = 'my-unique-conversation-123'\n\n    # Initialize the Redis chat message store\n    # max_messages can be set to limit history, None for unlimited\n    store = RedisChatMessageStore(\n        redis_url=redis_url,\n        thread_id=session_id,\n        max_messages=10 # Example: retain last 10 messages\n    )\n\n    print(f\"Storing messages for session: {session_id}\")\n\n    # Add messages to the store\n    await store.add_messages([\n        Message(role=Role.USER, content='Hello, agent!', author_name='User'),\n        Message(role=Role.ASSISTANT, content='Hi there! How can I help you?', author_name='Agent')\n    ])\n\n    # Retrieve messages from the store\n    retrieved_messages = await store.get_messages()\n    print(\"\\nRetrieved messages:\")\n    for msg in retrieved_messages:\n        print(f\"[{msg.author_name} ({msg.role.value})]: {msg.content}\")\n\n    # Add more messages to test trimming\n    for i in range(1, 15):\n        await store.add_messages([\n            Message(role=Role.USER, content=f'Message {i}', author_name=f'User{i}')\n        ])\n    \n    print(f\"\\nRetrieved messages after adding more (max_messages={store.max_messages}):\")\n    trimmed_messages = await store.get_messages()\n    for msg in trimmed_messages:\n        print(f\"[{msg.author_name} ({msg.role.value})]: {msg.content}\")\n\n    # Clear the session history\n    await store.clear()\n    print(\"\\nMessages cleared. Current messages:\")\n    print(await store.get_messages())\n\nif __name__ == '__main__':\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to initialize `RedisChatMessageStore`, add messages to it, retrieve messages, and observe message trimming if a `max_messages` limit is set. It also shows how to clear the session history. For local development, ensure a Redis server is running (e.g., via Docker: `docker run -d -p 6379:6379 redis:latest`)."},"warnings":[{"fix":"Always pin to exact versions (`==`) in production environments and review release notes for updates. Consult the Microsoft Agent Framework GitHub repository for the latest status.","message":"The current version `1.0.0b260409` indicates a beta release. While the core `agent-framework` is stable (v1.0.0), specific integration packages like `agent-framework-redis` might still undergo API changes or have unfinalized features before a stable release. Always refer to the latest official documentation.","severity":"gotcha","affected_versions":"1.0.0b*"},{"fix":"Migrate to `agent-framework` version 1.0.0 or higher. Carefully review the migration guide for the main `microsoft/agent-framework` repository if upgrading from pre-1.0.0 versions.","message":"The broader Microsoft Agent Framework (which `agent-framework-redis` is a part of) underwent significant breaking changes leading up to its 1.0.0 stable release, particularly in `agent-framework-core` and `agent-framework-openai`. Although `agent-framework-redis` itself wasn't explicitly listed with all breaking changes, updates to the parent framework could implicitly affect its usage or require dependency version bumps.","severity":"breaking","affected_versions":"<1.0.0 (of parent framework)"},{"fix":"Ensure that only one method of Redis connection configuration is used: either pass a `redis_url` string, or pass a `credential_provider` instance along with the `host` parameter. Never both, and never neither.","message":"When initializing `RedisChatMessageStore` or `RedisProvider`, you must provide either `redis_url` or a combination of `credential_provider` (for Azure AD auth) and `host`. Providing both `redis_url` and `credential_provider`, or neither, will raise a `ValueError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"`RedisChatMessageStore` is designed for chronological storage of `Message` objects in a chat-like format. `RedisProvider` is intended for storing and retrieving more flexible 'context' or 'memories', often leveraging Redis's search capabilities. Understand the distinct purposes of each class before implementing.","message":"The library offers `RedisChatMessageStore` for managing conversational chat history and `RedisProvider` for general context management and long-term memory, potentially with vector search. Confusing these or using the wrong class for a specific memory pattern is a common footgun.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[],"ecosystem":"pypi"}