examples/projects/ag2-multiagent-rag/README.md
This example demonstrates how to combine AG2 (formerly AutoGen) multi-agent conversations with Pathway's real-time RAG pipeline.
AG2 is a multi-agent conversation framework with 500K+ monthly PyPI downloads, 4,300+ GitHub stars, and 400+ contributors.
This project combines two powerful frameworks:
The key advantage: Pathway re-indexes documents automatically whenever they change, so AG2 agents always query the latest version of the knowledge base — no manual re-indexing required.
Documents (live folder) --> Pathway VectorStoreServer (real-time indexing)
|
REST API /v1/retrieve
|
User Query --> AG2 UserProxy --> GroupChat [Researcher + Analyst]
|
search_documents tool --> HTTP POST --> Pathway
|
Grounded, real-time answers with citations
Clone the Repository:
git clone https://github.com/pathwaycom/pathway.git
cd pathway/examples/projects/ag2-multiagent-rag/
Install Dependencies:
pip install -U pathway "ag2[openai]>=0.11.4,<1.0" requests python-dotenv
Environment Variables:
Create a .env file in the project root and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
Add Documents:
Place your documents (TXT, MD, PDF) in the ./data/ directory. A sample document is included for testing.
Run the Pipeline:
python main.py
The script will:
./data/Add documents while running — Pathway re-indexes automatically.
./data/, chunks them with TokenCountSplitter, embeds them with OpenAI embeddings, and serves the index via HTTP/v1/retrieve endpoint via the search_documents tool to retrieve relevant chunksGroupChat, coordinated by a GroupChatManagerThis example shows how Pathway's real-time document indexing complements AG2's multi-agent orchestration. The combination is especially useful for scenarios where documents change frequently and agents need access to the latest information — such as live knowledge bases, continuously updated reports, or streaming data pipelines.
You can find more ready-to-run pipelines in our templates section.