Conversation History
Luna stores all conversations in the Patient Graph for cross-channel continuity, compliance, and analysis.
How It Works
Every message exchanged between a user and Luna is stored in the patient_graph.conversation_history table:
{
customerId: 'prof_abc123',
channel: 'luna',
role: 'user', // or 'assistant', 'system'
content: 'What are my latest lab results?',
sessionId: 'sess_abc123',
toolCalls: null, // Present when Luna calls tools
toolResults: null, // Present with tool call results
metadata: {},
}Channels
| Channel | Description |
|---|---|
luna | Luna AI chat interface |
support | Customer support conversations |
voice | Voice call transcriptions (Vapi) |
Cross-Channel Context
When Luna starts a new conversation, it can access the user’s history across all channels to maintain continuity:
const history = await repos.conversationHistory.list({
customerId: userId,
limit: 50,
});This allows Luna to:
- Reference previous conversations without the user repeating themselves
- Track longitudinal health progress across sessions
- Maintain awareness of recent support interactions
Session Management
Each conversation has a unique sessionId. Messages within the same session represent a single conversation thread. Sessions are useful for:
- Grouping related messages
- Replaying conversations for review
- Compliance auditing of specific interactions
Tool Call Storage
When Luna calls tools during a conversation, both the tool calls and their results are stored:
{
"role": "assistant",
"content": "Let me check your latest lab results...",
"toolCalls": [
{
"id": "call_abc",
"name": "getLabResults",
"arguments": { "userId": "user_123", "limit": 5 }
}
],
"toolResults": [
{
"id": "call_abc",
"result": { "labs": [...] }
}
]
}Querying History
Via API
# Get recent Luna conversations
curl "https://patient-graph.loop.health/conversation-history?customerId=prof_abc123&channel=luna&limit=50" \
-H "Authorization: Bearer $CLERK_JWT"
# Get a specific session
curl "https://patient-graph.loop.health/conversation-history?customerId=prof_abc123&sessionId=sess_abc" \
-H "Authorization: Bearer $CLERK_JWT"Via Repository
const history = await repos.conversationHistory.list({
customerId: 'prof_abc123',
channel: 'luna',
fromDate: '2024-06-01',
limit: 100,
});Retention
Conversation history follows the same retention policy as other Patient Graph data:
- Active retention: 7 years (HIPAA requirement for clinical records)
- Compliance flag: Escalated conversations are flagged for extended retention