memory

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentMemory

type AgentMemory struct {
	// ID is a unique identifier for this memory record
	ID types.AgentMemoryID

	// AgentID identifies which agent this memory belongs to (e.g., "bigquery")
	AgentID string

	// TaskQuery is the original natural language query that triggered this execution
	TaskQuery string

	// QueryEmbedding is the vector embedding of TaskQuery for semantic search
	// Generated automatically by Memory Service when saving
	// Must use firestore.Vector32 type for Firestore vector search to work
	QueryEmbedding firestore.Vector32

	// Timestamp records when this task was executed
	Timestamp time.Time

	// Duration records how long the task took to complete
	Duration time.Duration

	// Successes is a list of successful patterns observed (K: Keep in KPT format)
	// Contains domain knowledge about what worked: field semantics, data formats, query patterns
	// Example: ["Login failures identified by severity='ERROR' AND action='login'. User ID is user.email (STRING) not user.id (INT64)"]
	Successes []string

	// Problems is a list of issues encountered during execution (P: Problem in KPT format)
	// Contains domain knowledge mistakes: wrong field assumptions, unexpected data formats
	// Example: ["Expected 'timestamp' field but actual field is 'event_time' (TIMESTAMP type). user_id is INT64 not STRING email"]
	Problems []string

	// Improvements is a list of suggestions for future executions (T: Try in KPT format)
	// Contains specific domain knowledge to apply: which fields to use, expected formats, search patterns
	// Example: ["For user searches: use user.email (STRING) not user_id (INT64). For errors: check error_code field values"]
	Improvements []string

	// QualityScore represents the usefulness of this memory (-10.0 to +10.0)
	// - Positive: Helpful memory (higher is better)
	// - 0: Neutral or unrated
	// - Negative: Harmful/misleading memory (lower is worse)
	// This field is optional and defaults to 0.0 for backward compatibility
	QualityScore float64

	// LastUsedAt records when this memory was last retrieved
	// Used for recency calculation and cleanup
	// This field is optional and defaults to zero time for backward compatibility
	LastUsedAt time.Time
}

AgentMemory represents a memory record for Sub-Agent execution history This model follows the KPT (Keep/Problem/Try) format for storing execution experiences

func (*AgentMemory) Validate

func (m *AgentMemory) Validate() error

Validate checks if the AgentMemory is valid

type ExecutionMemory

type ExecutionMemory struct {
	ID       types.MemoryID    `json:"id"`
	SchemaID types.AlertSchema `json:"schema_id"`
	Summary  string            `json:"summary"`
	Keep     string            `json:"keep"`
	Change   string            `json:"change"`
	Notes    string            `json:"notes"`

	// Embedding is the vector embedding of Summary for semantic search
	// Generated automatically by Memory Service when saving
	// Must use firestore.Vector32 type for Firestore vector search to work
	Embedding firestore.Vector32 `json:"embedding,omitempty"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	Version   int       `json:"version"`
}

ExecutionMemory represents learning from task execution

func NewExecutionMemory

func NewExecutionMemory(schemaID types.AlertSchema) *ExecutionMemory

NewExecutionMemory creates a new ExecutionMemory with a unique ID

func (*ExecutionMemory) IsEmpty

func (m *ExecutionMemory) IsEmpty() bool

IsEmpty returns true if the memory has no content

func (*ExecutionMemory) String

func (m *ExecutionMemory) String() string

String returns a Markdown-formatted representation of the memory

func (*ExecutionMemory) Validate

func (m *ExecutionMemory) Validate() error

Validate validates the ExecutionMemory

type MemoryFeedback added in v0.6.2

type MemoryFeedback struct {
	MemoryID types.AgentMemoryID

	// Relevance: Was the memory relevant to the task? (0-3)
	// 0 = Not relevant, 1 = Somewhat relevant, 2 = Relevant, 3 = Highly relevant
	Relevance int

	// Support: Did the memory help find the solution? (0-4)
	// 0 = No help, 1 = Minor help, 2 = Moderate help, 3 = Significant help, 4 = Critical help
	Support int

	// Impact: Did the memory contribute to the final result? (0-3)
	// 0 = No impact, 1 = Minor impact, 2 = Moderate impact, 3 = Major impact
	Impact int

	// Reasoning: LLM's explanation for the scores
	Reasoning string
}

MemoryFeedback represents evaluation of how useful a memory was This feedback is used to update the quality score of agent memories Based on three dimensions: Relevance, Support, and Impact

func (*MemoryFeedback) NormalizedScore added in v0.6.2

func (f *MemoryFeedback) NormalizedScore() float64

NormalizedScore returns score normalized to -10 to +10 range This normalization maps:

  • 0 (worst) -> -10
  • 5 (neutral) -> 0
  • 10 (best) -> +10

type TicketMemory

type TicketMemory struct {
	ID        types.MemoryID    `json:"id"`
	SchemaID  types.AlertSchema `json:"schema_id"`
	Insights  string            `json:"insights"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
	Version   int               `json:"version"`
}

TicketMemory represents organizational knowledge from ticket resolution

func NewTicketMemory

func NewTicketMemory(schemaID types.AlertSchema) *TicketMemory

NewTicketMemory creates a new TicketMemory with a unique ID

func (*TicketMemory) IsEmpty

func (m *TicketMemory) IsEmpty() bool

IsEmpty returns true if the memory has no content

func (*TicketMemory) String

func (m *TicketMemory) String() string

String returns a Markdown-formatted representation of the memory

func (*TicketMemory) Validate

func (m *TicketMemory) Validate() error

Validate validates the TicketMemory

Jump to

Keyboard shortcuts

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