ReActAgent in both agentic and generic manners.
AgentScope does not require you to use the built-in RAG module. Integrating third-party RAG implementations, frameworks, or services is fully supported and encouraged.
RAG Module Architecture
The RAG module is composed of two core components:- Reader — reads and chunks input documents into
Documentobjects. - Knowledge — stores documents in a vector database and implements retrieval algorithms.
Integration Approaches
When integrating RAG withReActAgent, you can choose between two approaches:
Built-in Readers
Readers are responsible for loading data and chunking it intoDocument objects. Each Document contains:
metadata— document content,doc_id,chunk_id, andtotal_chunks.embedding— embedding vector, filled when the document is added to or retrieved from the knowledge base.score— relevance score, filled during retrieval.
TextReader
TextReader reads and chunks plain text into paragraph-level (or character-level) Document objects.
There is no universally optimal chunk size or splitting strategy. For PDF files and domain-specific content, implementing a custom reader tailored to your scenario is strongly recommended. To create one, inherit from
ReaderBase and implement the __call__ method.Building a Knowledge Base
After chunking documents, create a knowledge base by providing an embedding model and an embedding store (vector database). AgentScope provides built-in support for Qdrant as the embedding store andSimpleKnowledge as the knowledge base implementation.
The
QdrantStore location parameter supports in-memory storage (:memory:), local file paths, and remote Qdrant server URLs. Refer to the Qdrant documentation for details.retrieve_knowledge as a Tool Function
SimpleKnowledge exposes a retrieve_knowledge method that wraps retrieve into a tool-compatible function. You can register it directly in an agent’s Toolkit:
Customizing RAG Components
AgentScope provides base classes for building custom readers, knowledge bases, and embedding stores:Integrating with ReActAgent
Agentic Manner
In agentic manner,retrieve_knowledge is registered as a tool in the agent’s Toolkit. The agent autonomously decides when to retrieve and rewrites the query using full conversation context.
Generic Manner
In generic manner, pass theknowledge object directly to ReActAgent. The agent automatically retrieves relevant documents at the start of each reply and prepends them to the user message.
Multimodal RAG
AgentScope supports multimodal RAG natively:DashScopeMultiModalEmbeddingembeds text, images, and other modalities into the same vector space.ImageReaderreads image files intoDocumentobjects with image metadata.
Further Reading
Context and Memory
Memory backends for storing and managing session messages.
Agent
ReActAgent internals, tool registration, and reply lifecycle.