strands.session.session_manager
Session manager interface for agent session management.
SessionManager
Section titled “SessionManager”class SessionManager(HookProvider, ABC)Defined in: src/strands/session/session_manager.py:31
Abstract interface for managing sessions.
A session manager is in charge of persisting the conversation and state of an agent across its interaction. Changes made to the agents conversation, state, or other attributes should be persisted immediately after they are changed. The different methods introduced in this class are called at important lifecycle events for an agent, and should be persisted in the session.
register_hooks
Section titled “register_hooks”def register_hooks(registry: HookRegistry, **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:40
Register hooks for persisting the agent to the session.
redact_latest_message
Section titled “redact_latest_message”@abstractmethoddef redact_latest_message(redact_message: Message, agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:65
Redact the message most recently appended to the agent in the session.
Arguments:
redact_message- New message to use that contains the redact contentagent- Agent to apply the message redaction to**kwargs- Additional keyword arguments for future extensibility.
append_message
Section titled “append_message”@abstractmethoddef append_message(message: Message, agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:75
Append a message to the agent’s session.
Arguments:
message- Message to add to the agent in the sessionagent- Agent to append the message to**kwargs- Additional keyword arguments for future extensibility.
sync_agent
Section titled “sync_agent”@abstractmethoddef sync_agent(agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:85
Serialize and sync the agent with the session storage.
Arguments:
agent- Agent who should be synchronized with the session storage**kwargs- Additional keyword arguments for future extensibility.
initialize
Section titled “initialize”@abstractmethoddef initialize(agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:94
Initialize an agent with a session.
Arguments:
agent- Agent to initialize**kwargs- Additional keyword arguments for future extensibility.
sync_multi_agent
Section titled “sync_multi_agent”def sync_multi_agent(source: "MultiAgentBase", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:102
Serialize and sync multi-agent with the session storage.
Arguments:
source- Multi-agent source object to persist**kwargs- Additional keyword arguments for future extensibility.
initialize_multi_agent
Section titled “initialize_multi_agent”def initialize_multi_agent(source: "MultiAgentBase", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:115
Read multi-agent state from persistent storage.
Arguments:
**kwargs- Additional keyword arguments for future extensibility.source- Multi-agent state to initialize.
Returns:
Multi-agent state dictionary or empty dict if not found.
initialize_bidi_agent
Section titled “initialize_bidi_agent”def initialize_bidi_agent(agent: "BidiAgent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:132
Initialize a bidirectional agent with a session.
Arguments:
agent- BidiAgent to initialize**kwargs- Additional keyword arguments for future extensibility.
append_bidi_message
Section titled “append_bidi_message”def append_bidi_message(message: Message, agent: "BidiAgent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:145
Append a message to the bidirectional agent’s session.
Arguments:
message- Message to add to the agent in the sessionagent- BidiAgent to append the message to**kwargs- Additional keyword arguments for future extensibility.
sync_bidi_agent
Section titled “sync_bidi_agent”def sync_bidi_agent(agent: "BidiAgent", **kwargs: Any) -> NoneDefined in: src/strands/session/session_manager.py:159
Serialize and sync the bidirectional agent with the session storage.
Arguments:
agent- BidiAgent who should be synchronized with the session storage**kwargs- Additional keyword arguments for future extensibility.