Files
FusionAGI/fusionagi/memory/reflective.py
defiQUG c052b07662
Some checks failed
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / docker (push) Has been cancelled
Initial commit: add .gitignore and README
2026-02-09 21:51:42 -08:00

32 lines
1.1 KiB
Python

"""Reflective memory: simple store for lessons learned / heuristics (used by Phase 3)."""
from typing import Any
class ReflectiveMemory:
"""Simple store for lessons and heuristics; append-only list or key-value."""
def __init__(self) -> None:
self._lessons: list[dict[str, Any]] = []
self._heuristics: dict[str, Any] = {}
def add_lesson(self, lesson: dict[str, Any]) -> None:
"""Append a lesson (e.g. from Critic)."""
self._lessons.append(lesson)
def get_lessons(self, limit: int = 50) -> list[dict[str, Any]]:
"""Return recent lessons (copy)."""
return [l.copy() for l in self._lessons[-limit:]]
def set_heuristic(self, key: str, value: Any) -> None:
"""Set a heuristic (e.g. strategy hint)."""
self._heuristics[key] = value
def get_heuristic(self, key: str) -> Any:
"""Get heuristic by key."""
return self._heuristics.get(key)
def get_all_heuristics(self) -> dict[str, Any]:
"""Return all heuristics (copy)."""
return dict(self._heuristics)