> ## Documentation Index
> Fetch the complete documentation index at: https://docs.junis.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# RAG Knowledge Base

> Upload documents to enhance AI agent knowledge

## Overview

RAG (Retrieval-Augmented Generation) allows your AI agents to access custom knowledge bases. Upload documents and let agents search through your organization's proprietary information.

<Info>
  RAG Knowledge requires Admin access. Contact your organization admin to upload documents.
</Info>

<Warning>
  **Model Restriction**: RAG tools use Google Vertex AI Search (VertexAiSearchTool), which is **only compatible with Gemini models**. Agents using Anthropic Claude or other models cannot use RAG tools. Ensure your agent is configured with a Gemini model (e.g., `gemini/gemini-2.5-flash`) when assigning RAG tools.
</Warning>

***

## Supported File Types

| Format     | Extension       | Max Size |
| ---------- | --------------- | -------- |
| Plain Text | .txt            | 10MB     |
| PDF        | .pdf            | 50MB     |
| HTML       | .html, .htm     | 10MB     |
| JSON       | .json           | 10MB     |
| JSONL      | .jsonl, .ndjson | 10MB     |
| Markdown   | .md, .markdown  | 10MB     |
| Word       | .docx           | 50MB     |
| PowerPoint | .pptx           | 10MB     |

***

## Uploading Documents

### Step 1: Access RAG Knowledge

1. Navigate to **Team > RAG Knowledge**
2. You must have Admin access to upload documents

### Step 2: Create a DataStore

1. Click **Create DataStore**
2. Enter a name for your knowledge base
3. Select files to upload

### Step 3: Wait for Indexing

After upload, documents are processed and indexed:

| Status       | Description                           |
| ------------ | ------------------------------------- |
| `pending`    | Waiting to start processing           |
| `uploading`  | Files being uploaded to cloud storage |
| `indexing`   | Documents being processed and indexed |
| `processing` | Processing in progress                |
| `completed`  | Knowledge base ready to use           |
| `failed`     | Processing error (can be retried)     |

<Note>
  Indexing typically takes 1-5 minutes depending on document size and quantity.
</Note>

***

## Using RAG with Agents

Once documents are indexed, they can be assigned to AI agents.

### Admin Configuration

1. Go to **Admin > Agents**
2. Edit an agent
3. In the **RAG Tools** section, select the DataStore
4. Save changes

### How It Works

When a user asks a question:

1. The agent searches the knowledge base
2. Relevant document sections are retrieved
3. The agent uses this context to provide accurate answers

***

## Agent-Generated Documents

Junis agents can **create their own knowledge base entries** using the `upload_rag_document` tool. This enables powerful workflows where agents research, synthesize, and store knowledge for future use.

<Warning>
  **Requires Configuration**: The `upload_rag_document` tool is **not auto-injected**. An admin must explicitly assign this tool to agents via **Admin > Agents > Tools**. Agent-generated documents are always saved as Markdown (`.md`) files — this is distinct from manual uploads which support PDF, DOCX, PPTX, and other formats.
</Warning>

### How It Works

1. Agent generates content (research summaries, analysis reports, processed data)
2. Agent calls `upload_rag_document` with the content
3. Document is automatically uploaded and indexed
4. All agents with access to that DataStore can search the new content

### Example Workflow

```
User: "Research the top 5 competitors in our market and save it
to our knowledge base."

Agent:
1. Searches the web for competitor information
2. Compiles findings into a structured Markdown document
3. Calls upload_rag_document:
   - datastore_name: "Market Research"
   - file_name: "competitor-analysis-march-2026"
   - content: "# Competitor Analysis\n\n## Company A..."
4. Document is indexed and searchable

Next conversation:
User: "What do we know about our competitors?"
Agent: Searches "Market Research" DataStore and retrieves the analysis
```

### Key Features

* **Auto-Create DataStore**: If the named DataStore doesn't exist, it's created automatically
* **Markdown Format**: Content is stored as `.md` files for clean indexing
* **Immediate Indexing**: Documents begin indexing as soon as they're uploaded
* **Cumulative Knowledge**: Agents build an ever-growing knowledge base over time

<Tip>
  **Pro Tip**: Combine `upload_rag_document` with scheduled tasks to automatically research and store information on a recurring basis.
</Tip>

***

## Best Practices

<AccordionGroup>
  <Accordion title="Organize content logically" icon="folder">
    * Group related documents together
    * Use clear, descriptive filenames
    * Remove duplicate content
  </Accordion>

  <Accordion title="Format documents well" icon="file-lines">
    * Use clear headings and structure
    * Break long documents into sections
    * Include context in document titles
  </Accordion>

  <Accordion title="Keep content current" icon="arrows-rotate">
    * Update documents when information changes
    * Remove outdated content
    * Re-index after major updates
  </Accordion>
</AccordionGroup>

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Upload failed">
    **Possible causes:**

    * File type not supported
    * File exceeds size limit
    * Network connection issue

    **Solution:**

    * Check file format and size
    * Try uploading again
    * Contact support if issue persists
  </Accordion>

  <Accordion title="Agent not finding information">
    **Possible causes:**

    * DataStore not assigned to agent
    * Documents not fully indexed
    * Query doesn't match document content

    **Solution:**

    * Verify DataStore is linked to the agent
    * Check indexing status is "ready"
    * Try rephrasing your question
  </Accordion>
</AccordionGroup>

***

## Related Guides

<CardGroup cols={2}>
  <Card title="Agent System" icon="robot" href="/getting-started/agent-system">
    Learn about AI agents
  </Card>

  <Card title="Tools Overview" icon="wrench" href="/guides/tools/overview">
    All available tools including memory and soul
  </Card>

  <Card title="RAG API Reference" icon="code" href="/api-reference/rag">
    Programmatic RAG API access
  </Card>

  <Card title="Credit System" icon="coins" href="/guides/billing/credits">
    Understand usage costs
  </Card>
</CardGroup>
