Repository navigation
v0.8.0: memory for Symfony AI agents
Long-term memory for Symfony AI agents.
HindsightMemory is a memory provider and an output processor in one: before the model answers, it recalls what the bank knows about the user's latest message; after, it retains the exchange, also for streamed answers, answers after tool calls and answers with reasoning.
use Fedoseev\Hindsight\Symfony\Ai\HindsightMemory;
use Symfony\AI\Agent\Agent;
use Symfony\AI\Agent\Memory\MemoryInputProcessor;
$memory = new HindsightMemory($hindsight, fn (): string => 'user-'.$security->getUser()->getUserIdentifier(), logger: $logger);
$agent = new Agent($platform, 'gpt-5-mini', [new MemoryInputProcessor([$memory])], [$memory]);It takes most options of the Laravel middleware as named arguments, so it can be configured as a service. A failed recall or retain is logged and the agent answers without memory, unless throw: true.
Unit tests run with symfony/ai-agent 0.15 and 1.0.0-BETA1; CI also runs a Symfony AI agent that remembers a fact across two conversations against real Hindsight 1.1.0, 1.2.0 and 1.2.1 servers. Details in the README and the changelog.