Source Code:
src/gaia/agents/chat/agent.pyComponent: ChatAgent - Reference Conversational AI Implementation
Module:
gaia.agents.chat.agent
Inherits: Agent, RAGToolsMixin, FileToolsMixin, ShellToolsMixin, FileSearchToolsMixin, FileIOToolsMixin, VLMToolsMixin, ScreenshotToolsMixin, SDToolsMixin, MCPClientMixinUpcoming rename (v0.20.0):ChatAgentwill be renamed toGaiaAgentas 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
-
RAG System
- Index documents (PDF, TXT, MD, code files)
- Query indexed documents
- File-specific queries
- Adaptive chunk retrieval
- Semantic/heuristic chunking
-
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
-
Shell Integration
- Execute shell commands safely
- Capture stdout/stderr
- Timeout management
-
Session Management
- Create/load/save sessions
- Persist conversation history
- Track indexed documents
- Auto-save after operations
Non-Functional Requirements
-
Security
- Path validation (no path traversal)
- Symlink protection (O_NOFOLLOW)
- Configurable allowed paths
- No arbitrary code execution
-
Performance
- File search: Phase 1 (fast) → Phase 2 (deep)
- Debounced file change detection
- LRU cache for file monitoring
- Streaming for large queries
-
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):Implementation Details
Smart Discovery Workflow
User asks domain-specific question without indexed docs: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
Example 3: Multi-Drive File Search
Related Specifications
- agent-base - Base Agent architecture
- database-mixin - DatabaseMixin for persistence
- tool-decorator - Tool registration system
ChatAgent Technical Specification