Enables agent self-analysis and improvement by using LLM to evaluate conversation quality, identify issues, and suggest improvements. This is a key feature for continuous agent optimization.
BOT REFLECTION activates the agent self-improvement system, which periodically analyzes conversations and provides actionable insights. When enabled, the system:
' Enable reflection for this bot session
BOT REFLECTION true
' Normal conversation proceeds
TALK "Hello! How can I help you today?"
HEAR userquery
response = LLM userquery
TALK response
' Reflection runs automatically in background
' Enable reflection on conversation quality
BOT REFLECTION ON "conversation_quality"
' Enable reflection on response accuracy
BOT REFLECTION ON "response_accuracy"
' Enable reflection on user satisfaction
BOT REFLECTION ON "user_satisfaction"
' Get insights from reflection analysis
insights = BOT REFLECTION INSIGHTS()
IF insights <> "" THEN
PRINT "Reflection Insights:"
PRINT insights.summary
PRINT "Quality Score: " + insights.qualityScore
PRINT "Issues Found: " + insights.issuesCount
FOR EACH suggestion IN insights.suggestions
PRINT "Suggestion: " + suggestion
NEXT suggestion
END IF
' Only reflect on complex conversations
messageCount = GET BOT MEMORY("messageCount")
IF messageCount > 5 THEN
' Enable reflection for longer conversations
BOT REFLECTION true
BOT REFLECTION ON "conversation_quality"
END IF
insights = BOT REFLECTION INSIGHTS()
' Available properties:
insights.qualityScore ' Overall quality (0-1)
insights.summary ' Text summary of analysis
insights.issues ' Array of identified issues
insights.issuesCount ' Number of issues found
insights.suggestions ' Array of improvement suggestions
insights.metrics ' Object with detailed metrics
insights.criticalIssues ' Count of critical problems
insights.conversationId ' ID of analyzed conversation
insights.timestamp ' When analysis was performed