Skip to content

feat: Redis-backed session store for chat history #6

Description

@alexandervazquez98

Context

The current chat endpoint in �ackend/routers/chat.py uses an in-memory Python dict (_SESSION_STORE) with a 60-minute TTL. This means:

  • Chat history is lost on every process restart
  • History is not shared across multiple backend instances

Proposed Solution

Replace _SESSION_STORE with Redis-backed sessions using the existing
edis_client.py:

  1. Store each session as a Redis key: chat:session:{session_id}
  2. Use Redis TTL (60 min) instead of manual cleanup task
  3. Serialize messages as JSON in Redis values
  4. Remove the cleanup_expired_sessions() coroutine and lifespan task

Acceptance Criteria

  • Chat sessions survive backend process restart
  • Sessions auto-expire after 60 minutes via Redis TTL
  • Graceful fallback if Redis is unavailable
  • All existing chat tests updated and passing
  • No changes to the HTTP API contract

Notes

Redis is already available in the stack (
edis_client.py handles the connection). P2 item carried over from �ugfix-code-review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions