1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! # agent-framework-redis
//!
//! Redis-backed [`HistoryProvider`](agent_framework_core::history::HistoryProvider)
//! and [`ContextProvider`](agent_framework_core::memory::ContextProvider) for
//! `agent-framework-rs`, porting `agent_framework_redis` from the Python
//! Agent Framework.
//!
//! - [`RedisChatMessageStore`] — one Redis `LIST` per session,
//! JSON-serialized messages, optional automatic trimming. A close mirror
//! of the Python `RedisChatMessageStore`, adapted to the
//! [`HistoryProvider`](agent_framework_core::history::HistoryProvider)
//! contract (`before_run`/`after_run`) now that conversation history lives
//! in a context provider rather than on the session/thread itself.
//! - [`RedisContextProvider`] — scoped long-term memory storage/retrieval.
//! Ports the Python `RedisProvider`'s *scoping* semantics
//! (application/agent/user/thread id). When the connected server has
//! RediSearch loaded (Redis Stack), retrieval is backed by a real
//! `FT.SEARCH` BM25 full-text index; otherwise it falls back to a
//! `SCAN`+token-match path over plain Redis. Vector/hybrid search is
//! **not** ported — see the [`context_provider`] module docs for the full
//! picture.
//!
//! Both types connect lazily: constructing them only parses the Redis URL
//! (via [`redis::Client::open`]); the actual
//! [`MultiplexedConnection`](redis::aio::MultiplexedConnection) is
//! established on the first call that needs it.
//!
//! ```no_run
//! use agent_framework_core::prelude::*;
//! use agent_framework_redis::{RedisChatMessageStore, RedisContextProvider};
//! use std::sync::Arc;
//!
//! # async fn demo(client: impl ChatClient + 'static) -> Result<()> {
//! let store = RedisChatMessageStore::new("redis://127.0.0.1:6379", None)?
//! .with_max_messages(200);
//!
//! let memory = RedisContextProvider::new("redis://127.0.0.1:6379")?.with_user_id("user-42");
//!
//! let agent = Agent::builder(client)
//! .instructions("You are a helpful assistant.")
//! .context_provider(Arc::new(memory))
//! .build();
//!
//! let mut session = AgentSession::new().with_context_providers(vec![Arc::new(store)]);
//! let response = agent
//! .run(vec![Message::user("Hello!")], Some(&mut session))
//! .await?;
//! println!("{}", response.text());
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;