-
Notifications
You must be signed in to change notification settings - Fork 395
Description
π Prerequisites
- I have searched the existing issues to avoid creating a duplicate
- By submitting this issue, you agree to follow our Code of Conduct
π Feature Summary
Add support for long-term memory
β Problem Statement / Motivation
Why do we need long term memory?
Sessions can track history (events) and temporary data for a single ongoing conversation. But in order for agents to recall information from past conversations (from the same or different session), we need a memory service to support "long-term knowledge", similar to a searchable archive or knowledge library that the agent can consult, potentially containing information from many past chats or other sources.
π‘ Proposed Solution
System Overview
- Agent (Python ADK): Uses KagentMemoryService to send/retrieve memories via HTTP and generate embeddings, configured from the CRDs
- Controller (Go): Exposes /api/memory endpoints to manage vector storage
- Storage (Postgres): Stores embeddings and metadata in the agent_memory table.
Components
- HTTP server endpoints (Go)
- POST /api/memory/sessions: Accepts (text, vector) pairs. Stores in agent_memory.
- POST /api/memory/search: Accepts (query_vector). Performs cosine similarity search in pgvector
- Kagent ADK (Python)
KagentMemoryService will BaseMemoryService with two methods:
add_session_to_memory: Uses LiteLLM to generate embeddings using the configured embedding model, send vectors to Kagent APIsearch_memory: Embed query and sendquery_vectorto Kagent API
This will be created and passed to the Runner if memory is enabled on the agent. The agent will use tools to either optionally or preload memory. After each agent execution, a callback will save the session to memory using the memory service. These are documented further in the ADK memory interface: https://google.github.io/adk-docs/sessions/memory/
- Embedding Model Config
apiVersion: kagent.dev/v1alpha2
kind: ModelConfig
spec:
embedding:
provider: OpenAI # or AzureOpenAI, Vertex, Ollama
model: "text-embedding-3-small"
- Agent Configuration
spec:
declarative:
memory:
enabled: true
modelConfig: "embedding-model-config"- Data Model
The user can configure whether to extend the database to use vector-extensions in Helm Chart:
// helm/kagent/values.yaml
database:
postgres:
vector:
enabled: true # Default: true
We will use pgvector for Postgres (production) and sqlite-vector (https://github.com/sqliteai/sqlite-vector) for sqlite (development).
Table: agent_memory
id: UUID
agent_name: String (Tenant)
user_id: String (Tenant)
content: Text (Chunk)
embedding: Vector (Size varies by model)
metadata: JSONB (Source session ID, timestamp)
π Alternatives Considered
-
Use the Qdrant MCP server or similar options: https://google.github.io/adk-docs/tools/third-party/qdrant/ However this requires using a cloud-hosted solution for the vector DB. Note that if you wish to use an external Vector database (like qdrant, chroma, pinecone), you can still use the MCP approach and disable the internal pgvector memory service.
-
Use pinecone or qdrant in cluster: this was a popular approach perhaps a year ago, but right now the best practice is to keep relational data and vector data in the same database as extensions like
pgvectormature and reach similar performance as dedicated vector databases. This not only provides tighter integration and less overhead, but also better metadata query performance.
π― Affected Service(s)
Multiple services / System-wide
π Additional Context
The feature will first be rolled out in ADK. Then, support to BYO agents will be added via the kagent packages to LangGraph, CrewAI, OpenAI SDK.
π Are you willing to contribute?
- I am willing to submit a PR for this feature
Metadata
Metadata
Assignees
Labels
Type
Projects
Status