Skip to main content
Component: ChatAgent - Reference Conversational AI Implementation Module: gaia_agent_chat.agent Inherits: Agent, RAGToolsMixin, FileToolsMixin, ShellToolsMixin, FileSearchToolsMixin, FileIOToolsMixin, VLMToolsMixin, ScreenshotToolsMixin, SDToolsMixin, MCPClientMixin
Upcoming rename (v0.20.0): ChatAgent will be renamed to GaiaAgent as part of the broader branding update (#696). The import path and class name will change; all other behavior remains the same.

Overview

ChatAgent is GAIA’s reference implementation for conversational AI with document Q&A (RAG), file operations, and shell command execution. It demonstrates best practices for agent development and serves as the foundation for specialized agents. 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

Implementation:

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