inmem

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package inmem provides an in-memory implementation of memory.Store for testing and local development. Data is stored in process memory and is lost when the process exits. Production deployments should use a durable backend such as features/memory/mongo (MongoDB-backed implementation).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service added in v1.2.2

type Service struct {
	// contains filtered or unexported fields
}

Service implements memory.Service with process-local storage.

func NewService added in v1.2.2

func NewService() *Service

NewService returns an empty in-memory long-term memory service.

func (*Service) IngestEvents added in v1.2.2

func (s *Service) IngestEvents(ctx context.Context, input memory.IngestEventsInput) (memory.IngestResult, error)

IngestEvents extracts textual entries from event deltas.

func (*Service) IngestRun added in v1.2.2

func (s *Service) IngestRun(ctx context.Context, input memory.IngestRunInput) (memory.IngestResult, error)

IngestRun extracts textual entries from a run snapshot.

func (*Service) PutEntry added in v1.2.2

func (s *Service) PutEntry(_ context.Context, input memory.PutEntryInput) (memory.Entry, error)

PutEntry stores a direct long-term memory entry.

func (*Service) Search added in v1.2.2

Search returns deterministic keyword matches scoped by namespace, user, and labels.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements memory.Store using an in-process map keyed by agent ID and run ID. It is thread-safe and suitable for tests and local development. Data is not persisted across restarts.

The store maintains a two-level map: agentID -> runID -> events, allowing efficient isolation between agents and runs. All operations defensively copy data to prevent external mutation.

func New

func New() *Store

New returns a new in-memory store instance with no events. The store is ready to use immediately and requires no initialization or cleanup.

func (*Store) AppendEvents

func (s *Store) AppendEvents(_ context.Context, agentID, runID string, events ...memory.Event) error

AppendEvents appends the provided events to the run history. Events are copied defensively to ensure callers cannot mutate the internal store. If events is empty, this is a no-op.

Thread-safe: concurrent writes acquire an exclusive lock and serialize. Writes to different runs do not block each other but are still serialized within this implementation.

func (*Store) LoadRun

func (s *Store) LoadRun(_ context.Context, agentID, runID string) (memory.Snapshot, error)

LoadRun retrieves the snapshot for the given agent and run. Returns an empty snapshot (not an error) if the run doesn't exist, allowing callers to treat absence as empty history. The returned snapshot contains a defensive copy of events to prevent external mutation.

Thread-safe: concurrent reads are allowed and do not block each other.

func (*Store) Query added in v1.2.2

func (s *Store) Query(_ context.Context, query memory.Query) (memory.QueryResult, error)

Query searches appended events by agent, run, event type, labels, and limit.

func (*Store) Reset

func (s *Store) Reset()

Reset clears all stored events across all agents and runs. Primarily useful in tests to reset state between test cases. Not typically needed in production since inmem stores are ephemeral.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL