Skip to main content
Agents can work with files - read documents, write outputs, and manage data.

Quick Start

1

Read Files

import { Agent } from 'praisonai';

const agent = new Agent({
  instructions: 'You analyze documents',
  tools: ['read_file']
});

await agent.chat('Summarize the contents of report.pdf');
// Agent reads and summarizes the file
2

Write Files

const agent = new Agent({
  tools: ['read_file', 'write_file']
});

await agent.chat('Create a summary.txt with key points');
// Agent creates the file

User Interaction Flow


Configuration Levels

// Level 1: Array - Enable file tools
const agent = new Agent({
  tools: ['read_file', 'write_file']
});

// Level 2: String - Allow directory access
const agent = new Agent({
  tools: ['read_file'],
  allowedPaths: './docs/'
});

// Level 3: Dict - Full control
const agent = new Agent({
  files: {
    read: true,
    write: true,
    delete: false,
    allowedPaths: ['./docs/', './output/'],
    maxFileSize: '10MB'
  }
});

File Tools

ToolDescription
read_fileRead file contents
write_fileCreate or update files
list_filesList directory contents
delete_fileRemove files (use carefully)

API Reference

Tools Module

Tools including file operations

Best Practices

Restrict file access to specific directories.
Only enable delete_file when absolutely needed.
Combine with approval for production safety.