aimemory

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aimemory contains the ai-memory config node: a shared conversation-memory definition referenced by ai-agent nodes. History is kept in the host's context store (nodebase.ContextStore — persistent when the host wires a durable backend), keyed by a conversation id resolved from a message property. Retention and a context-window cap bound what is loaded; consolidation/long-term memory is explicitly deferred.

Index

Constants

View Source
const Type = "ai-memory"

Type is the registered node type id for the memory config entity.

Variables

This section is empty.

Functions

func ScopeID

func ScopeID(nodeID string) string

ScopeID is the context-store scope the config node's memories live under (global scope — shared by every runner of the same store).

Types

type Config

type Config struct {
	// KeyProperty is the message property holding the conversation
	// id: "msg.x" reads metadata, "payload"/"payload.x" reads the
	// payload. Empty or unresolved falls back to "default".
	KeyProperty string `json:"keyProperty"`
	// MaxMessages caps the stored turns loaded into the prompt
	// (oldest dropped first); <= 0 uses the default of 40.
	MaxMessages int `json:"maxMessages"`
	// RetentionSeconds forgets turns older than the bound;
	// <= 0 means no time-based eviction.
	RetentionSeconds float64 `json:"retentionSeconds"`
}

Config holds the ai-memory configuration.

func ConfigForNode

func ConfigForNode(node nodestore.NodeInterface) (*Config, error)

ConfigForNode decodes the ai-memory config off a stored node definition — the path ai-agent takes after LookupNode.

func (*Config) ConversationKey

func (c *Config) ConversationKey(input nodestore.MessageInterface) string

ConversationKey resolves the conversation id for a message: the configured property ("msg.x" metadata or a payload path), falling back to "default" when unset or unresolvable.

type MemoryNode

type MemoryNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

MemoryNode is a config entity; its Execute is never invoked (no ports), existing only to satisfy the NodeExecutor contract.

func NewMemoryNode

func NewMemoryNode(node nodestore.NodeInterface, config *Config) *MemoryNode

NewMemoryNode creates a new ai-memory node.

func (*MemoryNode) Execute

Execute passes the payload through — unreachable in practice since an ai-memory node has no inputs.

func (*MemoryNode) Validate

func (n *MemoryNode) Validate() error

Validate checks the structural config — every field is optional.

type Store

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

Store is the per-conversation history bound to a context store — ai-agent loads it before the first model call and appends the turns the loop produced.

func OpenStore

func OpenStore(store nodebase.ContextStore, memoryNodeID string, cfg *Config, key string) *Store

OpenStore binds the conversation identified by key on the host's resolved context store. store may be nil — the caller treats memory as disabled then (host without a context seam).

func (*Store) Append

func (s *Store) Append(messages ...llm.Message) error

Append records new turns and persists the history, applying retention and the window cap before writing.

func (*Store) Load

func (s *Store) Load() ([]llm.Message, error)

Load returns the stored turns within the retention bound and the context-window cap, oldest first — ready for LlmOptions.Messages.

Jump to

Keyboard shortcuts

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