memory

package
v1.0.0-alpha.42 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compactor

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

func NewCompactor

func NewCompactor(cfg Config, logger *zap.Logger) *Compactor

func (*Compactor) Compact

func (c *Compactor) Compact(
	ctx context.Context, model fantasy.LanguageModel,
	store CompactorStore, sessionID string,
) error

Compact narrows the LLM-facing message window when it grows past the configured caps. The daemon's agent_messages table has no "hidden but visible-to-UI" notion, so compaction is destructive in the new model: rows that drop out of the window are gone for the UI too. The summarize strategy injects a synthetic "[Conversation summary]: …" assistant row in place of the old window; the slide strategy just keeps the tail.

Per the alpha plan that moved storage to the daemon, this trade is intentional — the dashboard ListMessages view now mirrors the model's actual context, never a "collapsed" superset.

type CompactorStore

type CompactorStore interface {
	ListMessages(ctx context.Context, sessionID string) ([]memoryclient.StoredMessage, error)
	ReplaceMessages(ctx context.Context, sessionID string, msgs []memoryclient.StoredMessage) error
}

CompactorStore is the read+rewrite surface Compact needs. *memoryclient.Client satisfies it; tests inject an in-memory fake.

type Config

type Config struct {
	Strategy    string
	MaxMessages int
	MaxTokens   int
}

Jump to

Keyboard shortcuts

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