Skip to main content
Effective debugging is essential for DeerFlow development. This guide covers debugging techniques, logging strategies, common issues, and tools to help troubleshoot problems.

Development Tools

Python Debugger (pdb)

Use Python’s built-in debugger for interactive debugging:
Common pdb commands:

IPython Debugger (ipdb)

More powerful alternative to pdb:
Benefits over pdb:
  • Syntax highlighting
  • Tab completion
  • Better error messages
  • Command history

pytest Debugger Integration

Visual Studio Code Debugging

Create .vscode/launch.json:
Set breakpoints by clicking in the gutter, then press F5 to start debugging.

Logging Strategies

Python Logging

DeerFlow uses Python’s logging module:

Logging Best Practices

Include context in log messages:
Use appropriate log levels:
Log at entry and exit points:

Viewing Logs

Docker Development:
Local Development: Logs appear in the terminal where you started the service:

Log Configuration

Configure logging level:
Or use environment variable:

Common Issues and Solutions

Backend Issues

Issue: Import Errors

Symptom: ModuleNotFoundError or ImportError Causes:
  • Missing dependencies
  • Incorrect PYTHONPATH
  • Circular imports
Solutions:
For circular imports, check backend/tests/conftest.py for mocking patterns.

Issue: Configuration Not Found

Symptom: FileNotFoundError: config.yaml Causes:
  • Config file in wrong location
  • Environment variable not set
Solutions:
Config search order:
  1. Explicit config_path parameter
  2. DEER_FLOW_CONFIG_PATH environment variable
  3. config.yaml in current directory (backend/)
  4. config.yaml in parent directory (project root)

Issue: Model Provider Not Found

Symptom: ModuleNotFoundError: No module named 'langchain_anthropic' Cause: Provider package not installed Solution:
The error message now includes install guidance:

Issue: Sandbox Execution Fails

Symptom: SandboxError or command execution fails Causes:
  • Docker not running (for AIO sandbox)
  • Permission issues
  • Virtual path mapping errors
Debug steps:

Issue: MCP Server Connection Fails

Symptom: MCP tools not available or connection errors Debug steps:
Common fixes:
  • Verify server command is correct
  • Check environment variables are set
  • Ensure server is enabled in config
  • Test server independently

Frontend Issues

Issue: API Connection Fails

Symptom: Frontend can’t reach backend APIs Debug steps:
Solutions:
  • Ensure all services are running
  • Check nginx configuration
  • Verify API base URLs in frontend .env
  • Clear browser cache

Issue: WebSocket/SSE Connection Drops

Symptom: Streaming responses don’t work Causes:
  • Nginx timeout too short
  • Network proxy interfering
  • Browser tab suspended
Solutions: Check nginx timeouts in docker/nginx/nginx.conf:
Test SSE endpoint:

Docker Issues

Issue: Docker Services Won’t Start

Symptom: docker-compose up fails Debug steps:
Solutions:
  • Start Docker Desktop
  • Stop services using required ports
  • Rebuild images: docker-compose build --no-cache
  • Remove old containers: docker-compose down -v

Issue: Hot Reload Not Working

Symptom: Code changes don’t trigger reload Causes:
  • Volume mounting issues
  • File watchers not working
Solutions:

Test Issues

Issue: Tests Fail Locally but Pass in CI

Causes:
  • Environment differences
  • Leftover test artifacts
  • Different Python versions
Solutions:

Issue: Tests Fail Due to Circular Imports

Symptom: ImportError when running tests Solution: Add module mock to backend/tests/conftest.py
See existing mocks in conftest.py for examples.

Debugging Techniques

Simple but effective:
Remember to remove print statements before committing!

Assertion Debugging

Use assertions to verify assumptions:
Assertions help catch bugs early and document expectations.

Logging Debugging

Add temporary debug logs:

Stack Trace Analysis

When errors occur, read the stack trace carefully:
Read from bottom to top:
  1. Bottom: Actual error - directory already exists
  2. Middle: Context - creating directories for sandbox
  3. Top: Entry point - processing agent request

Bisecting Issues

For complex bugs, use binary search:
  1. Identify working state (commit, version)
  2. Identify broken state
  3. Test midpoint
  4. Repeat until you find the breaking change

Rubber Duck Debugging

Explain the problem out loud (to a rubber duck, colleague, or yourself):
  1. Describe what you expect to happen
  2. Describe what actually happens
  3. Walk through the code step by step
  4. Often you’ll spot the issue while explaining!

Performance Debugging

Profiling Python Code

Timing Code Execution

Memory Debugging

Resources