memory

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package memory — manager.go provides an LLM-powered memory manager inspired by Agno's MemoryManager.

Package memory provides short-term and long-term memory APIs for agents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager uses an LLM to autonomously decide what to remember from conversations.

func NewManager

func NewManager(agentID, userID string, store *Store, provider model.Provider) *Manager

NewManager creates an LLM-powered memory manager.

func (*Manager) ExtractMemories

func (m *Manager) ExtractMemories(ctx context.Context, messages []model.Message) error

ExtractMemories uses the LLM to identify memorable facts from messages and stores them.

func (*Manager) GetUserMemories

func (m *Manager) GetUserMemories(ctx context.Context) (string, error)

GetUserMemories returns all long-term memories, formatted for context injection.

func (*Manager) MemoryTools

func (m *Manager) MemoryTools() []MemoryTool

MemoryTools returns tool definitions that let the model manage memory directly (agentic memory).

func (*Manager) OptimizeMemories

func (m *Manager) OptimizeMemories(ctx context.Context) error

OptimizeMemories asks the LLM to compress/deduplicate existing long-term memories.

type MemoryTool

type MemoryTool struct {
	Name        string
	Description string
	Handler     func(ctx context.Context, args map[string]any) (any, error)
}

MemoryTool is a tool definition for agentic memory management.

type Store

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

Store provides a high-level memory API on top of storage.Storage.

func NewStore

func NewStore(agentID string, backend storage.Storage) *Store

NewStore creates a memory store for the given agent.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (any, error)

Get retrieves a memory value by key.

func (*Store) ListLongTerm

func (s *Store) ListLongTerm(ctx context.Context) ([]*storage.MemoryRecord, error)

ListLongTerm returns all long-term memories for this agent.

func (*Store) ListShortTerm

func (s *Store) ListShortTerm(ctx context.Context) ([]*storage.MemoryRecord, error)

ListShortTerm returns all short-term memories for this agent.

func (*Store) SetLongTerm

func (s *Store) SetLongTerm(ctx context.Context, key string, value any) error

SetLongTerm stores a value in cross-session persistent memory.

func (*Store) SetShortTerm

func (s *Store) SetShortTerm(ctx context.Context, sessionID, key string, value any) error

SetShortTerm stores a value in session-scoped working memory.

Jump to

Keyboard shortcuts

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