Persistent RAG collections¶
URSA supports persistent Retrieval-Augmented Generation (RAG) collections. A persistent RAG collection lets you ingest documents once, store the resulting vectorstore on disk, and query that collection later from the TUI or through another URSA agent as a tool.
Persistent RAG collections are separate from regular persisted URSA agents. They are stored under:
For example, a RAG collection named papers in the default group is stored under:
What gets stored¶
A persistent RAG collection stores URSA's RAG artifacts, such as the vectorstore and summaries, in its cache directory.
Raw source documents are not copied into the RAG cache during ingestion. Instead, rag-ingest reads from the file or directory you provide and stores the indexed information in the collection's vectorstore.
This avoids duplicating large document trees and avoids copying unrelated large files into URSA's cache.
Ingest documents¶
Use rag-ingest to create or update a named RAG collection:
Example:
This creates or updates:
and indexes ingestible files from ./papers.
You can also ingest a single file:
Ingestion options¶
rag-ingest supports:
ursa rag-ingest <source> \
--name <rag_agent_name> \
--group default \
--return-k 10 \
--chunk-size 1000 \
--chunk-overlap 200
Options:
--name: required name for the persistent RAG collection.--group: RAG group name. Defaults todefault.--return-k: number of chunks to retrieve when the ingest command invokes the RAG graph. Defaults to10.--chunk-size: text chunk size used during ingestion. Defaults to1000.--chunk-overlap: overlap between text chunks. Defaults to200.
During ingestion, URSA prints the source path and confirms that raw documents were not copied:
RAG agent: papers
Group: default
Path: /home/user/.cache/ursa_rag/default/papers
Source: /home/user/project/papers
Query a RAG collection¶
Use rag-query to query a named persistent RAG collection:
Example:
You can specify a group:
You can also omit the query to enter a simple RAG query loop:
Then type questions at the prompt:
Press Ctrl-D or enter a blank line to exit.
Manage RAG collections¶
List RAG collections in a group:
Show details for a RAG collection:
Save a timestamped checkpoint copy of a RAG collection:
Delete a RAG collection:
Use RAG collections as tools¶
Persisted RAG collections can be bound as tools to tool-capable URSA agents.
From the CLI, pass one or more RAG collection names with --rag-tools:
Multiple collections can be comma-separated:
When the agent calls a RAG collection as a tool, URSA prints the request so it is clear that the RAG tool was used:
The RAG tool then returns the RAG summary to the calling agent.
Python usage¶
When constructing an agent in Python, pass rag_tools as a string or list:
or:
For agents that support tools, URSA builds one RAG query tool per named collection.
Groups and model whitelist policy¶
RAG groups are aligned with regular URSA agent groups.
Regular agent groups are stored under:
RAG groups are stored under:
For the default group, URSA creates the RAG group as needed.
For a non-default group, the corresponding regular URSA agent group must already exist. For example, before creating a RAG collection in group chemistry, this directory must exist:
and it must contain:
When a RAG group is first created, URSA copies:
to:
This keeps the RAG group associated with the same whitelist configuration as the corresponding regular agent group.
If the regular agent group does not exist, URSA raises an error and asks you to create the group first:
See the TUI guide for interactive use and the CLI reference for commands that create and manage groups.
Typical workflow¶
- Create a group if needed:
- Ingest a document directory into a named RAG collection:
- Query the RAG collection directly:
- Bind the RAG collection as a tool to an URSA agent:
- Ask questions in the URSA TUI. If the agent calls the RAG tool, you will see output like:
Notes and limitations¶
rag-ingestdoes not copy raw documents into the RAG cache. If the original documents are moved or deleted, already-ingested vectorstore content remains in the persistent RAG collection, but future ingestion from that original source path will require the files to still exist.- Re-running
rag-ingeston the same source updates the persistent RAG collection by indexing documents not already present in the vectorstore. - RAG collection names use the same naming policy as persisted URSA agents.
- RAG tools are available to URSA agents that support tools.
- The TUI uses URSA's configured language model and embedding model settings.