Schema Definition
Themessages table stores individual messages within conversations. Messages are created and managed by the AI agent system.
Fields
Unique message identifier
ID of the conversation this message belongs to
ID of the project (denormalized for efficient querying)
Message sender role
Message content (text)
Processing status for assistant messages
Indexes
Index on
conversationId for retrieving all messages in a conversationFields: ["conversationId"]Composite index for finding messages by project and status (used for monitoring processing messages)Fields:
["projectId", "status"]User-Facing Queries
Messages are typically retrieved through theconversations.getMessages query rather than directly. See Conversations Schema for details.
Internal System Operations
createMessage (Internal)
Create a new message in a conversation.Internal authentication key
Conversation identifier
Project identifier
Message sender role
Message content
Initial status (typically
"processing" for assistant messages)Id<'messages'> - ID of the newly created message
Side effects: Updates conversation’s updatedAt timestamp
updateMessageContent (Internal)
Update message content and mark as completed.Internal authentication key
Message identifier
New message content
"completed"
updateMessageStatus (Internal)
Update message processing status.Internal authentication key
Message identifier
New status
getProcessingMessages (Internal)
Retrieve all messages currently being processed in a project.Internal authentication key
Project identifier
status: "processing"
Use case: Monitoring active AI operations, cleanup, and recovery
getRecentMessages (Internal)
Retrieve recent messages from a conversation for AI context.Internal authentication key
Conversation identifier
Maximum number of messages to return (default: 10)
limit most recent messages in chronological order
Use case: Providing conversation context to AI agent
Message Lifecycle
Assistant message created
System creates assistant message with
status: "processing" and empty contentRelated Tables
Conversations
Messages belong to conversations. Use
conversations.getMessages to retrieve messages.Source Reference
- Schema definition:
convex/schema.ts:52-66 - Internal operations:
convex/system.ts:29-139