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
API Endpoints
Upload Files
files: One or more files
List Files
Delete File
Using the Upload API
- curl
- Python
- JavaScript/TypeScript
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
TheUploadsMiddleware automatically injects uploaded files into every agent request:
Reading Uploaded Files
The agent can read files using theread_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}.mdHandling 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
File Size Limit
File Size Limit
Default: 100 MB per fileConfigure in nginx:
File Name Security
File Name Security
- Path traversal prevented (no
../in filenames) - Special characters sanitized
- Filenames normalized
Thread Isolation
Thread Isolation
- Each thread has separate upload directory
- Cross-thread access blocked
- Files deleted when thread is deleted
Supported Conversions
Supported Conversions
- 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 endpointsUploads Middleware
src/agents/middlewares/uploads_middleware.pyInjects file list into agentArtifacts Router
src/gateway/routers/artifacts.pyServes files to frontendDependencies
pyproject.toml
Troubleshooting
Upload fails with 413 error
Upload fails with 413 error
File exceeds size limit. Increase in nginx config:Restart nginx:
docker/nginx/nginx.conf
Conversion fails silently
Conversion fails silently
Check Gateway logs:Verify markitdown is installed:
Agent can't see uploaded files
Agent can't see uploaded files
Verify:
- Files uploaded successfully (check response)
- UploadsMiddleware is registered in agent
- Thread ID matches between upload and agent
- Files exist in filesystem:
Files not accessible in sandbox
Files not accessible in sandbox
For non-local sandbox:
- Ensure sandbox is running
- Check mount configuration
- Verify thread_id matches
- Check sandbox logs
Best Practices
-
Validate Files Client-Side
-
Show Upload Progress
-
Display File List
-
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