strands.session.repository_session_manager
Repository session manager implementation.
RepositorySessionManager
Section titled “RepositorySessionManager”class RepositorySessionManager(SessionManager)Defined in: src/strands/session/repository_session_manager.py:28
Session manager for persisting agents in a SessionRepository.
__init__
Section titled “__init__”def __init__(session_id: str, session_repository: SessionRepository, **kwargs: Any)Defined in: src/strands/session/repository_session_manager.py:31
Initialize the RepositorySessionManager.
If no session with the specified session_id exists yet, it will be created in the session_repository.
Arguments:
session_id- ID to use for the session. A new session with this id will be created if it does not exist in the repository yetsession_repository- Underlying session repository to use to store the sessions state.**kwargs- Additional keyword arguments for future extensibility.
append_message
Section titled “append_message”def append_message(message: Message, agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/repository_session_manager.py:66
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.
redact_latest_message
Section titled “redact_latest_message”def redact_latest_message(redact_message: Message, agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/repository_session_manager.py:85
Redact the latest message appended to 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.
sync_agent
Section titled “sync_agent”def sync_agent(agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/repository_session_manager.py:99
Serialize and update the agent into the session repository.
Only updates the agent if state has been modified or internal state has changed. This optimization reduces unnecessary I/O operations when the agent processes messages without modifying its state.
Arguments:
agent- Agent to sync to the session.**kwargs- Additional keyword arguments for future extensibility.
initialize
Section titled “initialize”def initialize(agent: "Agent", **kwargs: Any) -> NoneDefined in: src/strands/session/repository_session_manager.py:162
Initialize an agent with a session.
Arguments:
agent- Agent to initialize from the session**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/repository_session_manager.py:286
Serialize and update the multi-agent state into the session repository.
Arguments:
source- Multi-agent source object to sync to the session.**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/repository_session_manager.py:295
Initialize multi-agent state from the session repository.
Arguments:
source- Multi-agent source object to restore state into**kwargs- Additional keyword arguments for future extensibility.
initialize_bidi_agent
Section titled “initialize_bidi_agent”def initialize_bidi_agent(agent: "BidiAgent", **kwargs: Any) -> NoneDefined in: src/strands/session/repository_session_manager.py:309
Initialize a bidirectional agent with a session.
Arguments:
agent- BidiAgent to initialize from the session**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/repository_session_manager.py:362
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/repository_session_manager.py:381
Serialize and update the bidirectional agent into the session repository.
Arguments:
agent- BidiAgent to sync to the session.**kwargs- Additional keyword arguments for future extensibility.