lcm

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSummaryXML

func FormatSummaryXML(sum sqlc.CtxSummary, parents []sqlc.CtxSummary) string

FormatSummaryXML formats a summary as XML for model consumption.

Types

type Option added in v0.50.3

type Option func(*Provider)

Option configures optional Provider behavior at construction.

func WithQueryEmbedder added in v0.50.3

func WithQueryEmbedder(emb QueryEmbedder) Option

WithQueryEmbedder enables the semantic search lane: search() embeds the query with emb and fuses vector KNN hits with the BM25 lexical results. Without it (the default) search stays pure lexical. A nil emb is ignored so callers can pass an unconditionally-built option.

type Provider

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

Provider implements memory.Provider and all six capability interfaces using the lossless context management algorithm.

func New

func New(db *pgxpool.Pool, summarizerFn func(ctx context.Context, prompt string) (string, error), cfg map[string]any, opts ...Option) (*Provider, error)

New creates a new LCM provider. summarizerFn provides LLM access for compaction; if nil, compaction is disabled. cfg is the plugin-specific configuration from the plugin.config JSON.

func (*Provider) AddConstraint

func (p *Provider) AddConstraint(ctx context.Context, userID string, agentID string, text string) ([]memory.ConstraintEntry, error)

AddConstraint implements memory.ConstraintStore.

func (*Provider) AdvanceSessionSnapshot

func (p *Provider) AdvanceSessionSnapshot(ctx context.Context, sessionID string, userID string, agentID string) error

AdvanceSessionSnapshot implements memory.SessionSnapshotStore.

func (*Provider) Append

func (p *Provider) Append(ctx context.Context, session memory.Session, msgs ...ai.Message) error

Append implements memory.Provider.

func (*Provider) ApplyFactBatch added in v0.60.0

func (p *Provider) ApplyFactBatch(ctx context.Context, userID string, agentID string, ops []memorywrite.FactBatchOperation) ([]memory.Fact, error)

ApplyFactBatch applies multiple fact mutations in one transaction. Reflect uses this capability after reconciliation so fact-line writes can fail closed without partially updating profile, soul, or world knowledge.

func (*Provider) Assemble

func (p *Provider) Assemble(ctx context.Context, session memory.Session, budget, freshTail int) ([]ai.Message, error)

Assemble implements memory.Provider.

func (*Provider) Bootstrap

func (p *Provider) Bootstrap(ctx context.Context, session memory.Session) error

Bootstrap implements memory.Provider.

func (*Provider) BuildReviewContext

func (p *Provider) BuildReviewContext(ctx context.Context, session memory.Session, since time.Time) (string, error)

BuildReviewContext implements memory.Reviewer.

func (*Provider) Close

func (p *Provider) Close() error

Close implements memory.Provider.

func (*Provider) CommitGroupCursor added in v0.43.0

func (p *Provider) CommitGroupCursor(ctx context.Context, session memory.Session, triggerSeq int64) error

func (*Provider) Compact

Compact implements memory.Compactor.

func (*Provider) Describe

func (p *Provider) Describe(ctx context.Context, summaryID string) (*memory.DescribeResult, error)

Describe implements memory.Explorer.

func (*Provider) Expand

func (p *Provider) Expand(ctx context.Context, summaryID string, tokenCap int) (*memory.ExpandResult, error)

Expand implements memory.Explorer.

func (*Provider) GetAgentSoul

func (p *Provider) GetAgentSoul(ctx context.Context, userID string, agentID string) (string, error)

func (*Provider) GetAgentSoulAt

func (p *Provider) GetAgentSoulAt(ctx context.Context, userID string, agentID string, version int64) (string, error)

GetAgentSoulAt implements memory.VersionedProfileStore.

func (*Provider) GetConstraints

func (p *Provider) GetConstraints(ctx context.Context, userID string, agentID string) ([]memory.ConstraintEntry, error)

GetConstraints implements memory.ConstraintStore.

func (*Provider) GetConstraintsAt

func (p *Provider) GetConstraintsAt(ctx context.Context, userID string, agentID string, version int64) ([]memory.ConstraintEntry, error)

GetConstraintsAt implements memory.VersionedConstraintStore.

func (*Provider) GetGroupMemory added in v0.42.0

func (p *Provider) GetGroupMemory(ctx context.Context, groupID string) (string, error)

GetGroupMemory implements memory.GroupMemoryStore.

func (*Provider) GetMessage added in v0.49.0

func (p *Provider) GetMessage(ctx context.Context, messageID string) (*memory.MessageDetail, error)

GetMessage implements memory.MessageReader.

func (*Provider) GetOrCreateSessionSnapshot

func (p *Provider) GetOrCreateSessionSnapshot(ctx context.Context, sessionID string, userID string, agentID string) (memory.SessionSnapshot, error)

GetOrCreateSessionSnapshot implements memory.SessionSnapshotStore.

func (*Provider) GetProfile

func (p *Provider) GetProfile(ctx context.Context, userID string, agentID string) (string, error)

