Session • AI Agent SDK
Session: A simple wrapper around PraisonAI's existing stateful capabilities.
Session
Defined in the session module.
AI Agent
A simple wrapper around PraisonAI’s existing stateful capabilities.
Provides a unified API for:
- Session management with persistent state
- Memory operations (short-term, long-term, user-specific)
- Knowledge base operations
- Agent state management
- Remote agent connectivity
Constructor
OptionalNo description available.
OptionalNo description available.
OptionalNo description available.
OptionalNo description available.
OptionalNo description available.
intNo description available.
Methods
Lazy-loaded memory instance
knowledge()Lazy-loaded knowledge instance
Agent()Create an agent with session context.
create_agent()Backward compatibility wrapper for Agent method
save_state()Save session state data to memory.
restore_state()Restore session state from memory.
get_state()Get a specific state value
set_state()Set a specific state value
increment_state()Increment a numeric state value
add_memory()Add information to session memory.
search_memory()Search session memory.
add_knowledge()Add knowledge source to session.
search_knowledge()Search session knowledge base.
clear_memory()Clear session memory.
get_context()Build context from session memory and knowledge.
chat()Send a message to the remote agent or handle local session.
send_message()Alias for chat() method to match Google ADK pattern.
Usage
# Local session with agent
session = Session(session_id="chat_123", user_id="user_456")
agent = session.Agent(name="Assistant", role="Helpful AI")
# Remote agent session (similar to Google ADK)
session = Session(agent_url="192.168.1.10:8000/agent")
response = session.chat("Hello from remote client!")
# Save session state
session.save_state({"conversation_topic": "AI research"})Source
View on GitHubpraisonaiagents/session.py at line 23