memory

package
v1.99.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package memory provides the memory_manage and memory_capture MCP tools. Recall (reading memory back) is served by the unified search tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoCaptureInput added in v1.95.0

type AutoCaptureInput struct {
	SinkClass  string
	Content    string
	Category   string
	Source     string
	Confidence string
	EntityURNs []string
	Metadata   map[string]any

	// CreatedBy is the owner email the record is scoped to (required). Persona,
	// UserID, and SessionID mirror the tool path's PlatformContext fields.
	CreatedBy string
	Persona   string
	UserID    string
	SessionID string
}

AutoCaptureInput is a server-initiated (non-agent) capture. Unlike the memory_capture tool, there is no incoming request to read identity from, so the caller supplies it explicitly. Source defaults to automation so audits and reads can distinguish platform-minted records from agent- and user- authored ones.

type CaptureResult added in v1.95.0

type CaptureResult struct {
	ID         string
	SinkClass  string
	Status     string
	Superseded []string
}

CaptureResult is the outcome of a server-initiated capture.

type RecallChecker added in v1.87.0

type RecallChecker interface {
	// Matches returns the caller's active records with cosine similarity at or
	// above q.MinScore, best first. When the candidate carries entity URNs,
	// matches must share at least one (knowledge about table A never matches
	// knowledge about table B).
	Matches(ctx context.Context, q RecallQuery) ([]RecallMatch, error)
}

RecallChecker finds the caller's active records a new capture restates, so the write path can supersede instead of appending (recall-first, #633) and surface near-matches for the agent to consolidate (#762). Implemented by the platform over the memory store; declared here so this package does not import pkg/knowledge.

type RecallMatch added in v1.96.0

type RecallMatch struct {
	ID    string  `json:"id"`
	Score float64 `json:"score"`
}

RecallMatch is one existing record similar to a new capture, with its raw cosine score. The capture path splits matches by score: at or above recallSupersedeThreshold the record is superseded; below it the match is returned to the agent as a similar_existing candidate.

type RecallQuery added in v1.87.0

type RecallQuery struct {
	Embedding   []float32
	EntityURNs  []string
	CallerEmail string
	MinScore    float64
}

RecallQuery is the recall-first lookup: the precomputed embedding of the candidate content, the entities it concerns, and the caller's email, plus the cosine threshold above which a prior record counts as similar. Embedding is empty when no embedder is configured; in that case recall is skipped (no reliable similarity, so the capture simply appends).

type ThreadLinker added in v1.87.0

type ThreadLinker interface {
	LinkInsight(ctx context.Context, threadIDs []string, insightID, actorID, actorEmail string) ([]string, error)
}

ThreadLinker bridges a reviewed capture back to the feedback thread(s) it resolves (#602). Satisfied by the portal thread store; a minimal interface so the memory toolkit does not depend on the portal package.

type Toolkit

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

Toolkit implements the memory management toolkit. Recall is handled by the unified search tool (#632); this toolkit owns only the memory_manage write path.

func New

func New(name string, store memstore.Store, embedder embedding.Provider) (*Toolkit, error)

New creates a new memory toolkit.

func (*Toolkit) AutoCapture added in v1.95.0

func (t *Toolkit) AutoCapture(ctx context.Context, in AutoCaptureInput) (*CaptureResult, error)

AutoCapture persists a server-initiated capture, reusing the full memory_capture pipeline: sink-class routing (live vs reviewed), embedding, recall-first supersede, and the pending-insight overlay for reviewed classes. It is the single entry point for platform-minted memory (e.g. reflexive capture of a query error and its later fix), so such records go through the same review and dedup path as agent captures rather than a parallel writer.

func (*Toolkit) Close

func (*Toolkit) Close() error

Close releases resources.

func (*Toolkit) Connection

func (*Toolkit) Connection() string

Connection returns the connection name for audit logging.

func (*Toolkit) Kind

func (*Toolkit) Kind() string

Kind returns the toolkit kind.

func (*Toolkit) Name

func (t *Toolkit) Name() string

Name returns the toolkit instance name.

func (*Toolkit) RegisterTools

func (t *Toolkit) RegisterTools(s *mcp.Server)

RegisterTools registers memory_manage with the MCP server. Recall moved to the unified search tool (#632).

func (*Toolkit) SetQueryProvider

func (*Toolkit) SetQueryProvider(_ query.Provider)

SetQueryProvider is a no-op; memory toolkit does not use query execution.

func (*Toolkit) SetRecallChecker added in v1.87.0

func (t *Toolkit) SetRecallChecker(rc RecallChecker)

SetRecallChecker wires the recall-first checker.

func (*Toolkit) SetSemanticProvider

func (*Toolkit) SetSemanticProvider(_ semantic.Provider)

SetSemanticProvider is a no-op: recall (which used lineage) moved to search, so the memory toolkit no longer needs the semantic provider.

func (*Toolkit) SetThreadLinker added in v1.87.0

func (t *Toolkit) SetThreadLinker(tl ThreadLinker)

SetThreadLinker wires the feedback-thread bridge.

func (*Toolkit) Tools

func (*Toolkit) Tools() []string

Tools returns the list of tool names.

Jump to

Keyboard shortcuts

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