AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Configuring Custom Vector Databases and Persistent Memory in Self-Hosted AgentGPT

Annika Bernklau · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Self-hosting AgentGPT gives teams full control over autonomous agent orchestration, privacy, and infrastructure costs. But anyone who has spun up the default Docker Compose stack discovers a glaring limitation within ten minutes: AgentGPT has goldfish memory.

Out of the box, AgentGPT’s persistence layer—powered by MySQL via Prisma and SQLModel—stores user sessions, configuration settings, and linear execution logs. It records what happened, but it does not recall semantic context across execution loops or between independent agent runs. As an agent tackles subtasks, its context window rapidly inflates until it either overflows token limits or begins hallucinating redundant actions.

To turn AgentGPT from an ephemeral prompt-chainer into an autonomous assistant that actually learns from previous iterations, developers must connect an external vector database. Here is how 365Finds recommends architecting, configuring, and wiring custom vector stores—specifically local ChromaDB and cloud-managed Pinecone—into a self-hosted AgentGPT deployment.


The Architectural Split: Relational State vs. Vector Memory

AgentGPT consists of two core containers in Docker:

  1. Next.js Frontend (frontend): Web UI running on port 3000 that manages user input, real-time agent output streams, and visual task graphs.
  2. FastAPI Backend (platform / backend): Python service running on port 8000 handling agent lifecycle logic, tool execution, and LLM orchestration via LangChain.
  3. Relational Database (db): Standard MySQL container holding users, agent runs, and historical chat logs.
       [ Browser / Client ]
                 │
                 ▼
     ┌───────────────────────┐
     │  Next.js (Port 3000)  │
     └───────────┬───────────┘
                 │ HTTP / WebSocket
                 ▼
     ┌───────────────────────┐
     │  FastAPI (Port 8000)  │ ◄─── LangChain Agent Loop
     └─────┬───────────┬─────┘
           │           │
     Prisma│SQL        │ Embeddings & Cosine Search
           ▼           ▼
     ┌──────────┐  ┌──────────────────────────────┐
     │  MySQL   │  │ ChromaDB (Local) or Pinecone │
     │ (State)  │  │   (Long-Term Vector Memory)  │
     └──────────┘  └──────────────────────────────┘

The MySQL database tracks execution state. Vector memory handles episodic and semantic recall. When an agent creates subtasks, instead of blindly stuffing the past twenty outputs into the next prompt, the backend converts previous task outputs into high-dimensional embeddings, writes them to the vector store, and queries for only the top-k most semantically relevant memories before executing the next action.


Option 1: Local ChromaDB via Docker Compose (The 365Finds Recommendation)

For air-gapped environments, local development, and privacy-sensitive internal tools, 365Finds strongly favors self-hosting ChromaDB directly within the Docker Compose network. You keep all vector data on your own storage volume, eliminate third-party API latency, and avoid per-query vector pricing.

1. Update docker-compose.yml

Add a dedicated chroma service to your deployment manifest and mount a persistent volume so memory survives container restarts:

version: "3.9"

services:
  frontend:
    # Next.js UI configuration
    build:
      context: ./next
    ports:
      - "3000:3000"
    environment:
      - NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
    depends_on:
      - platform

  platform:
    # FastAPI Backend execution engine
    build:
      context: ./platform
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=mysql://agentgpt:password@db:3306/agentgpt_db
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - VECTOR_STORE_PROVIDER=chroma
      - CHROMA_SERVER_HOST=chroma
      - CHROMA_SERVER_HTTP_PORT=8000
      - CHROMA_COLLECTION_NAME=agentgpt_persistent_memory
      - EMBEDDING_MODEL=text-embedding-3-small
    depends_on:
      - db
      - chroma

  chroma:
    image: chromadb/chroma:0.5.20
    container_name: agentgpt_chroma
    ports:
      - "8001:8000" # Mapped to host port 8001 to prevent collisions
    volumes:
      - chroma_data:/chroma/chroma
    environment:
      - IS_PERSISTENT=TRUE
      - ANONYMIZED_TELEMETRY=FALSE
    restart: unless-stopped

  db:
    image: mysql:8.0
    environment:
      - MYSQL_DATABASE=agentgpt_db
      - MYSQL_USER=agentgpt
      - MYSQL_PASSWORD=password
      - MYSQL_ROOT_PASSWORD=rootpassword
    volumes:
      - mysql_data:/var/lib/mysql

volumes:
  chroma_data:
    driver: local
  mysql_data:
    driver: local

Critical Networking Gotcha: Within the Docker bridge network, services communicate by service name. Setting CHROMA_SERVER_HOST=localhost in platform will fail because localhost inside the platform container refers to itself, not the chroma container. Use CHROMA_SERVER_HOST=chroma.


Option 2: Managed Pinecone for Zero-Maintenance Cloud Memory

If you are running AgentGPT across distributed nodes or want to offload infrastructure maintenance entirely, Pinecone is the path of least resistance. Pinecone handles vector sharding, automatic metadata indexing, and multi-tenant namespacing out of the box.

1. Create the Pinecone Index

Before updating your environment variables, initialize a serverless index in the Pinecone Console with the following settings:

2. Configure Backend Environment

