using Codex.Dal.Enums;
namespace Codex.Dal.Entities;
///
/// Represents a single message in a conversation.
/// Messages are stored permanently for audit trail, with IsInActiveWindow for efficient memory management.
///
public class ConversationMessage
{
///
/// Unique identifier for the message
///
public Guid Id { get; set; }
///
/// Foreign key to the conversation
///
public Guid ConversationId { get; set; }
///
/// Role of the message sender
///
public MessageRole Role { get; set; }
///
/// Content of the message
///
public string Content { get; set; } = string.Empty;
///
/// Tool calls made in this message (stored as JSON array if applicable)
///
public string? ToolCalls { get; set; }
///
/// Tool results from this message (stored as JSON array if applicable)
///
public string? ToolResults { get; set; }
///
/// Order of the message in the conversation (0-indexed)
///
public int MessageIndex { get; set; }
///
/// Whether this message is within the active conversation window for LLM context.
/// System messages are always in the active window.
/// For user/assistant/tool messages, only the last N are in the window (N = Agent.ConversationWindowSize).
///
public bool IsInActiveWindow { get; set; } = true;
///
/// Estimated token count for this message
///
public int? TokenCount { get; set; }
///
/// Foreign key to the execution that generated this message (nullable for user messages)
///
public Guid? ExecutionId { get; set; }
///
/// When this message was created
///
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
// Navigation properties
///
/// The conversation this message belongs to
///
public Conversation Conversation { get; set; } = null!;
///
/// The execution that generated this message (if applicable)
///
public AgentExecution? Execution { get; set; }
}