Vector DB does not generate embeddings if Content DB is present in the Knowledge

This works:

knowledge = Knowledge(
    name="basic sdk knowledge base",
    description="agno 2.0 knowledge implementation",
    vector_db=vector_db,
    #contents_db=contents_db,
)
this doesn't work;

knowledge = Knowledge(
    name="basic sdk knowledge base",
    description="agno 2.0 knowledge implementation",
    vector_db=vector_db,
    contents_db=contents_db,
)

the problem is that with AgentOS contents_db is mandatory
vector_db=lancedb
content_db=postgres

Hi @Roberto, thanks for reaching out and supporting Agno. I’ve shared this with the team, we’re working through all requests one by one and will get back to you soon.If it’s urgent, please let us know. We appreciate your patience!

Thanks so much, @Monali! Yes, it’s quite urgent. I need to decide on a strategy ASAP.
Thank you very much for your attention.

Hey @Roberto, absolutely! Our Engineer @anuragphi will be here to help you out.

Hey @Roberto,
I gave it a try and was able to successfully generate embeddings with the contentdb. Could you share your agent configuration so we can debug this locally ?

Alternatively, you can try running the snippet below to check if it’s generating vectors correctly:

from agno.agent import Agent
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.models.openai import OpenAIChat
from agno.vectordb.lancedb import LanceDb, SearchType
from agno.db.postgres import PostgresDb

# Create knowledge with BOTH vector_db and contents_db
knowledge = Knowledge(
    name="agno_knowledge_base",
    description="Knowledge base with both vector and content storage",
    vector_db=LanceDb(
        uri="tmp/lancedb",
        table_name="testpostgres",
        search_type=SearchType.hybrid,
        embedder=OpenAIEmbedder(id="text-embedding-3-small"),
    ),
    contents_db=PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai"),
)

# Add content to the knowledge base
knowledge.add_content(text_content="Agno is a powerful framework for building AI agents with Python.")

agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    knowledge=knowledge,
    search_knowledge=True,
    instructions="Use the knowledge base to answer questions accurately.",
    markdown=True,
)

agent.print_response("What is Agno?", markdown=True)

Let me know if it successfully generates vectors on your end — that’ll help narrow things down quickly.

from agno.db.postgres.postgres import PostgresDb
from agno.knowledge.embedder.openai import OpenAIEmbedder
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.lancedb import LanceDb
from agno.vectordb.search import SearchType
import lancedb
import json
from utilities import convert_numpy

from db.session import db_url

contents_db = PostgresDb(
    db_url=db_url,
    knowledge_table="knowledge_contents",
    db_schema="agno_api",
)

vector_db=LanceDb(
    table_name="recipes",
    uri="tmp/lancedb",
    search_type=SearchType.hybrid,
    embedder=OpenAIEmbedder(),
)

# create knowledge instance
knowledge = Knowledge(
    name="basic sdk knowledge base",
    description="agno 2.0 knowledge implementation",
    vector_db=vector_db,
    contents_db=contents_db,
)

# add a single piece of text content
 asyncio.run(
     knowledge.add_content_async(
         name="text content",
         text_content="cats and dogs are pets.",
         metadata={"user_tag": "animals"},
     )
)

Very simple code! vector in lancedb is null

Hey @Roberto

The snippet you shared seems to work fine. Vectors are added to the vector db.

Can you please share more info on the error you see (if any)?