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:

python
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")
Note

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

MethodPurpose
create_session(initial_title)Start a new session (returns a UUID)
get_all_sessionsList 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):

MethodPathAction
GET/api/chatsList sessions (recent first)
GET/api/chats/{session_id}Open a session
DELETE/api/chats/{session_id}Delete a session
bash
curl http://127.0.0.1:8000/api/chats
curl http://127.0.0.1:8000/api/chats/3f9a-... # one conversation

History vs. memory

They're complementary:

Chat history

The verbatim transcript of each conversation, grouped into sessions you can browse and delete. Stored as JSON in data/chats/.

Memory

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.