
自定义最小AI代理,具备持久内存、MCP工具和Discord
概览
一个定制的最小AI代理,具备持久内存、MCP工具集成、Discord/CLI接口和结构化可观察性。完全运行于本地硬件——无云API成本。 我们评估了现有的代理框架,并全部拒绝了: - : 40万行代码,4.2万个暴露实例在Shodan上。太大无法审计,太大无法信任。- : 评估时已有9天历史。太不成熟。- : 内容过于薄弱——大部分都需要重建。 核心需求(内存、工具、聊天、日志)都是单独解决的问题。不需要40万线的框架。 所有LLM流量都通过一个带有可配置端点URL的LLMClient。目前它指向localhost:8001(llama-server)。若要后续插入AI防火墙,只需将URL改为localhost:9000——无需任何代码更改。 Luna 自动处理推理模型(Qwen 3.5 等)——提取reasoning_content,内容空时回退到清理后的推理,并剔除泄漏的标记(如 、 等)。
概述(AI 翻译)
月球特工
一个自定义的最小AI代理,具备持久内存、MCP工具集成、Discord/CLI接口和结构化可观察性。 完全运行在本地硬件上——无需云API费用。
~2300行Python。没有框架。
为什么是习俗
我们评估了现有的代理框架,并全部拒绝了:
- OpenClaw:40万行代码,4.2万个暴露实例在Shodan上。太大无法审计,太大无法信任。
- 零爪:评估时9天大。太幼稚了。
- 纳米爪:太薄了——反正大部分都得重建。
核心需求(内存、工具、聊天、日志)都是单独解决的问题。不需要40万线的框架。
建筑
所有LLM流量都经过一个带有可配置端点URL的单一LLMClient。如今它指向localhost:8001(llama-server)。若要后续插入AI防火墙,只需将URL改为localhost:9000——无需任何代码更改。
思考模型支持: Luna 自动处理推理模型(Qwen3.5 等)——提取 reasoning_content,内容空时回退到清理推理,并从输出中剔除泄漏的标记( 、 等)。
硬件
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Luna Agent
A custom minimal AI agent with persistent memory, MCP tool integration, Discord/CLI interface, and structured observability. Runs entirely on local hardware — no cloud API costs.
~2300 lines of Python. No frameworks.
Why Custom
We evaluated existing agent frameworks and rejected them all:
- OpenClaw: 400K lines of code, 42K exposed instances on Shodan. Too large to audit, too large to trust.
- ZeroClaw: 9 days old at time of evaluation. Too immature.
- NanoClaw: Too thin — would need to rebuild most of it anyway.
The core needs (memory, tools, chat, logging) are individually well-solved problems. No 400K-line framework needed.
Architecture
Discord (discord.py) CLI REPL (no token)
| |
v v
+---------------------------------+
| Luna Agent Core |
| |
| agent.py | agent loop: msg → memory → prompt → LLM → tools → respond
| ├── llm.py | single LLM client, configurable endpoint
| ├── memory.py | SQLite + FTS5 + sqlite-vec hybrid search
| ├── tools.py | native tools: bash, files, web, delegate, code_task
| ├── tool_output.py | smart output pipeline for large results
| ├── mcp_manager.py | MCP client for community tool servers
| └── observe.py | structured JSON logging
| |
+---------------------------------+
|
v
llama-server Qwen3.5-35B-A3B on 2x RTX 3090
All LLM traffic flows through a single LLMClient with a configurable endpoint URL. Today it points at localhost:8001 (llama-server). To insert an AI firewall later, change the URL to localhost:9000 — zero code changes required.
Thinking model support: Luna handles reasoning models (Qwen3.5, etc.) automatically — extracting reasoning_content, falling back to cleaned reasoning when content is empty, and stripping leaked markup (, , etc.) from output.
Hardware
- Intel i7-13700K, 64GB DDR4
- 2x NVIDIA RTX 3090 (24GB each, 48GB total)
- Qwen3.5-35B-A3B Q8_0 via llama-server with layer split across both GPUs
- 131K context window, Q8_0 KV cache
Quick Start
安装
npx -y @playwright/mcp