HazelJS Explains When to Use RAG, CAG, KAG, or Memory for Agent Context
HazelJS presents its approach to context for AI agents as four complementary layers: RAG, CAG, KAG, and Memory, each with its own NodeJS package. The article explains that RAG retrieves relevant passages from large, changing document collections at query time, which suits relevance-dependent answers. CAG instead prepares relatively stable knowledge once and reuses it through caching, which fits policies and schemas needed on most turns. KAG stores domain knowledge as typed entities, relationships, and time-scoped facts with provenance, enabling multi-hop and causal questions. The authors stress that Memory is distinct from domain knowledge, tracking what an agent has learned about a specific user, and that the labs can be run offline without API keys.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in