---
name: Matrix Bot Conversation Context and Multi-Room
---

# Matrix Bot Conversation Context and Multi-Room

## User Story

As a developer, I want the Matrix bot to remember recent conversation history and work across multiple rooms so that conversations feel natural and different projects or teams can have their own rooms.

## Background

The Matrix bot story (currently 174, will be renumbered) delivers a basic Matrix bot that responds to individual messages with no memory. This story adds:
- Per-room conversation context so the bot remembers what you were just talking about
- Multi-room support so a single Story Kit instance can serve multiple rooms (e.g., a project room and a 1:1 DM)

## Acceptance Criteria

- [ ] Bot maintains a rolling conversation history per room (last N messages, configurable)
- [ ] Conversation context is included when calling the LLM so it can reference earlier messages
- [ ] Bot handles multiple rooms independently (configured in `bot.toml` as a list of room IDs)
- [ ] Each room has its own independent conversation history
- [ ] History is in-memory only — restarting the server resets context (persistence is a future concern)
- [ ] Bot correctly attributes messages to different Matrix users in the conversation history

## Out of Scope
- Persistent conversation history across restarts
- Per-room configuration (different LLM models, different tool access)
- Thread-based conversations (Matrix threads)
- User-specific context or preferences

## Technical Notes
- Store conversation history as a `HashMap<RoomId, Vec<Message>>` with a configurable max length
- Trim oldest messages when the history exceeds the limit
- Include Matrix display names in the message context so the LLM knows who said what
- Depends on the Matrix bot story (currently 174, will be renumbered after merge)
