agentmemory

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	ID         string      `json:"id"`
	AgentName  string      `json:"agent_name"`
	Scope      MemoryScope `json:"scope"`
	Kind       MemoryKind  `json:"kind"`
	Key        string      `json:"key"`
	Content    string      `json:"content"`
	Confidence float64     `json:"confidence"` // 0.0-1.0
	UseCount   int         `json:"use_count"`
	Tags       []string    `json:"tags,omitempty"`
	CreatedAt  time.Time   `json:"created_at"`
	UpdatedAt  time.Time   `json:"updated_at"`
}

Entry represents a single agent memory entry.

type InMemoryStore

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

InMemoryStore is a thread-safe in-memory implementation of Store.

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

NewInMemoryStore creates a new in-memory agent memory store.

func (*InMemoryStore) Delete

func (s *InMemoryStore) Delete(agentName, key string) error

func (*InMemoryStore) Get

func (s *InMemoryStore) Get(agentName, key string) (*Entry, error)

func (*InMemoryStore) IncrementUseCount

func (s *InMemoryStore) IncrementUseCount(agentName, key string) error

func (*InMemoryStore) ListAgentNames

func (s *InMemoryStore) ListAgentNames() ([]string, error)

func (*InMemoryStore) ListAll

func (s *InMemoryStore) ListAll(agentName string) ([]*Entry, error)

func (*InMemoryStore) Prune

func (s *InMemoryStore) Prune(agentName string, minConfidence float64) (int, error)

func (*InMemoryStore) Save

func (s *InMemoryStore) Save(entry *Entry) error

func (*InMemoryStore) Search

func (s *InMemoryStore) Search(agentName string, opts SearchOptions) ([]*Entry, error)

func (*InMemoryStore) SearchWithContext

func (s *InMemoryStore) SearchWithContext(agentName string, query string, limit int) ([]*Entry, error)

type MemoryKind

type MemoryKind string

MemoryKind categorizes memory entries.

const (
	KindPattern    MemoryKind = "pattern"    // learned tool usage patterns
	KindPreference MemoryKind = "preference" // user/agent preferences
	KindFact       MemoryKind = "fact"       // discovered facts
	KindSkill      MemoryKind = "skill"      // learned capabilities
)

type MemoryScope

type MemoryScope string

MemoryScope defines the visibility of a memory entry.

const (
	ScopeInstance MemoryScope = "instance" // specific to one agent instance
	ScopeType     MemoryScope = "type"     // shared across agents of same type
	ScopeGlobal   MemoryScope = "global"   // shared across all agents
)

type SearchOptions

type SearchOptions struct {
	Query         string
	Scope         MemoryScope
	Kind          MemoryKind
	Tags          []string
	MinConfidence float64
	Limit         int
}

SearchOptions configures a memory search query.

type Store

type Store interface {
	// Save upserts a memory entry (matched by agent_name + key).
	Save(entry *Entry) error

	// Get retrieves a specific entry by agent name and key.
	Get(agentName, key string) (*Entry, error)

	// Search finds entries matching criteria.
	Search(agentName string, opts SearchOptions) ([]*Entry, error)

	// SearchWithContext resolves entries with scope fallback:
	// instance (agent_name) > type (all agents of same type) > global.
	SearchWithContext(agentName string, query string, limit int) ([]*Entry, error)

	// Delete removes an entry.
	Delete(agentName, key string) error

	// IncrementUseCount bumps the use counter for an entry.
	IncrementUseCount(agentName, key string) error

	// Prune removes entries below a confidence threshold.
	Prune(agentName string, minConfidence float64) (int, error)

	// ListAgentNames returns the names of all agents that have stored memories.
	ListAgentNames() ([]string, error)

	// ListAll returns all entries for a given agent.
	ListAll(agentName string) ([]*Entry, error)
}

Store is the interface for agent memory storage.

Jump to

Keyboard shortcuts

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