Skip to content

PostgreSQL storage backend #20

@djthorpe

Description

@djthorpe

Summary

Implement a PostgreSQL backend for storage, complementing the existing in-memory and file-based storage options.

Requirements

  • Add a PostgreSQL store that implements the same interface as the existing memory and file stores
  • Connection configured via CLI flag (e.g. --store postgres://...) or environment variable
  • Support all existing store interfaces: Agent, Session, Credential, Server
  • Handle concurrent access safely (multiple server instances sharing the same database)
  • Include database migrations for schema setup (auto-migrate on startup or via a separate command)

Schema Considerations

  • sessions table: id, name, provider, model, system_prompt, labels (JSONB), created_at, modified_at
  • messages table: id, session_id (FK), role, content (JSONB for multi-part content blocks), tool_calls (JSONB), created_at
  • Use JSONB for flexible content storage (text, attachments, tool calls/responses)
  • Index on labels for efficient label-based lookups
  • etc.

Motivation

In-memory storage is lost on restart. File storage works for single instances but doesn't support multiple server replicas or easy backup/querying. PostgreSQL provides durable, queryable, multi-instance-safe storage.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions