nanobot is a small, self-hosted personal AI agent framework written in Python, providing an agent runtime that can operate through a WebUI, terminal, or chat applications. Users use it to connect language models with tools, memory, MCP integrations, scheduled automation, and multi-agent workflows. The catalogue add-ons provide skills and instructions for working with nanobot.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/hkuds/nanobot/agents-mdgit clone --depth 1 https://github.com/HKUDS/nanobotWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/hkuds/nanobot/agents-md)<a href="https://agentmods.dev/instructions/hkuds/nanobot/agents-md"><img src="https://agentmods.dev/badge/instructions/hkuds/nanobot/agents-md.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.01289 | $0.01289 |
| Opus 5 | $0.00645 | $0.00645 |
| Sonnet 5 | $0.00258 | $0.00258 |
| Haiku 4.5 | $0.00129 | $0.00129 |
Grade A, and why
nanobot AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
Copies of this mod
1 near-identical copy found in the catalogue:
- nanobot-render AGENTS.md — 92% identical, 9 lines differ
How it starts
The opening of the file, as written. The whole thing — 87 lines — stays where its author put it; the contents beside it link to each section on GitHub.
This file provides guidance to AI coding agents working with this repository.
Project Overview
nanobot is a lightweight, open-source AI agent framework written in Python with a React/TypeScript WebUI. It centers around a small agent loop that receives messages from chat channels, invokes an LLM provider, executes tools, and manages session memory.
Development Commands
# Python: run single test / lint
pytest tests/test_openai_api.py::test_function -v
ruff check nanobot/
# Strict type checking (matches CI)
uv sync --all-extras --dev
uv run --no-sync python -m scripts.install_channel_dependencies --all-channels
uv run --no-sync basedpyright
# WebUI: dev server (proxies API/WS to gateway :8765), build, test
# Build outputs to ../nanobot/web/dist (bundled into the Python wheel)
cd webui && bun run dev # or NANOBOT_API_URL=... bun run dev
cd webui && bun run build
cd webui && bun run test
# Gateway
nanobot gateway
High-Level Architecture
Core Data Flow
Messages flow through an async MessageBus (nanobot/bus/queue.py) that decouples chat channels from the agent core:
- Channels (
nanobot/channels/) receive messages from external platforms and publishInboundMessageevents to the bus. AgentLoop(nanobot/agent/loop.py) consumes inbound messages, builds context, and coordinates the turn.AgentRunner(nanobot/agent/runner.py) handles the actual LLM conversation loop: send messages to the provider, receive tool calls, execute tools, and stream responses.- Responses are published as
OutboundMessageevents back to the appropriate channel.
Key Subsystems
- Agent Loop (
nanobot/agent/loop.py,runner.py): The core processing engine.AgentLoopmanages session keys, hooks, and context building.AgentRunnerexecutes the multi-turn LLM conversation with tool execution. - LLM Providers (
nanobot/providers/): Provider implementations (Anthropic, OpenAI-compatible, OpenAI Responses API, Azure, Bedrock, GitHub Copilot, OpenAI Codex, etc.) built on a common base (base.py). Includes image generation (image_generation.py) and audio transcription (transcription.py).factory.pyandregistry.pyhandle instantiation and model discovery. - Channels (
nanobot/channels/): Platform integrations (Telegram, Discord, Slack, Feishu, Matrix, WhatsApp, QQ, WeChat, WeCom, DingTalk, Email, MoChat, MS Teams, WebSocket, Mattermost).manager.pydiscovers and coordinates them. Channels are self-contained packages auto-discovered viapkgutilscanning. - Tools (
nanobot/agent/tools/): Agent capabilities exposed to the LLM: filesystem (read/write/edit/list), shell execution (with sandbox backends), web search/fetch, MCP servers, cron, notebook editing, subagent spawning, long-running tasks / sustained goals (long_task.py), image generation, and self-modification. Tools are auto-discovered viapkgutilscan + entry-point plugins. - Memory (
nanobot/agent/memory.py): Session history persistence with Dream two-phase memory consolidation. Uses atomic writes with fsync for durability. - Session Management (
nanobot/session/): Per-session history, context compaction, TTL-based auto-compaction (manager.py), and sustained goal state tracking (goal_state.py). - Config (
nanobot/config/schema.py,loader.py): Pydantic-based configuration loaded from~/.nanobot/config.json. Supports camelCase aliases for JSON compatibility. - WebUI (
webui/): Vite-based React SPA that talks to the gateway over a WebSocket multiplex protocol. The dev server proxies/api,/webui,/auth, and WebSocket traffic to the gateway. - API Server (
nanobot/api/server.py): OpenAI-compatible HTTP API (/v1/chat/completions,/v1/models) for programmatic access. - Command Router (
nanobot/command/): Slash command routing and built-in command handlers. - Heartbeat (
nanobot/templates/HEARTBEAT.md): Periodic task list checked viacronjobs (legacy dedicated service removed). - Pairing (
nanobot/pairing/): DM sender approval store with persistent pairing codes per channel. - Skills (
nanobot/skills/): Built-in skill definitions (cron, github, image-generation, etc.) loaded into agent context. - Security (
nanobot/security/): PTH file guard and other security measures activated at CLI entry.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 87 lines · 1,289 tokens per session scan A 6a0ffce3086f
nanobot AGENTS.md is an instructions file published in the GitHub repository HKUDS/nanobot (47,620 stars, last pushed 2d ago), licensed MIT. It adds 1,289 tokens to every session, about $0.0064 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other instructions, from other repositories
openfang AGENTS.md
AGENTS.md instructions for RightNow-AI/openfang, a project described as: Open-source Agent Operating System.
lobu AGENTS.md
Instructions for lobu-ai/lobu, covering repo map, unrecoverable — never do these, facts you cannot derive, ship a change and how to work.
HARTOS CLAUDE.md
Instructions for hertz-ai/HARTOS, covering claude.md, project overview, master key - ai exclusion zone, branch discipline — main branch only (mandatory) and sibling repos — canonical filesystem paths.
lobu CLAUDE.md
Instructions for lobu-ai/lobu, a project described as: Open-source control plane and runtime for organisational agents: shared company context, isolated execution, approvals and MCP.
progressive-agent CLAUDE.md
Instructions for Rayan55050/progressive-agent, covering progressive agent, что это, текущая фаза: v1.0.0 — open source release, стек and ключевые архитектурные решения.
AgenticX AGENTS.md
Instructions for DemonDamon/AgenticX, covering agents.md, learned user preferences and learned workspace facts.