rony-llm-agent/pkg/rag
Victor Vargas 1c0c86de10 feat(rag): memory taxonomy (episodic/semantic/procedural) + episodic auto-capture
Fragments now carry a memory type in metadata (legacy fragments count as
procedural) with SearchByType filtering, and EpisodeCapture summarizes a
finished turn with the local LLM and stores it as episodic memory, so the
agent can answer "what did we do yesterday?". Includes an E2E test against
a live llama.cpp server (gated) and taxonomy unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 14:50:31 -07:00
..
backends style: gofmt 2026-07-12 16:14:15 -07:00
embeddings feat(rag): add SQLite+FTS5 backend, fix content/usage plumbing bugs 2026-07-06 00:05:30 -07:00
autocapture.go feat(rag): memory taxonomy (episodic/semantic/procedural) + episodic auto-capture 2026-07-15 14:50:31 -07:00
e2e_local_test.go feat(rag): memory taxonomy (episodic/semantic/procedural) + episodic auto-capture 2026-07-15 14:50:31 -07:00
memory.go feat(rag): memory taxonomy (episodic/semantic/procedural) + episodic auto-capture 2026-07-15 14:50:31 -07:00
memory_test.go style: gofmt 2026-07-12 16:14:15 -07:00
README.es.md docs(i18n): translate all docs to English (with .es.md as Spanish alternative) 2026-06-30 13:40:37 -07:00
README.md docs(i18n): translate all docs to English (with .es.md as Spanish alternative) 2026-06-30 13:40:37 -07:00
taxonomy_test.go feat(rag): memory taxonomy (episodic/semantic/procedural) + episodic auto-capture 2026-07-15 14:50:31 -07:00

pkg/rag

Retrieval-Augmented Generation: memory, embeddings, and semantic search.

Responsibility

Provide persistent memory and semantic search over agent content.

Components

Type What it stores Persistence
Working Current session messages RAM
Episodic Past events: "what I did on 2026-06-20" Vector DB
Semantic Consolidated knowledge: "how is the architecture" Vector DB (curated)
Procedural How to do things: user workflows Vector DB (auto-learned)

Public API

type Memory interface {
    Add(ctx context.Context, fragment Fragment) error
    Search(ctx context.Context, query string, topK int) ([]Fragment, error)
    Forget(ctx context.Context, id string) error
}

type Fragment struct {
    ID         string
    Content    string
    Vector     []float32
    Metadata   map[string]string
    Timestamp  time.Time
    ProjectID  string
}

type Embedder interface {
    Embed(ctx context.Context, text string) ([]float32, error)
    Dimensions() int
}

Backends

Backend When to use
ChromaDB embedded Default. Simple, sufficient for <100k docs
Qdrant embedded If you need >100k docs or very fast queries
SQLite + sqlite-vec If you want zero-dependency (no CGO with modernc.org/sqlite)

Embeddings

Provider Model Dimensions
Ollama nomic-embed-text 768
Ollama bge-m3 1024
Local ONNX all-MiniLM-L6-v2 384

Usage

import "github.com/VictorVargas/rony-llm-agent/pkg/rag"
import "github.com/VictorVargas/rony-llm-agent/pkg/rag/backends/chroma"

backend, _ := chroma.New(chroma.Config{
    Path: "~/.local/share/rony/chroma",
})

memory := rag.New(rag.Config{
    Backend: backend,
    Embedder: ollamaEmbedder,
})

err := memory.Add(ctx, rag.Fragment{
    Content: "Refactored auth.go using hexagonal",
    ProjectID: "rony",
})

See also

  • pkg/agent — Injects memory into the loop
  • pkg/llm — For summarization in compaction