func (*Provider) GetProfileAt

func (p *Provider) GetProfileAt(ctx context.Context, userID string, agentID string, version int64) (string, error)

GetProfileAt implements memory.VersionedProfileStore.

func (*Provider) GetProfileEntries added in v0.42.0

func (p *Provider) GetProfileEntries(ctx context.Context, userID string, agentID string) ([]memory.ProfileEntry, error)

GetProfileEntries implements memory.ProfileEntryStore.

func (*Provider) ListActiveFacts added in v0.60.0

func (p *Provider) ListActiveFacts(ctx context.Context, userID string, agentID string, subject memory.FactSubject) ([]memory.Fact, error)

ListActiveFacts implements memory.FactStore.

func (*Provider) ListActiveFactsAt added in v0.60.0

func (p *Provider) ListActiveFactsAt(ctx context.Context, userID string, agentID string, subject memory.FactSubject, version int64) ([]memory.Fact, error)

ListActiveFactsAt implements memory.VersionedFactStore. The snapshot clock is ctx_agent_memory.version; fact.version remains local to each fact row.

func (*Provider) ListInfo

func (p *Provider) ListInfo(ctx context.Context, opts memory.ListOptions) ([]memory.SessionInfo, error)

ListInfo implements memory.SessionManager.

func (*Provider) ListInfoForReview added in v0.40.0

func (p *Provider) ListInfoForReview(ctx context.Context, opts memory.ListOptions) ([]memory.SessionInfo, error)

ListInfoForReview lists review candidates across users for one agent.

func (*Provider) LoadHistory

func (p *Provider) LoadHistory(ctx context.Context, sessionID string) ([]ai.Message, error)

LoadHistory implements memory.SessionManager.

func (*Provider) LoadInfo

func (p *Provider) LoadInfo(ctx context.Context, sessionID string) (memory.SessionInfo, error)

LoadInfo implements memory.SessionManager.

func (*Provider) LoadReviewHistory added in v0.60.0

func (p *Provider) LoadReviewHistory(ctx context.Context, sessionID string) ([]memory.ReviewMessage, error)

LoadReviewHistory implements memory.ReviewHistoryReader.

func (*Provider) Name

func (p *Provider) Name() string

Name implements memory.Provider.

func (*Provider) NeedsCompaction

func (p *Provider) NeedsCompaction(ctx context.Context, session memory.Session, threshold float64) bool

NeedsCompaction implements memory.Compactor.

func (*Provider) ReadChangelog

func (p *Provider) ReadChangelog(ctx context.Context, userID string, agentID string, scope string, limit int) ([]memory.ChangeEntry, error)

ReadChangelog implements memory.ChangelogReader.

func (*Provider) ReadChangelogPage added in v0.60.0

func (p *Provider) ReadChangelogPage(ctx context.Context, userID string, agentID string, scope string, cursor *memory.ChangelogCursor, limit int) ([]memory.ChangeEntry, error)

ReadChangelogPage implements memory.ChangelogPageReader without changing the recent-only ChangelogReader contract used by memory tools.

func (*Provider) RemoveConstraint

func (p *Provider) RemoveConstraint(ctx context.Context, userID string, agentID string, id string) ([]memory.ConstraintEntry, error)

RemoveConstraint implements memory.ConstraintStore.

func (*Provider) SaveInfo

func (p *Provider) SaveInfo(ctx context.Context, info memory.SessionInfo) error

SaveInfo implements memory.SessionManager.

func (*Provider) Search

func (p *Provider) Search(ctx context.Context, session memory.Session, query memory.SearchQuery) ([]memory.SearchResult, error)

Search implements memory.Searcher.

func (*Provider) SetAgentSoul

func (p *Provider) SetAgentSoul(ctx context.Context, userID string, agentID string, content string) error

func (*Provider) SetProfile

func (p *Provider) SetProfile(ctx context.Context, userID string, agentID string, content string) error

func (*Provider) Stats

func (p *Provider) Stats(ctx context.Context, session memory.Session) (memory.SessionStats, error)

Stats implements memory.Provider.

func (*Provider) TouchKnowledgeUsage added in v0.60.0

func (p *Provider) TouchKnowledgeUsage(ctx context.Context, userID string, agentID string, factIDs []string) error

TouchKnowledgeUsage records runtime use for Reflect-owned world facts. The SQL query rechecks ownership and status so callers cannot create usage rows for manual, deprecated, or non-world facts.

func (*Provider) WriteChangelog

func (p *Provider) WriteChangelog(ctx context.Context, entry memory.ChangeEntry) error

WriteChangelog implements memory.ChangelogWriter.

type QueryEmbedder added in v0.50.3

type QueryEmbedder interface {
	EmbedQuery(ctx context.Context, text string) (pgvector.Vector, string, error)
}

QueryEmbedder turns a search query into a vector plus the vector space it belongs to, so the retrieval engine can run KNN against the matching index. It is optional: when nil, search is pure BM25 (embedding.Service satisfies it).

Jump to

Keyboard shortcuts

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