File size: 717 Bytes
0f336cf
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
from database.db import DatabaseManager


class ReflectionEngine:
    """Post-mission self-reflection engine for recording lessons and improving colony performance."""

    @staticmethod
    async def analyze_and_reflect(db: DatabaseManager, mission_id: str, agent_id: str, cost_usd: float, confidence: float) -> str:
        lessons = f"Mission {mission_id} executed with overall confidence {confidence}%. Knowledge cached in SQLite memory."
        mistakes = "None detected" if confidence >= 80.0 else "Low confidence detected in sub-claims; additional verification required in future."
        ref_id = await db.save_reflection(mission_id, agent_id, lessons, mistakes, cost_usd, confidence)
        return ref_id