Documentation
¶
Overview ¶
Package memory manages the engine's local working copy of an agent's declared memory files. A configured store holds the durable copy; this manager pulls a snapshot at boot, exposes read/append/edit operations to LLM agent nodes, and pushes every successful write back through the store synchronously. Sync-on-write keeps the durable copy ahead of in-memory state in case the engine process is killed without graceful shutdown.
Index ¶
- Variables
- func IndexCard(refs []workflow.MemoryRef, mgr *Manager) (string, error)
- func Tools(refs []workflow.MemoryRef, mgr *Manager) ([]llmproxy.Tool, error)
- func ValidateRefs(refs []workflow.MemoryRef, mgr *Manager) error
- type Card
- type Manager
- func (m *Manager) Append(ctx context.Context, uid, content string) error
- func (m *Manager) Card(uid string) (Card, error)
- func (m *Manager) Edit(ctx context.Context, uid, oldStr, newStr string) error
- func (m *Manager) Read(uid string) (string, error)
- func (m *Manager) Restore(ctx context.Context) error
- func (m *Manager) UIDs() []string
Constants ¶
This section is empty.
Variables ¶
var ErrEditNoMatch = errors.New("memory edit: old_string not found in file")
ErrEditNoMatch is returned by Edit when the supplied old_string isn't present in the file. The LLM is expected to recover by re-reading.
var ErrFileNotFound = errors.New("memory file not found")
ErrFileNotFound is returned when the LLM references a memory file that isn't declared for this agent.
var ErrSizeExceeded = errors.New("memory write would exceed max size")
ErrSizeExceeded is returned when an append/edit would push the file past its declared maxSizeBytes cap.
Functions ¶
func IndexCard ¶
IndexCard renders the auto-injected memory index block prepended to the LLM agent's system prompt. One line per file with name, mode, size, and description so the LLM can decide what to fetch.
func Tools ¶
Tools synthesizes the LLM-callable tools (read_memory, append_memory, edit_memory) for the given memory refs. Each tool's `file` parameter is constrained by enum to the human names of files this agent is allowed to touch (read-only refs excluded from write enums). Internally, each tool resolves the chosen name to its uid before calling the manager.
Returns nil when refs is empty.
Types ¶
type Card ¶
Card is the metadata used to render an entry in the auto-injected memory index in the LLM agent's system prompt. Size is in bytes; the LLM treats it as a hint, not a hard contract.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the engine-side memory subsystem. One instance per engine process. Files are keyed internally by uid (stable across renames); the LLM-facing tool layer resolves human names to uids via Card.
func NewManager ¶
func NewManager(dir string, store engine.MemoryStore) *Manager
NewManager constructs a manager that writes its working copy into dir and syncs through the given store. The directory is created lazily on Restore.
func (*Manager) Append ¶
Append concatenates content to the file identified by uid, persists locally, and pushes the new full content through the store. Returns ErrSizeExceeded if the result would exceed the declared cap.
func (*Manager) Card ¶
Card returns the metadata for the file identified by uid. Tool builders use this to translate refs into LLM-facing enums and index cards.
func (*Manager) Edit ¶
Edit performs a single find/replace against the file identified by uid. Returns ErrEditNoMatch if oldStr isn't present. First match only, matching Claude Code's Edit semantics.