Skip to main content

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

session_id
Optional
No description available.
user_id
Optional
No description available.
agent_url
Optional
No description available.
memory_config
Optional
No description available.
knowledge_config
Optional
No description available.
timeout
int
default:"30"
No description available.

Methods

memory()

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 GitHub

praisonaiagents/session.py at line 23

Session Management

Sessions Feature

Session Persistence