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 ¶
- type AutoCaptureInput
- type CaptureResult
- type IndexNotifier
- type RecallChecker
- type RecallMatch
- type RecallQuery
- type ThreadLinker
- type Toolkit
- func (t *Toolkit) AutoCapture(ctx context.Context, in AutoCaptureInput) (*CaptureResult, error)
- func (*Toolkit) Close() error
- func (*Toolkit) Connection() string
- func (*Toolkit) Kind() string
- func (t *Toolkit) Name() string
- func (t *Toolkit) RegisterTools(s *mcp.Server)
- func (t *Toolkit) SetIndexNotifier(n IndexNotifier)
- func (*Toolkit) SetQueryProvider(_ query.Provider)
- func (t *Toolkit) SetRecallChecker(rc RecallChecker)
- func (*Toolkit) SetSemanticProvider(_ semantic.Provider)
- func (t *Toolkit) SetThreadLinker(tl ThreadLinker)
- func (t *Toolkit) SettleRecall(ctx context.Context, id string, emb []float32)
- func (*Toolkit) Tools() []string
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
CaptureResult is the outcome of a server-initiated capture.
type IndexNotifier ¶ added in v1.138.2
IndexNotifier asks for a stored record to be embedded now rather than on the next reconciler sweep. Satisfied by *indexjobs.Producer; declared here so the toolkit does not import the queue.
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"`
// CreatedAt orders a restating pair: the newer record supersedes the
// older, whichever of the two is embedded first (#1987).
CreatedAt time.Time `json:"-"`
}
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 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. The check runs when the capture's embedding is written (SettleRecall), so it never runs without one.
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 (*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), the queued embedding and the recall-first check it triggers, 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) Connection ¶
Connection returns the connection name for audit logging.
func (*Toolkit) RegisterTools ¶
RegisterTools registers memory_manage with the MCP server. Recall moved to the unified search tool (#632).
func (*Toolkit) SetIndexNotifier ¶ added in v1.138.2
func (t *Toolkit) SetIndexNotifier(n IndexNotifier)
SetIndexNotifier wires the write-path enqueue that embeds a stored capture or an updated record off the request (#1987).
func (*Toolkit) SetQueryProvider ¶
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 ¶
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) SettleRecall ¶ added in v1.138.2
SettleRecall runs the recall-first check for a capture whose embedding has just been written (#1987). The index job calls it with the vector it wrote, so the check costs no embed of its own.
A capture is stored before it is embedded, and two restatements captured close together can be embedded in either order. So the rule is about the records rather than about which job ran first: of two records at or above the supersede threshold, the NEWER supersedes the older. When this record is the newer, it supersedes every restated record (all of them, so a capture arriving over an already-duplicated pair consolidates the whole set); when a restated record is newer, this one is superseded by the best such match. Records in the suggest band are written to this record's metadata as similar_existing.
Only a record marked recall_check=pending is checked, once: a re-embed after an edit or a model swap is not a new capture. Best-effort throughout; a failure is logged and leaves the record pending, where the next write of its embedding checks it again.