Documentation
¶
Index ¶
- Variables
- func IsConversationWrite(ctx context.Context) bool
- func WithConversationWrite(ctx context.Context) context.Context
- type MemoryItem
- type Service
- func (s *Service) CountMemoryFiles(ctx context.Context, botID string) (int, error)
- func (s *Service) OverviewStaleSince(botID string) (time.Time, bool)
- func (s *Service) PersistMemories(ctx context.Context, botID string, items []MemoryItem, _ map[string]any) error
- func (s *Service) ReadAllMemoryFiles(ctx context.Context, botID string) ([]MemoryItem, error)
- func (s *Service) ReadAllMemoryFilesForIngest(ctx context.Context, botID string) ([]MemoryItem, error)
- func (s *Service) RebuildFiles(ctx context.Context, botID string, items []MemoryItem, _ map[string]any) error
- func (s *Service) RefreshOverview(ctx context.Context, botID string) error
- func (s *Service) RemoveAllMemories(ctx context.Context, botID string) error
- func (s *Service) RemoveMemories(ctx context.Context, botID string, ids []string) error
- func (s *Service) SyncOverview(ctx context.Context, botID string) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotConfigured = errors.New("memory filesystem not configured")
Functions ¶
func IsConversationWrite ¶ added in v0.22.0
IsConversationWrite reports whether ctx carries a conversation write.
func WithConversationWrite ¶ added in v0.22.0
WithConversationWrite marks ctx as carrying a memory write made while a conversation runs: post-turn extraction or a memory tool the agent called. Such a write leaves MEMORY.md as it is until RefreshOverview runs: MEMORY.md sits in the system prompt ahead of the whole history, so rewriting it while a session is warm makes every following token of that session's next request miss the prompt cache. Writes outside a conversation (management API, ingest, rebuild) leave ctx unmarked and rewrite MEMORY.md at once.
Types ¶
type MemoryItem ¶
type MemoryItem struct {
ID string `json:"id"`
Memory string `json:"memory"`
Hash string `json:"hash,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Score float64 `json:"score,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
BotID string `json:"bot_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
RunID string `json:"run_id,omitempty"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) CountMemoryFiles ¶
func (*Service) OverviewStaleSince ¶ added in v0.22.0
OverviewStaleSince reports whether MEMORY.md may lag behind the bot's memory files and, if so, since when.
func (*Service) PersistMemories ¶
func (*Service) ReadAllMemoryFiles ¶
func (*Service) ReadAllMemoryFilesForIngest ¶
func (s *Service) ReadAllMemoryFilesForIngest(ctx context.Context, botID string) ([]MemoryItem, error)
ReadAllMemoryFilesForIngest is like ReadAllMemoryFiles but does not drop items whose YAML frontmatter lacks an `id`. Instead it synthesises a deterministic id from the file path + body so re-ingesting the same file is idempotent (collides on the same row via UpsertNode's ON CONFLICT(id)). Items that already declare an `id` keep it verbatim, preserving agent-authored control.
This is the file→DB ingest entry point: the derived-markdown rebuild path (RebuildFiles) regenerates files from DB nodes and preserves un-ingested agent-authored files, but without this ingest the agent's directly-written /data/memory/*.md would stay invisible to search_memory.
func (*Service) RebuildFiles ¶
func (s *Service) RebuildFiles(ctx context.Context, botID string, items []MemoryItem, _ map[string]any) error
RebuildFiles rewrites the memory projection from items and finishes with SyncOverview, so callers need not sync the overview again. A conversation write defers the MEMORY.md rewrite as SyncOverview does.
func (*Service) RefreshOverview ¶ added in v0.22.0
RefreshOverview rewrites MEMORY.md from the memory files when it may be stale. Rendering is deterministic, so a refresh that finds nothing new writes the same bytes the file already holds.