Operations Runbook
Installation
From Source (recommended for development)
git clone https://github.com/HKUDS/nanobot.git
cd nanobot
pip install -e .
From PyPI
pip install nanobot-ai
With uv
uv tool install nanobot-ai
With Matrix Support
pip install nanobot-ai[matrix]
First-Time Setup
# 1. Initialize config and workspace
nanobot onboard
# 2. Edit config to add API keys
# macOS/Linux:
vim ~/.nanobot/config.json
# Or use any editor
# 3. Verify setup
nanobot status
# 4. Test with a message
nanobot agent -m "Hello!"
Minimum Viable Config
{
"providers": {
"openrouter": {
"apiKey": "sk-or-v1-your-key-here"
}
}
}
Running
CLI Mode (Interactive)
nanobot agent # Interactive REPL
nanobot agent -m "Hello" # Single message
nanobot agent --no-markdown # Plain text output
nanobot agent --logs # Show debug logs
Gateway Mode (Daemon)
nanobot gateway # Foreground
Docker
# Build
docker build -t nanobot .
# First-time setup
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot onboard
# Run gateway
docker run -v ~/.nanobot:/root/.nanobot -p 18790:18790 nanobot gateway
# Single command
docker run -v ~/.nanobot:/root/.nanobot --rm nanobot agent -m "Hello!"
Docker Compose
docker compose run --rm nanobot-cli onboard # First-time setup
docker compose up -d nanobot-gateway # Start gateway
docker compose logs -f nanobot-gateway # View logs
docker compose down # Stop
systemd User Service (Linux)
Create ~/.config/systemd/user/nanobot-gateway.service:
[Unit]
Description=Nanobot Gateway
After=network.target
[Service]
Type=simple
ExecStart=%h/.local/bin/nanobot gateway
Restart=always
RestartSec=10
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=%h
[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now nanobot-gateway
loginctl enable-linger $USER # Keep running after logout
Common Operations
Check Status
nanobot status
Shows: configured providers, enabled channels, workspace path, model selection.
Reset a Session
Delete the session file:
rm ~/.nanobot/workspace/sessions/telegram_12345.jsonl
Or clear all sessions:
rm ~/.nanobot/workspace/sessions/*.jsonl
View Memory
cat ~/.nanobot/workspace/memory/MEMORY.md # Long-term facts
cat ~/.nanobot/workspace/memory/HISTORY.md # Chronological log
Edit Heartbeat Tasks
vim ~/.nanobot/workspace/HEARTBEAT.md
Format:
## Periodic Tasks
- [ ] Check weather forecast and send a summary
- [ ] Scan inbox for urgent emails
Add/Update Provider Credentials
Edit ~/.nanobot/config.json and restart:
vim ~/.nanobot/config.json
# If running as systemd service:
systemctl --user restart nanobot-gateway
OAuth Provider Login
nanobot provider login openai-codex
nanobot provider login github-copilot
WhatsApp QR Code Setup
# Terminal 1: start WhatsApp bridge
nanobot channels login
# Terminal 2: start gateway
nanobot gateway
Troubleshooting
Problem: “No provider configured”
Symptoms: nanobot agent returns an error about no API key.
Solution:
Run
nanobot statusto check provider configurationEnsure at least one provider has a valid
apiKeyin~/.nanobot/config.jsonCheck the model name matches a configured provider
Problem: “Access denied for sender”
Symptoms: Bot ignores messages from a chat platform.
Solution:
Check the
allowFromlist in the channel configAdd the sender’s ID to
allowFromUse
["*"]to allow all senders (for testing only)Check the logs for the actual sender ID being rejected
Problem: Channel fails to connect
Symptoms: “Channel not available” in logs.
Solution:
Check that the channel SDK is installed (some are optional)
Verify credentials (bot token, app secret, etc.)
Check network connectivity and proxy settings
For WebSocket channels (Feishu, DingTalk, Slack): ensure firewall allows outbound WebSocket
Problem: Tool execution failures
Symptoms: Agent reports tool errors.
Solution:
If workspace-restricted (
restrictToWorkspace: true), ensure the file/command is within~/.nanobot/workspace/For shell commands: check
tools.exec.timeout(default: 60s)For MCP tools: check
toolTimeouton the MCP server config (default: 30s)Check file permissions
Problem: Memory/session corruption
Symptoms: Garbled responses, repeated context, or “tool_call_id not found” errors.
Solution:
Delete the affected session file:
rm ~/.nanobot/workspace/sessions/{key}.jsonlMemory files can be manually edited:
~/.nanobot/workspace/memory/MEMORY.mdRestart the gateway
Problem: High memory usage
Symptoms: Python process consuming excessive RAM.
Solution:
Lower
agents.defaults.memory_window(default: 100) to consolidate more aggressivelyDelete old session files
Reduce
agents.defaults.max_tool_iterations(default: 40)
Configuration Reference
Environment Variables
The config supports environment variable overrides with prefix NANOBOT_ and nested delimiter __:
export NANOBOT_AGENTS__DEFAULTS__MODEL="openai/gpt-4o"
export NANOBOT_PROVIDERS__OPENAI__API_KEY="sk-xxx"
Key Configuration Paths
Setting |
Path in JSON |
Default |
Description |
|---|---|---|---|
Model |
|
|
LLM model identifier |
Provider |
|
|
Provider name or |
Max tokens |
|
|
Max response tokens |
Temperature |
|
|
Sampling temperature |
Workspace |
|
|
Working directory |
Memory window |
|
|
Messages before consolidation |
Tool iterations |
|
|
Max tool call rounds |
Workspace sandbox |
|
|
Sandbox all tools |
Shell timeout |
|
|
Shell command timeout (seconds) |
Heartbeat interval |
|
|
Heartbeat wake-up interval (seconds) |
Progress streaming |
|
|
Stream partial responses |
Monitoring
Log Output
CLI mode: logs to stderr (visible with
--logsflag)Gateway mode: logs to stderr (pipe to file or use journalctl for systemd)
Docker:
docker compose logs -f nanobot-gatewaysystemd:
journalctl --user -u nanobot-gateway -f
Health Indicators
Gateway process is running
Channels show “enabled” in
nanobot statusHeartbeat fires every 30 minutes (visible in logs)
Session files are being updated (check timestamps)
Backup & Recovery
What to Back Up
Path |
Priority |
Content |
|---|---|---|
|
Critical |
All credentials and settings |
|
High |
Long-term memory and history |
|
Medium |
Conversation history |
|
Medium |
Custom user skills |
|
Low |
Periodic task definitions |
Recovery
Reinstall nanobot
Restore
~/.nanobot/config.jsonRestore
~/.nanobot/workspace/directoryRun
nanobot statusto verify