Reference pipeline: ingest, memory, web and paper search, filter, kickoff, and Streamlit demo (PDF 159–168).
Build a Context Engineering workflow We'll build a multi-agent research assistant using context engineering principles. This Agent will gather its context across 4 sources: Documents, Memory, Web search, and Arxiv. Here’s our workflow:
● User submits query.
● Fetch context from docs, web, arxiv API, and memory.
● Pass the aggregated context to an agent for filtering.
● Pass the filtered context to another agent to generate a response.
● Save the final response to memory.
Tech stack:
● Tensorlake to get RAG-ready data from complex docs
● Zep for memory
● Firecrawl for web search
● Milvus for vector DB
● CrewAI for orchestration
Let's go!
CE involves creating dynamic systems that offer:
● The right info
● The right tools
● In the right format
This ensures the LLM can effectively complete the task.
#1) Crew flow
We'll follow a top-down approach to understand the code. Here's an outline of what our flow looks like: Note that this is one of many blueprints to implement a context engineering workflow. Your pipeline will likely vary based on the use case.
#2) Prepare data for RAG
We use Tensorlake to convert the document into RAG-ready markdown chunks for each section. The extracted data can be directly embedded and stored in a vector DB without further processing.
#3) Indexing and retrieval
Now that we have RAG-ready chunks along with the metadata, it's time to store them in a self-hosted Milvus vector database. We retrieve the top-k most similar chunks to our query:
#4) Build memory layer
Zep acts as the core memory layer of our workflow. It creates temporal knowledge graphs to organize and retrieve context for each interaction. We use it to store and retrieve context from chat history and user data.
#5) Firecrawl web search
We use Firecrawl web search to fetch the latest news and developments related to the user query. Firecrawl's v2 endpoint provides 10x faster scraping, semantic crawling, and image search, turning any website into LLM-ready data.
#6) ArXiv API search
To further support research queries, we use the arXiv API to retrieve relevant results from their data repository based on the user query.
#7) Filter context
Now, we pass our combined context to the context evaluation agent that filters out irrelevant context. This filtered context is then passed to the synthesizer agent that generates the final response.
#8) Kick off the workflow
Finally, we kick off our context engineering workflow with a query. Based on the query, we notice that the RAG tool, powered by Tensorlake, was the most relevant source for the LLM to generate a response.
We also translated this workflow into a streamlit app that:
● Provides citations with links and metadata.
● Provides insights into relevant sources.
The workflow explained above is one of the many blueprints. Your implementation can vary.