Skip to main content

Overview

DeerFlow provides complete file upload functionality with automatic document conversion and thread isolation. Users can upload files during conversations, and the agent automatically accesses and processes them.

Features

Multi-file Upload

Upload multiple files simultaneously

Auto Conversion

Automatic PDF and Office document to Markdown conversion

Thread Isolation

Files stored in thread-specific directories

Agent Awareness

Agent automatically sees uploaded files

Supported File Formats

These formats are automatically converted to Markdown:
  • PDF: .pdf
  • PowerPoint: .ppt, .pptx
  • Excel: .xls, .xlsx
  • Word: .doc, .docx
Other file types are stored as-is and can be accessed by the agent.

API Endpoints

Upload Files

Request:
  • files: One or more files
Response:

List Files

Response:

Delete File

Response:

Using the Upload API

Path Mapping

Files are stored with three different path representations:
1

Physical Path

Actual location on the filesystem:
2

Virtual Path (Agent)

Path used by the agent in sandbox:
The agent reads files using this path:
3

Artifact URL (Frontend)

HTTP URL for frontend access:

File Storage Structure

Each thread has its own isolated upload directory. Files cannot be accessed across threads.

Agent Integration

Automatic File Listing

The UploadsMiddleware automatically injects uploaded files into every agent request:

Reading Uploaded Files

The agent can read files using the read_file tool:
Reading the Markdown version (.md) is recommended as it provides text content the agent can process.

Document Conversion

DeerFlow uses markitdown to convert documents:

Conversion Process

1

Upload

File uploaded via POST request
2

Storage

Original file saved to uploads directory
3

Detection

File extension checked against supported formats
4

Conversion

Document converted to Markdown using markitdown
5

Save Markdown

Converted file saved as {filename}.md

Handling Conversion Failures

If conversion fails:
  • Original file is still saved
  • Error logged but not returned to user
  • Agent can still access original file
  • No Markdown file created

Frontend Integration

Implement file upload in your UI:
components/FileUpload.tsx

Limits and Restrictions

Default: 100 MB per fileConfigure in nginx:
  • Path traversal prevented (no ../ in filenames)
  • Special characters sanitized
  • Filenames normalized
  • Each thread has separate upload directory
  • Cross-thread access blocked
  • Files deleted when thread is deleted
  • PDF: ✅ Text extraction, images as placeholders
  • Office (docx, xlsx, pptx): ✅ Full text extraction
  • Images: ❌ No automatic OCR (consider adding)
  • Archives (zip): ❌ No automatic extraction

Implementation Details

Components

Upload Router

src/gateway/routers/uploads.pyHandles HTTP endpoints

Uploads Middleware

src/agents/middlewares/uploads_middleware.pyInjects file list into agent

Artifacts Router

src/gateway/routers/artifacts.pyServes files to frontend

Dependencies

pyproject.toml

Troubleshooting

File exceeds size limit. Increase in nginx config:
docker/nginx/nginx.conf
Restart nginx:
Check Gateway logs:
Verify markitdown is installed:
Verify:
  1. Files uploaded successfully (check response)
  2. UploadsMiddleware is registered in agent
  3. Thread ID matches between upload and agent
  4. Files exist in filesystem:
For non-local sandbox:
  • Ensure sandbox is running
  • Check mount configuration
  • Verify thread_id matches
  • Check sandbox logs

Best Practices

  1. Validate Files Client-Side
  2. Show Upload Progress
  3. Display File List
  4. Handle Errors Gracefully

Next Steps

Custom Tools

Create tools that process uploaded files

Creating Skills

Build skills that work with documents

API Reference

Complete upload API documentation

Configuration

Configure file handling settings