Skip to main content
The direct OpenAI and LiteLLM provider adapters have been removed. Any use_chatgpt field shown below is a migration-error shim: setting it to True raises before inference. Use the Lemonade gateway path.
Component: ChatAgent - Reference Conversational AI Implementation Module: gaia_agent_chat.agent Inherits: Agent, RAGToolsMixin, FileToolsMixin, ShellToolsMixin, FileSearchToolsMixin, FileIOToolsMixin, VLMToolsMixin, ScreenshotToolsMixin, SDToolsMixin, MCPClientMixin
Status: ChatAgent is the base class GaiaAgent extends, not an agent you pick. Its chat / doc / file registrations are hidden — still resolvable by id, so stored sessions and eval scenarios keep working, but absent from the Agent UI picker and the Hub catalog. New work should target the flagship.

Overview

ChatAgent is GAIA’s reference implementation for conversational AI with document Q&A (RAG), file operations, and shell command execution. It is the foundation the flagship GaiaAgent builds on — read this page to understand what the flagship inherits, not to choose an agent. Key Features:
  • Document Q&A using RAG (Retrieval-Augmented Generation)
  • Automatic file indexing with file system monitoring
  • Multi-drive file search (intelligent phase-based search)
  • Shell command execution
  • Session persistence with auto-save
  • Security: Path validation, symlink protection

Requirements

Functional Requirements

  1. RAG System
    • Index documents (PDF, TXT, MD, code files)
    • Query indexed documents
    • File-specific queries
    • Adaptive chunk retrieval
    • Semantic/heuristic chunking
  2. File Operations
    • Search files across drives (phase-based: fast → thorough)
    • Search directories
    • Read/write files with security validation
    • Directory monitoring (watchdog)
    • Auto-reindexing on file changes
  3. Shell Integration
    • Execute shell commands safely
    • Capture stdout/stderr
    • Timeout management
  4. Session Management
    • Create/load/save sessions
    • Persist conversation history
    • Track indexed documents
    • Auto-save after operations

Non-Functional Requirements

  1. Security
    • Path validation (no path traversal)
    • Symlink protection (O_NOFOLLOW)
    • Configurable allowed paths
    • No arbitrary code execution
  2. Performance
    • File search: Phase 1 (fast) → Phase 2 (deep)
    • Debounced file change detection
    • LRU cache for file monitoring
    • Streaming for large queries
  3. Usability
    • Context inference (single doc auto-query)
    • Smart discovery (find+index workflow)
    • Progress indicators
    • Clear error messages

API Specification

ChatAgentConfig

Public API

Tool Examples

RAG Tools (from RAGToolsMixin):
File Tools (from FileSearchToolsMixin):
Shell Tools (from ShellToolsMixin):

Implementation Details

Smart Discovery Workflow

User asks domain-specific question without indexed docs:
Example:

File Change Monitoring

Each watched directory gets a FileChangeHandler from gaia.utils.file_watcher (see the file change handler spec), with reindex_file as its created and modified callback. It watches the handler’s default extensions: .pdf, .txt, .md, .markdown, .rst, .log, .csv, .json, .xml, .yaml, .yml, .py, .js, .ts, .java, .cpp, .c, .html and .css (see default extensions). Word, PowerPoint and Excel files are not watched.
  • A created or modified file is reindexed once it has gone a full window (debounce_seconds, 2 s by default) with no change in size or modification time, so a file still being copied in is never indexed half-written.
  • On Windows, if another program holds the file exclusively or has locked part of it, reindex_file raises PermissionError and the watcher retries the file 1, 2 and 4 windows later. A file saved by renaming a temp file onto it is retried the same way. After the third retry it gives up and logs one error telling the user to close the program and save the file again.
  • A deleted file is removed from the index, and a moved file is removed under its old path and indexed under its new one.

Security: Path Validation

Prevents TOCTOU attacks using O_NOFOLLOW:

Testing Requirements

Unit Tests


Dependencies


Usage Examples

Example 1: Basic Chat with RAG

Example 2: File Monitoring



ChatAgent Technical Specification