Development Tools
Python Debugger (pdb)
Use Python’s built-in debugger for interactive debugging:IPython Debugger (ipdb)
More powerful alternative to pdb:- Syntax highlighting
- Tab completion
- Better error messages
- Command history
pytest Debugger Integration
Visual Studio Code Debugging
Create.vscode/launch.json:
Logging Strategies
Python Logging
DeerFlow uses Python’slogging module:
Logging Best Practices
Include context in log messages:Viewing Logs
Docker Development:Log Configuration
Configure logging level:Common Issues and Solutions
Backend Issues
Issue: Import Errors
Symptom:ModuleNotFoundError or ImportError
Causes:
- Missing dependencies
- Incorrect PYTHONPATH
- Circular imports
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
- Explicit
config_pathparameter DEER_FLOW_CONFIG_PATHenvironment variableconfig.yamlin current directory (backend/)config.yamlin parent directory (project root)
Issue: Model Provider Not Found
Symptom:ModuleNotFoundError: No module named 'langchain_anthropic'
Cause: Provider package not installed
Solution:
Issue: Sandbox Execution Fails
Symptom:SandboxError or command execution fails
Causes:
- Docker not running (for AIO sandbox)
- Permission issues
- Virtual path mapping errors
Issue: MCP Server Connection Fails
Symptom: MCP tools not available or connection errors Debug steps:- 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:- 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
docker/nginx/nginx.conf:
Docker Issues
Issue: Docker Services Won’t Start
Symptom:docker-compose up fails
Debug steps:
- 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
Test Issues
Issue: Tests Fail Locally but Pass in CI
Causes:- Environment differences
- Leftover test artifacts
- Different Python versions
Issue: Tests Fail Due to Circular Imports
Symptom:ImportError when running tests
Solution: Add module mock to backend/tests/conftest.py
Debugging Techniques
Print Debugging
Simple but effective:Assertion Debugging
Use assertions to verify assumptions:Logging Debugging
Add temporary debug logs:Stack Trace Analysis
When errors occur, read the stack trace carefully:- Bottom: Actual error - directory already exists
- Middle: Context - creating directories for sandbox
- Top: Entry point - processing agent request
Bisecting Issues
For complex bugs, use binary search:- Identify working state (commit, version)
- Identify broken state
- Test midpoint
- Repeat until you find the breaking change
Rubber Duck Debugging
Explain the problem out loud (to a rubber duck, colleague, or yourself):- Describe what you expect to happen
- Describe what actually happens
- Walk through the code step by step
- Often you’ll spot the issue while explaining!