Live development without restarts
Modify DevDuck's code while it's running. Changes apply instantly without losing context. Protected during agent execution.
DevDuck watches its own source file and automatically reloads when changes are detected.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Hot Reload System β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β β β File Watcher Thread β β β β β βββ Every 1 second: β β β βββ Check devduck/__init__.py mtime β β β β β βββ Change Detected? β β β β β β β βββ Agent Executing? β β β β βββ Set _reload_pending = True β β β β βββ Wait for agent to finish β β β β β β β βββ Agent Idle? β β β βββ Trigger os.execv() β Full Process Restart β β β β β βββ 3 second debounce to prevent rapid reloads β β β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Hot reload never interrupts a running agent. When code changes are detected during execution:
_reload_pending flag is setCreate new tools by saving .py files to the ./tools/ directory.
# Create ./tools/my_tool.py
from strands import tool
@tool
def my_custom_tool(param: str) -> dict:
"""My custom tool description."""
return {
"status": "success",
"content": [{"text": f"Processed: {param}"}]
}
# Save the file β Tool is immediately available!
# No restart needed
# Disable auto-loading tools from ./tools/ directory
export DEVDUCK_LOAD_TOOLS_FROM_DIR=false
devduck
Background thread monitors source file every second for changes.
3-second debounce prevents rapid reloads during file saves.
Never interrupts running agentβwaits for completion.
Uses os.execv() for clean process restart with fresh code.
Drop .py files in ./tools/ for instant tool availability.
Check watcher status via devduck.status()["file_watcher"].
import devduck
# Check file watcher status
status = devduck.status()
print(status["file_watcher"])
# {
# "enabled": True,
# "watching": "/path/to/devduck/__init__.py"
# }
# Manually trigger hot reload
devduck.hot_reload()
# Full restart (re-initializes everything)
devduck.restart()
| Variable | Default | Description |
|---|---|---|
DEVDUCK_LOAD_TOOLS_FROM_DIR |
true | Auto-load tools from ./tools/ directory |