Skip to main content

Context vs Knowledge

PraisonAI provides two systems for providing information to agents: Context (runtime data flow) and Knowledge (pre-loaded reference data). Understanding when to use each is crucial for building efficient agents.

Quick Comparison


Context: Runtime Data Flow

Context is how agents share information during a single workflow execution. Data flows from one agent to the next and is lost when the session ends.

Context Code Example


Knowledge: Pre-loaded Reference Data

Knowledge provides agents with pre-loaded reference information from files, URLs, or documents. It uses RAG (Retrieval Augmented Generation) to find relevant information.

Knowledge Code Example

Supported File Types

Documents

PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX

Text

TXT, CSV, JSON, XML, MD, HTML

Media

JPG, PNG, GIF, MP3, WAV (with transcription)

How Knowledge Works

1

Load Documents

Files are read and converted to text using MarkItDown.
2

Chunk Content

Text is split into smaller chunks (default: 512 tokens, 50 overlap).
3

Generate Embeddings

Each chunk is converted to a vector embedding.
4

Store in Vector DB

Embeddings are stored in ChromaDB for fast similarity search.
5

Query at Runtime

When agent needs info, query is embedded and similar chunks are retrieved.

When to Use Each

Use Context When:

  • Agent-to-agent data flow - Passing results between sequential agents
  • Tool results - Using output from tool calls
  • Simple workflows - No external reference data needed
  • Zero dependencies - Want to avoid extra packages

Use Knowledge When:

  • Reference documents - Manuals, FAQs, documentation
  • Large content - Too much to fit in prompt
  • Semantic search - Need to find relevant sections
  • RAG applications - Question answering over documents

Using Both Together

The most powerful pattern combines both: Knowledge for reference data + Context for workflow data.

Knowledge Configuration

Basic Configuration

Advanced Configuration


Performance Comparison

Knowledge has higher setup cost but enables semantic search over large document collections that wouldn’t fit in context.

Summary

Context

Runtime data flow between agents. Fast, zero dependencies, ephemeral. Use for passing agent outputs.

Knowledge

Pre-loaded reference data with semantic search. Persistent, RAG-enabled. Use for documents and FAQs.
Rule of thumb: Use context for workflow data flow. Add knowledge when you need semantic search over documents.