Skip to content

[FEATURE] Add Database Session Management #33

@puritatemcordis

Description

@puritatemcordis

Problem Statement

The current implementation of the Strands agent uses in-memory storage to maintain conversation history. While this is suitable for short-lived sessions, it lacks persistence across application restarts or crashes. To address this limitation, it would be valuable to implement a class that enables saving conversation history to a relational database such as PostgreSQL or MySQL. This enhancement would provide a more robust and reliable foundation for production-grade applications by ensuring conversation state can be preserved and recovered when needed.

Proposed Solution

No response

Use Case

Objective:
Enable the Strands agent to persist conversation history in a relational database to ensure continuity and resilience in production environments.

Primary Actor:
Strands Agent

Stakeholders and Interests:

Developers: Want reliable state management to build robust applications.
End Users: Expect seamless conversation experiences even after interruptions.
Operations/DevOps: Need observability and data recovery mechanisms in case of system failures.
Preconditions:

A relational database (e.g., PostgreSQL, MySQL) is available and configured.
The Strands agent is running in a production or long-lived session environment.

Main Flow:

A user interacts with the Strands agent.
The agent processes user input and generates responses.
Each turn in the conversation (user input and agent response) is saved to the relational database in real-time or at regular intervals.
If the application crashes or restarts, the agent retrieves the saved conversation history from the database.
The agent resumes the conversation with full context, ensuring continuity for the user.

Postconditions:

Conversation history is persistently stored in the database.
The agent can recover and resume sessions after unexpected terminations.

Alternative Flows:

If the database is unreachable, the agent logs the failure and continues with in-memory storage, optionally retrying persistence later.

Alternatives Solutions

No response

Additional Context

No response

Activity

changed the title [-][FEATURE] Add class for Database Session Management[/-] [+][FEATURE] Add Database Session Management[/+] on May 17, 2025
DennisTraub

DennisTraub commented on May 20, 2025

@DennisTraub

Depending on the size of individual messages, particularly if they include multimodal data or large documents, the conversation history can become quite large and difficult to handle for an RDBMS. As an alternative, I would suggest an option to store the history in the local file system with a lightweight lookup index (e.g. a JSON file or SQLLite DB), or an object store like S3, with a lookup table e.g. in DynamoDB.

vincenzodomina

vincenzodomina commented on May 22, 2025

@vincenzodomina

I would definitely need to handle the messages and content blocks (also runs and sessions) as their own tables and records in a relational database (in my case especially for UI use cases and for post processing of results)

My current approach is to store short string contents directly in the content block record in a text field and store multimodal content inputs (images, files or larger texts) as files in S3 and reference them from the content block record. To distinguish small messages from file contents i work with the concept of artifacts (which are then stored as files)

That way the complete chat history can be persisted and retrieved in a performant way without loosing the structure and integrity of the RDB

zastrowm

zastrowm commented on May 22, 2025

@zastrowm
Member

Thanks for the request & use-case.

I think this might fit in with #57 and is something we're looking into how to better support. We don't have any updates to share yet, but our upcoming roadmap should provide more clarity on improvements to this area.

added theissue type on May 29, 2025
removed their assignment
on Jun 18, 2025
moved this from Researching to We're Working On It in Strands Agents Roadmapon Jun 24, 2025
moved this from We're Working On It to Coming Soon in Strands Agents Roadmapon Jul 15, 2025
Unshure

Unshure commented on Jul 29, 2025

@Unshure
Member

Hi @puritatemcordis , I wanted to reach out here with an update that we recently shipped a session manager as part of this Feature Request: #246

I saw that in this feature request, you are specifically asking for a relational database session manager instead of a file based approach like we took. The reason we decided to use files over a relational database is that the content in an Agentic conversation can be quite large, and may not fit easily into the rows of a database.

Our team has though about creating a hybrid session manager, where the conversation metadata is stored in a database, while the conversation content is stored in files to help mitigate potential latency concerns related to a file-only based session manager.

I was wondering if the approach that we took with the file based session manager addresses the issues you raised in this Feature request, or if you still need some functionality specifically out of a relational database backed session manager?

moved this from Coming Soon to Just Shipped in Strands Agents Roadmapon Jul 30, 2025
removed their assignment
on Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-contextSession or context relatedenhancementNew feature or request

    Projects

    Status

    Just Shipped

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @DennisTraub@zastrowm@yonib05@Unshure@puritatemcordis

        Issue actions

          [FEATURE] Add Database Session Management · Issue #33 · strands-agents/sdk-python