Source Code:
hub/agents/chat/python/gaia_agent_chat/agent.pyComponent: ChatAgent - Reference Conversational AI Implementation
Module:
gaia_agent_chat.agent
Inherits: Agent, RAGToolsMixin, FileToolsMixin, ShellToolsMixin, FileSearchToolsMixin, FileIOToolsMixin, VLMToolsMixin, ScreenshotToolsMixin, SDToolsMixin, MCPClientMixinStatus: ChatAgent is the base class GaiaAgent extends, not an agent you pick. Itschat/doc/fileregistrations arehidden— 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
-
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
Each watched directory gets aFileChangeHandler 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_fileraisesPermissionErrorand 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
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