agentloopmem

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package agentloopmem provides in-memory implementations of agentloop.StepStore and agentloop.SessionStore.

Use cases:

  • Local dev / smoke tests where standing up a database is overkill.
  • Eval suites that need deterministic, ephemeral session state.
  • Stub stores while an application's real schema is still being designed, so loop wiring can land before the migrations do.

The stores are concurrency-safe (each method takes a mutex) and reset on process exit. They MUST NOT be used as the system of record for real traffic — there's no durability, no cross-process visibility, and no audit trail.

For production, implement agentloop.StepStore + agentloop.SessionStore against your own schema — see agentlooptest.StepStoreContract for a reusable conformance harness to hold that implementation to the same behavioural guarantees the loop relies on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionStore

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

SessionStore is an in-memory agentloop.SessionStore. New constructs it; use Put to seed an initial Session before the first Run.

func NewSessionStore

func NewSessionStore(clock func() time.Time) *SessionStore

NewSessionStore returns an empty in-memory SessionStore. clock is optional; nil falls back to time.Now.

func (*SessionStore) Exists

func (s *SessionStore) Exists(_ context.Context, id string) (bool, error)

Exists reports whether a session has been Put, without creating one — the unambiguous existence check (Get can't tell "fresh" from "found" here).

func (*SessionStore) Final

Final returns the most recent FinalizeSummary for id, or (zero, false) when no Finalize has been called for it.

func (*SessionStore) Finalize

func (s *SessionStore) Finalize(_ context.Context, id string, summary agentloop.FinalizeSummary) error

Finalize records the run-completion summary under id. Later calls for the same id overwrite — a session finalizes once per Run, so the most recent is the right semantics.

func (*SessionStore) Get

Get implements agentloop.SessionStore. Unknown IDs return a zero-value Session (empty ID) with a nil error — the loop treats that as a fresh session. Callers deciding "does this session exist?" must test Exists, never Get's error (which is always nil).

func (*SessionStore) Put

func (s *SessionStore) Put(sess agentloop.Session)

Put seeds a Session by ID. Used to set up a persona / model before the first Run — Get() would otherwise return a zero-value Session.

func (*SessionStore) Snapshot

func (s *SessionStore) Snapshot(id string) json.RawMessage

Snapshot returns the most recent data snapshot persisted for id, or nil when none. Useful for tests asserting on the agent's state without going through Get().

func (*SessionStore) UpdateData

func (s *SessionStore) UpdateData(_ context.Context, id string, snap json.RawMessage) error

UpdateData stores the latest data snapshot under id. Each call replaces the previous snapshot; Snapshot returns the most recent.

type StepStore

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

StepStore is an in-memory agentloop.StepStore. Steps are stored in insertion order per session; LastN returns the trailing window.

func NewStepStore

func NewStepStore() *StepStore

NewStepStore returns an empty in-memory StepStore.

func (*StepStore) All

func (s *StepStore) All(sessionID string) []agentloop.RunStep

All returns every step recorded for sessionID in insertion order. Useful for tests asserting on the full trace.

func (*StepStore) Append

func (s *StepStore) Append(_ context.Context, step agentloop.RunStep) error

Append implements agentloop.StepStore.

func (*StepStore) LastN

func (s *StepStore) LastN(_ context.Context, sessionID string, n int) ([]agentloop.RunStep, error)

LastN implements agentloop.StepStore.

Jump to

Keyboard shortcuts

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