Nanobot - An open-source personal AI assistant from the Data Science Lab at the University of Hong Kong
Nanobot is an ultra-lightweight personal AI assistant open-sourced by the Data Intelligence Laboratory at the University of Hong Kong. With only about 4,000 lines of code, it fully replicates the core functionality of the OpenClaw agent. Nanobot features web search, file operations, and more...
What is Nanobot?
Nanobot is an ultra-lightweight personal AI assistant open-sourced by the Data Intelligence Laboratory at the University of Hong Kong. With only about 4,000 lines of code, it fully replicates the core functionality of the OpenClaw agent. Nanobot possesses capabilities such as web search, file operations, scheduled tasks, and a memory mechanism, supporting scenarios including 24/7 real-time market analysis, full-stack development, schedule management, and personal knowledge bases. Compared to the original 430,000 lines of code, Nanobot achieves the same productivity with 99% less code. Developers can read through the source code in a few hours and quickly understand the underlying logic of AI calling tools and managing memory, making it an ideal choice for learning and customizing agents.
Nanobot's main functions
-
core of intelligent agentsA complete closed loop of autonomous task planning, tool invocation, and multi-turn dialogue is achieved based on a large language model.
-
Information AcquisitionIt integrates a web search interface, supporting real-time retrieval and analysis of external information.
-
File operationsIt provides code reading and writing capabilities as well as file system management capabilities, and can be used to build local personal knowledge bases.
-
Communication IntegrationNative support for Telegram and WhatsApp, enabling cross-platform messaging and remote interaction.
-
Scheduled tasksIt has a built-in Cron-like scheduling system that can automatically execute reminders and tasks according to preset cycles.
-
Memory mechanismA persistent storage scheme is adopted to save the dialogue context to support long-term memory retrieval.
-
Voice interaction: Integrate with Groq Whisper service to enable automatic recognition and transcription of voice messages.
-
Scene templateIt includes four types of ready-to-use application templates: financial analysis, development assistant, schedule management, and knowledge Q&A.
Nanobot's technical principles
-
Minimalist architecture designNanobot breaks down the system into four core modules: the Agent loop is responsible for coordinating the interaction between the large language model and the tools; the memory module implements the persistent storage and retrieval of the dialogue context; the skill loader supports the dynamic expansion of functional components; the message bus uniformly handles internal and external communication routing; and the overall system uses explicit dependency injection to replace the complex abstraction layer.
-
Agent Execution FlowUser input first goes through the Prompt builder to assemble the context, and then is sent to the large language model for reasoning and decision-making. The model autonomously determines the tools to be called and generates execution instructions. After the tools are executed, the results are fed back to the model, and finally the memory state is updated, forming a complete closed loop of "perception-decision-action-learning".
-
Multi-source LLM accessThe system achieves unified routing through OpenRouter, enabling seamless switching between cloud models such as Claude, GPT, and Gemini, while also being compatible with local vLLM deployment solutions, meeting flexible selection needs and supporting data security requirements in private scenarios.
-
Dynamic tool systemAll functions are placed in the form of skill modules.
skills/The directory is automatically loaded at runtime and includes commonly used tools such as code manipulation, network requests, and system commands. Developers can quickly extend custom capabilities by following a unified interface specification. -
Cross-platform communication layerTelegram uses the official Bot API for sending and receiving messages, while WhatsApp uses a web protocol bridging solution. All messages from all channels are standardized through an internal bus and then distributed to the Agent for processing, ensuring a consistent experience across multiple platforms.
Nanobot's project address
- GitHub repository: https://github.com/HKUDS/nanobot
Nanobot application scenarios
-
Real-time financial analysisNanobot can monitor market conditions 24/7 and automatically capture data to generate investment insight reports.
-
Full-stack development assistanceIt supports code writing, debugging, and deployment tasks at any time, acting as a personal technical partner.
-
Intelligent schedule managementNanobot can automatically schedule meetings, send reminders, handle to-do lists, and coordinate personal time management.
-
Personal knowledge baseNanobot supports the integration of private documents such as PDFs and notes, and supports natural language question answering and knowledge retrieval.
-
Remote personal assistantInteract anytime, anywhere via Telegram or WhatsApp, without having to stay in front of a computer.