This skill provides guidance for working with the Omi backend, including conversation processing, memory extraction, chat system, and LangGraph integration.
When to Use
Use this skill when:
- Working on backend Python code in
backend/ - Implementing new API endpoints
- Processing conversations or extracting memories
- Working with the LangGraph chat system
- Integrating with Firestore, Pinecone, or Redis
Key Patterns
Conversation Processing
The conversation processing pipeline follows this flow:
- Audio arrives via WebSocket (
/v4/listen) - Transcription via Deepgram/Soniox/Speechmatics
- Conversation creation in Firestore (status: "in_progress")
- Processing trigger via
POST /v1/conversationsor timeout - LLM extraction of structured data:
- Title and overview
- Action items
- Calendar events
- Memories (user facts)
- Storage in Firestore and Pinecone
Key Function: utils/conversations/process_conversation.py::process_conversation()
Memory Extraction
Memories are extracted from conversations using LLM:
from utils.llm.conversation_processing import _extract_memories
memories = await _extract_memories(
transcript=transcript,
existing_memories=existing_memories,
)
Categories: personal, health, work, relationships, preferences
Chat System Architecture
The chat system uses LangGraph for routing:
- Classification:
requires_context()determines path - Simple Path: Direct LLM response (no context needed)
- Agentic Path: Full tool access with LangGraph ReAct agent
- Persona Path: Persona app responses
Key File: utils/retrieval/graph.py
Module Hierarchy
CRITICAL: Always follow the import hierarchy:
database/- Data access (lowest)utils/- Business logicrouters/- API endpointsmain.py- Application entry
Never import from higher levels in lower levels!
Database Patterns
- Firestore: Primary database for conversations, memories, users
- Pinecone: Vector embeddings for semantic search
- Redis: Caching (speech profiles, enabled apps, user names)
- GCS: Binary files (audio, photos, speech profiles)
API Endpoint Patterns
- Use FastAPI routers in
routers/ - Keep routers thin - business logic in
utils/ - Use dependency injection for auth
- Return consistent error formats
Common Tasks
Adding a New API Endpoint
- Create router function in appropriate
routers/*.py - Add business logic in
utils/ - Use database functions from
database/ - Follow error handling patterns
- Add to router in
main.py
Processing Conversations
- Use
process_conversation()fromutils/conversations/process_conversation.py - Handle extraction results
- Store in Firestore and Pinecone
- Trigger app webhooks if needed
Adding a Chat Tool
- Create tool function in
utils/retrieval/tools/ - Use
@tooldecorator from LangChain - Add to tool loading in
utils/retrieval/tools/app_tools.py - Tool will be available in agentic chat path
Related Documentation
The docs/ folder is the single source of truth for all user-facing documentation, deployed at docs.omi.me.
- Backend Deep Dive:
docs/doc/developer/backend/backend_deepdive.mdx- View online - Chat System:
docs/doc/developer/backend/chat_system.mdx- View online - Data Storage:
docs/doc/developer/backend/StoringConversations.mdx- View online - Transcription:
docs/doc/developer/backend/transcription.mdx- View online - Backend Setup:
docs/doc/developer/backend/Backend_Setup.mdx- View online - Backend Architecture:
.cursor/rules/backend-architecture.mdc
Related Cursor Resources
Rules
.cursor/rules/backend-architecture.mdc- System architecture and module hierarchy.cursor/rules/backend-api-patterns.mdc- FastAPI router patterns.cursor/rules/backend-database-patterns.mdc- Database storage patterns.cursor/rules/backend-llm-patterns.mdc- LLM integration patterns.cursor/rules/backend-testing.mdc- Testing patterns.cursor/rules/backend-imports.mdc- Import rules.cursor/rules/memory-management.mdc- Memory management
Subagents
.cursor/agents/backend-api-developer/- Uses this skill for API development.cursor/agents/backend-llm-engineer/- Uses this skill for LLM integration.cursor/agents/backend-database-engineer/- Uses this skill for database work
Commands
/backend-setup- Uses this skill for setup guidance/backend-test- Uses this skill for testing patterns/backend-deploy- Uses this skill for deployment patterns