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 ¶
- type SessionStore
- func (s *SessionStore) Exists(_ context.Context, id string) (bool, error)
- func (s *SessionStore) Final(id string) (agentloop.FinalizeSummary, bool)
- func (s *SessionStore) Finalize(_ context.Context, id string, summary agentloop.FinalizeSummary) error
- func (s *SessionStore) Get(_ context.Context, id string) (agentloop.Session, error)
- func (s *SessionStore) Put(sess agentloop.Session)
- func (s *SessionStore) Snapshot(id string) json.RawMessage
- func (s *SessionStore) UpdateData(_ context.Context, id string, snap json.RawMessage) error
- type StepStore
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 ¶
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 ¶
func (s *SessionStore) Final(id string) (agentloop.FinalizeSummary, bool)
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 ¶
All returns every step recorded for sessionID in insertion order. Useful for tests asserting on the full trace.