crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Knowledge metadata supported in storage but not configurable via KnowledgeConfig / Agent

Open mmpouya opened this issue 6 months ago • 9 comments

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

In the agentic systems I wrote, there were times when I needed a knowledge base. This base was gradually filled during the pipeline and was later to be used by other agents. But I needed to filter the data for metadata. (I'm currently using Qdrant) KnowledgeStorage.search() accepts and returns metadata; the missing piece is how to set that metadata from user-land and how that relates (or not) to set_rag_config.

The lower layers already support metadata fully:

1- KnowledgeStorage.search(query, metadata_filter=...) → RAG client → ChromaDB/Qdrant 👌 (the _prepare_search_params from QdrantClient handles params perfectly.) 2- BaseRecord has a metadata field 👌 3- BaseKnowledgeSource has metadata: dict[str, Any] field.


But 4 gaps prevent users from actually using it:

  1. KnowledgeConfig: No metadata_filter field (only results_limit, score_threshold), so metadata‑based retrieval cannot be configured at the config/agent level.

  2. Knowledge.query() / Knowledge.aquery() Doesn't forward metadata_filter — it's silently dropped

  3. Crew.query_knowledge() Same — no metadata_filter param

  4. BaseKnowledgeSource._save_documents() / save() Source's self.metadata is never written to vector store documents. even a Comment says # Currently unused ~/lib/crewai/src/crewai/knowledge/source/base_knowledge_source.py#L20 I would expect self.metadata to be merged into each stored document’s metadata (or at least optionally).

If these gaps get filled and fixed, usage would then look like this:

from crewai.knowledge.knowledge_config import KnowledgeConfig
config = KnowledgeConfig(
    results_limit=10,
    score_threshold=0.5,
    metadata_filter={"task": "translation"}  # new
)
agent = Agent(
    knowledge_sources=[...],
    knowledge_config=config
)

The solution would be just like passing these metadata to search and queries from KnowledgeConfig.

mmpouya avatar May 14 '26 08:05 mmpouya

Metadata propagation is also the point where knowledge starts to become auditable across agents, not just filterable inside one vector store.

For multi-agent crews, the fields I would want user-land to preserve are not only domain filters, but provenance fields:

  • source agent / role,
  • pipeline stage,
  • task or run id,
  • artifact hash / source URI,
  • confidence or validation status,
  • expiry / revocation marker.

That keeps metadata_filter useful for retrieval, but also lets a downstream agent decide whether a memory item is safe to use for a particular task.

For AgentFolio/SATP-style reputation, this is the bridge: if knowledge written by one agent later drives another agent’s action, the metadata should preserve enough identity/provenance that the work history remains inspectable. Otherwise the reputation trail breaks at the RAG boundary.

So +1 to exposing metadata in KnowledgeConfig / Agent and making sure BaseKnowledgeSource._save_documents() actually writes it through. I’d also consider documenting a recommended provenance schema, even if CrewAI keeps the keys optional.

0xbrainkid avatar May 15 '26 03:05 0xbrainkid

For managing knowledge base metadata in agentic pipelines, Supabase could help store and query structured metadata alongside your knowledge entries. Check out the supabase-py integration at aiaam.xyz for a ready-to-use setup.

For observability into how agents consume that knowledge over time, Langfuse tracing is also worth considering.

javierfajardo85-rgb avatar May 18 '26 20:05 javierfajardo85-rgb

Great framing on provenance fields, @0xbrainkid. We ran into the same gap running 20+ agents across CrewAI, AutoGen, and LangGraph in production — metadata is stored per agent but there's no cross-agent provenance chain.

What worked for us: instead of a centralized metadata store, each agent signs its knowledge contributions with a wallet keypair (ETH/SOL/BTC). The signed metadata includes source agent, pipeline step, and a hash of the content. Any downstream agent can verify the origin chain without needing access to the upstream agent's vector store. We surface this as /llms.txt at each agent's endpoint — so discovery and provenance verification share the same wire format.

We open-sourced this approach at github.com/sunfishloop/sunfishloop — it's the provenance layer for a cross-framework agent social network running in production.

sunfishloop avatar Jun 18 '26 04:06 sunfishloop

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 18 '26 12:07 github-actions[bot]

Reliability note

Production automation failures usually reduce to a contract issue before a model/prompt issue:

  1. Success criteria — durable artifact id (message/booking/row), not only node green
  2. Side-effect before complete — never blind-retry without an idempotency key on the business object
  3. Tool vs path split — external action can succeed while the node/agent path still errors (silent-green / false-red)

If you have one failing execution + expected vs actual, reply with stack/version and I will send a free root-cause checklist.

IgorGanapolsky avatar Jul 23 '26 00:07 IgorGanapolsky

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 23 '26 12:08 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Aug 28 '26 16:08 github-actions[bot]