> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Session • AI Agent SDK

> Session: A simple wrapper around PraisonAI's existing stateful capabilities.

# Session

> Defined in the [**session**](../modules/session) module.

<Badge color="blue">AI Agent</Badge>

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

<ParamField query="session_id" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="user_id" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="agent_url" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="memory_config" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="knowledge_config" type="Optional" required={false}>
  No description available.
</ParamField>

<ParamField query="timeout" type="int" required={false} default="30">
  No description available.
</ParamField>

## Methods

<CardGroup cols={2}>
  <Card title="memory()" icon="function" href="../functions/Session-memory">
    Lazy-loaded memory instance
  </Card>

  <Card title="knowledge()" icon="function" href="../functions/Session-knowledge">
    Lazy-loaded knowledge instance
  </Card>

  <Card title="Agent()" icon="function" href="../functions/Session-Agent">
    Create an agent with session context.
  </Card>

  <Card title="create_agent()" icon="function" href="../functions/Session-create_agent">
    Backward compatibility wrapper for Agent method
  </Card>

  <Card title="save_state()" icon="function" href="../functions/Session-save_state">
    Save session state data to memory.
  </Card>

  <Card title="restore_state()" icon="function" href="../functions/Session-restore_state">
    Restore session state from memory.
  </Card>

  <Card title="get_state()" icon="function" href="../functions/Session-get_state">
    Get a specific state value
  </Card>

  <Card title="set_state()" icon="function" href="../functions/Session-set_state">
    Set a specific state value
  </Card>

  <Card title="increment_state()" icon="function" href="../functions/Session-increment_state">
    Increment a numeric state value
  </Card>

  <Card title="add_memory()" icon="function" href="../functions/Session-add_memory">
    Add information to session memory.
  </Card>

  <Card title="search_memory()" icon="function" href="../functions/Session-search_memory">
    Search session memory.
  </Card>

  <Card title="add_knowledge()" icon="function" href="../functions/Session-add_knowledge">
    Add knowledge source to session.
  </Card>

  <Card title="search_knowledge()" icon="function" href="../functions/Session-search_knowledge">
    Search session knowledge base.
  </Card>

  <Card title="clear_memory()" icon="function" href="../functions/Session-clear_memory">
    Clear session memory.
  </Card>

  <Card title="get_context()" icon="function" href="../functions/Session-get_context">
    Build context from session memory and knowledge.
  </Card>

  <Card title="chat()" icon="function" href="../functions/Session-chat">
    Send a message to the remote agent or handle local session.
  </Card>

  <Card title="send_message()" icon="function" href="../functions/Session-send_message">
    Alias for chat() method to match Google ADK pattern.
  </Card>
</CardGroup>

## Usage

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# 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

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/session.py#L23">
  `praisonaiagents/session.py` at line 23
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Session Management" icon="clock" href="/docs/concepts/session-management" />

  <Card title="Sessions Feature" icon="folder" href="/docs/features/sessions" />

  <Card title="Session Persistence" icon="database" href="/docs/features/session-persistence" />
</CardGroup>
