Chat History & Sessions
How conversations are grouped into sessions and persisted to disk.
Conversations in MeghaOS are organized into sessions that persist across restarts, so you can revisit or delete past chats. This is handled by MeghaOS β distinct from the semantic Memory system, which extracts long-term facts from conversations.
Sessions on disk
Each session is a JSON file under data/chats/, named by a sanitized session id:
def _get_filename(self, session_id):
safe_id = "".join(c for c in session_id if c.isalnum or c in ("-", "_"))
return os.path.join(self.data_dir, f"{safe_id}.json")The id is sanitized to alphanumerics, -, and _ before being used as a filename β a guard
against path-traversal. Session ids are UUIDs.
A session payload holds its session_id, a title, timestamps, and the full list of
messages.
What the manager does
| Method | Purpose |
|---|---|
create_session(initial_title) | Start a new session (returns a UUID) |
get_all_sessions | List session metadata, sorted by most-recent |
get_session(session_id) | Full payload incl. all messages |
save_session(session_id, data) | Persist a session |
get_all_sessions returns lightweight metadata (id, title, timestamps) for the chat list,
while get_session returns the complete message history for one conversation.
The API
The shell drives history through these endpoints (see Chat API):
| Method | Path | Action |
|---|---|---|
GET | /api/chats | List sessions (recent first) |
GET | /api/chats/{session_id} | Open a session |
DELETE | /api/chats/{session_id} | Delete a session |
curl http://127.0.0.1:8000/api/chats
curl http://127.0.0.1:8000/api/chats/3f9a-... # one conversationHistory vs. memory
They're complementary:
The verbatim transcript of each conversation, grouped into sessions you can browse
and delete. Stored as JSON in data/chats/.
Distilled facts extracted from conversations and stored as vectors in a vector database, then injected into future prompts for personalization.
Deleting a chat session removes its transcript; facts already extracted into long-term memory persist separately.