using Codex.Dal.Enums; namespace Codex.Dal.Entities; /// /// Represents a single execution of an agent, tracking performance, tokens, and tool usage. /// public class AgentExecution { /// /// Unique identifier for this execution /// public Guid Id { get; set; } /// /// Foreign key to the agent that was executed /// public Guid AgentId { get; set; } /// /// Foreign key to the conversation (if part of a conversation). Nullable for standalone executions. /// public Guid? ConversationId { get; set; } /// /// The user's input prompt /// public string UserPrompt { get; set; } = string.Empty; /// /// Additional input context or parameters (stored as JSON if needed) /// public string? Input { get; set; } /// /// The agent's generated output/response /// public string Output { get; set; } = string.Empty; /// /// When the execution started /// public DateTime StartedAt { get; set; } = DateTime.UtcNow; /// /// When the execution completed (null if still running) /// public DateTime? CompletedAt { get; set; } /// /// Total execution time in milliseconds /// public long? ExecutionTimeMs { get; set; } /// /// Number of tokens in the input/prompt /// public int? InputTokens { get; set; } /// /// Number of tokens in the output/response /// public int? OutputTokens { get; set; } /// /// Total tokens used (input + output) /// public int? TotalTokens { get; set; } /// /// Estimated cost in USD (null for Ollama/local models) /// public decimal? EstimatedCost { get; set; } /// /// Tool calls made during execution (stored as JSON array) /// public string? ToolCalls { get; set; } /// /// Results from tool executions (stored as JSON array for debugging) /// public string? ToolCallResults { get; set; } /// /// Current status of the execution /// public ExecutionStatus Status { get; set; } = ExecutionStatus.Running; /// /// Error message if execution failed /// public string? ErrorMessage { get; set; } // Navigation properties /// /// The agent that was executed /// public Agent Agent { get; set; } = null!; /// /// The conversation this execution belongs to (if applicable) /// public Conversation? Conversation { get; set; } /// /// Messages generated during this execution /// public ICollection Messages { get; set; } = new List(); }