Documentation
¶
Overview ¶
Package memory defines the Message entity and memory store interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []any `json:"tool_calls,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Message represents a single message in a conversation.
func DecodeStoredMessage ¶
DecodeStoredMessage rejects malformed persisted conversation rows. Callers must fail the complete history read rather than silently skip a bad row. Errors never include the stored content or parser diagnostics.
type Store ¶
type Store interface {
SaveConversation(ctx context.Context, agentID id.AgentID, sessionID id.SessionID, messages []Message) error
LoadConversation(ctx context.Context, agentID id.AgentID, sessionID id.SessionID, limit int) ([]Message, error)
ClearConversation(ctx context.Context, agentID id.AgentID, sessionID id.SessionID) error
SaveWorking(ctx context.Context, runID id.AgentRunID, key string, value any) error
LoadWorking(ctx context.Context, runID id.AgentRunID, key string) (any, error)
ClearWorking(ctx context.Context, runID id.AgentRunID) error
SaveSummary(ctx context.Context, agentID id.AgentID, summary string) error
LoadSummaries(ctx context.Context, agentID id.AgentID) ([]string, error)
}
Store defines persistence for agent memory (conversation, working, summaries).
None of these methods carry a tenant or scope parameter: the scope comes from the context via cortex.ScopeFromContext, so there is nothing left for a caller to forget to pass. This includes the working-memory methods, which are keyed by run ID — a bearer capability, not an isolation boundary on its own — so they need the same guard as everything else here.