CODEX_ADK/BACKEND/Codex.Dal/Entities/ConversationMessage.cs
Svrnty 229a0698a3 Initial commit: CODEX_ADK monorepo
Multi-agent AI laboratory with ASP.NET Core 8.0 backend and Flutter frontend.
Implements CQRS architecture, OpenAPI contract-first API design.

BACKEND: Agent management, conversations, executions with PostgreSQL + Ollama
FRONTEND: Cross-platform UI with strict typing and Result-based error handling

Co-Authored-By: Jean-Philippe Brule <jp@svrnty.io>
2025-10-26 23:12:32 -04:00

79 lines
2.3 KiB
C#

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