In your root .env or platform/.env file, supply your Pinecone credentials:

# Vector Store Selection
VECTOR_STORE_PROVIDER=pinecone

# Pinecone Credentials
PINECONE_API_KEY=pcsk_live_example_key_xxxxxxxxxxxxx
PINECONE_INDEX_NAME=agentgpt-memory
PINECONE_NAMESPACE=production-agents

# Embedding Engine
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxxxxxxxxx
EMBEDDING_MODEL=text-embedding-3-small

Pass these variables into the platform container inside docker-compose.yml:

  platform:
    environment:
      - VECTOR_STORE_PROVIDER=${VECTOR_STORE_PROVIDER}
      - PINECONE_API_KEY=${PINECONE_API_KEY}
      - PINECONE_INDEX_NAME=${PINECONE_INDEX_NAME}
      - PINECONE_NAMESPACE=${PINECONE_NAMESPACE}
      - OPENAI_API_KEY=${OPENAI_API_KEY}

Hooking the Vector Store into the Agent Execution Pipeline

Environment variables alone do not automatically grant memory to your agent. In the FastAPI backend (reworkd_platform), agent task cycles must explicitly call vector retrieval and insertion logic.

Here is how the memory store adapter bridges LangChain’s vector abstractions into the AgentGPT task loop:

import os
from typing import List
from langchain_openai import OpenAIEmbeddings
from langchain_core.documents import Document

def get_vector_store():
    provider = os.getenv("VECTOR_STORE_PROVIDER", "chroma").lower()
    embeddings = OpenAIEmbeddings(
        model=os.getenv("EMBEDDING_MODEL", "text-embedding-3-small")
    )

    if provider == "chroma":
        import chromadb
        from langchain_community.vectorstores import Chroma

        client = chromadb.HttpClient(
            host=os.getenv("CHROMA_SERVER_HOST", "chroma"),
            port=int(os.getenv("CHROMA_SERVER_HTTP_PORT", "8000")),
        )
        return Chroma(
            client=client,
            collection_name=os.getenv("CHROMA_COLLECTION_NAME", "agentgpt_memory"),
            embedding_function=embeddings,
        )

    elif provider == "pinecone":
        from pinecone import Pinecone
        from langchain_pinecone import PineconeVectorStore

        pc = Pinecone(api_key=os.getenv("PINECONE_API_KEY"))
        index = pc.Index(os.getenv("PINECONE_INDEX_NAME", "agentgpt-memory"))
        return PineconeVectorStore(
            index=index,
            embedding=embeddings,
            namespace=os.getenv("PINECONE_NAMESPACE", "default"),
        )

    raise ValueError(f"Unsupported VECTOR_STORE_PROVIDER: {provider}")

Implementing Episodic Read/Write in Task Execution

Within the agent step processor:

  1. Pre-Execution Context Search: Query the vector store for documents matching the current task's objective, filtered by agent_id or session metadata.
  2. Execution: Inject retrieved snippets into the agent's system prompt under a designated <context> block.
  3. Post-Execution Upsert: Once the task finishes, write the task description, generated outcome, and timestamp into the vector store.
# Before executing subtask:
vector_store = get_vector_store()
relevant_context = vector_store.similarity_search(
    query=current_task.description,
    k=3,
    filter={"agent_id": agent.id}
)
context_string = "\n".join([doc.page_content for doc in relevant_context])

# After task completion:
doc = Document(
    page_content=f"Task: {current_task.description}\nResult: {task_result}",
    metadata={
        "agent_id": str(agent.id),
        "task_id": str(current_task.id),
        "created_at": current_task.created_at.isoformat(),
    }
)
vector_store.add_documents([doc])

365Finds Field Observations: Practical Pitfalls

Over dozens of agent deployment runs, 365Finds observed three recurring operational headaches that documentation rarely mentions:

1. The Context Pollution Spiral

More memory is not always better memory. If you retrieve top-10 memories indiscriminately, early missteps or hallucinated intermediate goals will permanently contaminate subsequent steps. Keep retrieval tight: k=3 or k=4 with a cosine similarity threshold cutoff (e.g., minimum score of 0.72) is vastly superior to greedy retrieval.

2. Missing Volume Mounts

Running docker compose down -v instead of docker compose down destroys anonymous and named volumes. If your Chroma data directory is not explicitly declared as a named external volume in Docker Compose, your agent’s hard-won cross-session memories vanish after an image rebuild.

3. Upstream Codebase Status

The upstream reworkd/AgentGPT repository was formally archived in early 2026 as the maintainers pivoted toward newer autonomous agent initiatives. For teams deploying AgentGPT today, this means you cannot expect upstream PR merges for modern LangChain 0.2+ or Pydantic v2 vector store shims. You are responsible for maintaining your backend dependencies, patching breaking changes in Chroma’s HTTP client, and pinning stable container versions.


365Finds Assessment

For self-hosting AgentGPT, 365Finds recommends starting with local ChromaDB. It requires zero external account credentials, keeps embedding data strictly within your Docker perimeter, and costs nothing beyond your base compute resources.

Switch to Pinecone only when you need distributed multi-tenant agents where multiple backend instances must share an identical semantic memory pool without dealing with SQLite database locks or container storage replication.


References