Repository navigation
v0.2.0: queued retains and Hindsight::fake()
Agent memory that waits out an outage of the Hindsight API, and memory you can test without a server.
// Store each exchange from a queue worker, with retries that never store it twice.
Memory::bank("user-{$this->user->id}")->queue();
// In tests
Hindsight::fake(['user-1' => ['Alice is on the Pro plan']]);
Hindsight::assertRetained('user-1', fn (string $content) => str_contains($content, 'renews'));Tested in CI on PHP 8.2–8.5, Laravel 12 and 13, Laravel AI SDK 1.0 and 1.3, and real Hindsight 1.1.0 and 1.2.0 servers.
Added
Hindsight::fake()andFedoseev\Hindsight\Testing\HindsightFake: an in-memory server for tests, withassertRetained(),assertNotRetained(),assertNothingRetained(),assertRecalled(),assertNotRecalled()andassertReflected(). It follows the server where tests depend on it: a bank nobody wrote to answers 404, tag filters select the same memories, a retain with a document ID replaces the document, an async retain repeated with the same operation ID stores nothing new, and invalid operation IDs, timestamps, tags, metadata values and update modes are rejected with the server's status.unavailable()simulates an outage,respondTo()stubs other endpoints.RetainMemoryjob andMemory::queue(): store memories from a queue worker, retried with backoff while the Hindsight API is unavailable (six attempts over about 36 minutes by default; earlier attempts log a warning, only a failure on the last attempt is reported). Every attempt sends the operation ID the job got when it was dispatched, so a retry never stores a memory twice, and the dispatch time as the memory's timestamp. Errors a retry cannot fix fail the job at once and are reported.queuesection inconfig/hindsight.php: connection, queue, tries, backoff and payload encryption.- Bank aliases:
listBankAliases(),addBankAlias(),setPrimaryBankAlias()andremoveBankAlias(), on the client and the facade. retryOperation()to queue a failed or cancelled operation again.- CI also runs the integration suite against Hindsight 1.2.0, and compares the fake with real 1.1.0 and 1.2.0 servers.
Changed
Hindsightis no longerfinal, soHindsightFakecan stand in for it. Other subclasses are not supported.