/** * Agent Feedback System * * This module provides a feedback mechanism for agents to evaluate each other's work, * enabling continuous improvement and quality control in multi-agent systems. */ import { Agent } from './agent'; /** * Feedback rating scale */ export declare enum FeedbackRating { EXCELLENT = 5, GOOD = 4, ADEQUATE = 3, NEEDS_IMPROVEMENT = 2, POOR = 1 } /** * Feedback categories for structured evaluation */ export declare enum FeedbackCategory { ACCURACY = "accuracy", COMPLETENESS = "completeness", RELEVANCE = "relevance", CLARITY = "clarity", CREATIVITY = "creativity", EFFICIENCY = "efficiency", REASONING = "reasoning" } /** * Feedback item representing an evaluation of a task result */ export interface FeedbackItem { id: string; taskId: string; evaluatorAgentId: string; producerAgentId: string; timestamp: number; ratings: Record; comments: string; suggestions: string; metadata?: Record; } /** * Configuration for the feedback system */ export interface FeedbackSystemConfig { enableAutoFeedback?: boolean; requiredCategories?: FeedbackCategory[]; feedbackFrequency?: number; detailedFeedback?: boolean; feedbackTimeout?: number; } /** * System for agents to provide and receive feedback on task results */ export declare class FeedbackSystem { private feedbackHistory; private config; private logger; private static readonly DEFAULT_CONFIG; /** * Creates a new feedback system * * @param config - Feedback system configuration */ constructor(config?: FeedbackSystemConfig); /** * Request feedback on a task result from an evaluator agent * * @param taskId - ID of the task * @param taskDescription - Description of the task * @param taskResult - Result of the task * @param producerAgent - Agent that produced the result * @param evaluatorAgent - Agent that will evaluate the result * @returns Promise resolving to feedback item */ requestFeedback(taskId: string, taskDescription: string, taskResult: string, producerAgent: Agent, evaluatorAgent: Agent): Promise; /** * Check if we should request feedback for this task * based on configured feedback frequency * * @returns Boolean indicating whether to request feedback */ shouldRequestFeedback(): boolean; /** * Get all feedback for a specific agent * * @param agentId - ID of the agent * @returns Array of feedback items */ getFeedbackForAgent(agentId: string): FeedbackItem[]; /** * Get feedback statistics for an agent * * @param agentId - ID of the agent * @returns Feedback statistics */ getAgentFeedbackStats(agentId: string): { averageRatings: Record; overallAverage: number; totalFeedbackItems: number; recentTrend: 'improving' | 'stable' | 'declining' | 'unknown'; }; /** * Apply feedback to improve an agent's capabilities * * @param agent - Agent to improve * @returns Promise resolving to improvement summary */ applyFeedbackImprovements(agent: Agent): Promise<{ agentId: string; improvementAreas: string[]; suggestedAdjustments: string; }>; /** * Builds a prompt for requesting feedback * * @param taskDescription - Description of the task * @param taskResult - Result of the task * @param producerName - Name of the producer agent * @param producerRole - Role of the producer agent * @returns Feedback request prompt */ private buildFeedbackPrompt; /** * Parses feedback from an agent's response * * @param response - Agent's response to feedback request * @param taskId - ID of the task * @param producerAgentId - ID of the agent that produced the task result * @param evaluatorAgentId - ID of the agent providing feedback * @returns Parsed feedback item */ private parseFeedbackResponse; /** * Calculates the average rating across all categories * * @param ratings - Ratings by category * @returns Average rating */ private calculateAverageRating; /** * Extract improvement areas from reflection response * * @param reflectionResponse - Agent's reflection on feedback * @returns Array of improvement areas */ private extractImprovementAreas; /** * Creates fallback feedback in case of errors * * @param taskId - ID of the task * @param producerAgentId - ID of the agent that produced the task result * @param evaluatorAgentId - ID of the agent providing feedback * @returns Default feedback item with neutral ratings */ private createFallbackFeedback; }