Session wrapper keeps state, memory, and knowledge in one place for local agents or remote HTTP endpoints.
Quick Start
Constructor
| Parameter | Description |
|---|---|
session_id | Unique session identifier; auto-generated when omitted |
user_id | User scope for memory operations |
agent_url | Remote agent URL (enables remote mode) |
memory_config | Memory backend config (local sessions only) |
knowledge_config | Knowledge backend config (local sessions only) |
timeout | HTTP timeout for remote calls (seconds) |
session_ttl | Optional expiry in seconds |
State & Memory
| Method | Purpose |
|---|---|
save_state / restore_state | Persist arbitrary dict state |
get_state / set_state | Single key access |
increment_state | Atomic numeric counter helper |
add_memory / search_memory / clear_memory | Session-scoped memory |
add_knowledge / search_knowledge | Knowledge base (local only) |
get_context | Build prompt context from memory |
Session Lifecycle
_test_remote_connection() during init — connection failures raise before you chat.
Remote Sessions
Related
Session Persistence
Agent
memory={"session_id": ...} pathSession Store
Pluggable backends and hierarchical sessions

