lsdefine/GenericAgent
GitHub: lsdefine/GenericAgent
一个极简、可自我进化的自主 Agent 框架,用约 3K 行代码和 9 个原子工具赋予 LLM 系统级控制与持续学习的能力。
Stars: 2324 | Forks: 281
|
|
| *"Order me a milk tea"* — Navigates the delivery app, selects items, and completes checkout automatically. | *"Find GEM stocks with EXPMA golden cross, turnover > 5%"* — Screens stocks with quantitative conditions. |
| 🌐 Autonomous Web Exploration | 💰 Expense Tracking | 💬 Batch Messaging |
|
|
|
|
| Autonomously browses and periodically summarizes web content. | *"Find expenses over ¥2K in the last 3 months"* — Drives Alipay via ADB. | Sends bulk WeChat messages, fully driving the WeChat client. |
## 📅 最新新闻
- **2026-04-11:** Introduced **L4 session archive memory** and scheduler cron integration
- **2026-03-23:** Support personal WeChat as a bot frontend
- **2026-03-10:** [Released million-scale Skill Library](https://mp.weixin.qq.com/s/q2gQ7YvWoiAcwxzaiwpuiQ?scene=1&click_id=7)
- **2026-03-08:** [Released "Dintal Claw" — a GenericAgent-powered government affairs bot](https://mp.weixin.qq.com/s/eiEhwo-j6S-WpLxgBnNxBg)
- **2026-03-01:** [GenericAgent featured by Jiqizhixin (机器之心)](https://mp.weixin.qq.com/s/uVWpTTF5I1yzAENV_qm7yg)
- **2026-01-16:** GenericAgent V1.0 public release
## 🚀 快速开始
#### 方法 1:标准安装
```
# 1. 克隆仓库
git clone https://github.com/lsdefine/GenericAgent.git
cd GenericAgent
# 2. 安装最小依赖
pip install streamlit pywebview
# 3. 配置 API 密钥
cp mykey_template.py mykey.py
# 编辑 mykey.py 并填写您的 LLM API 密钥
# 4. 启动
python launch.pyw
```
Full guide: [GETTING_STARTED.md](GETTING_STARTED.md)
## 🤖 机器人接口(可选)
### Telegram 机器人
```
# mykey.py
tg_bot_token = 'YOUR_BOT_TOKEN'
tg_allowed_users = [YOUR_USER_ID]
```
```
python frontends/tgapp.py
```
### 替代应用前端
Besides the default Streamlit web UI, you can also try other frontend styles:
```
python frontends/qtapp.py # Qt-based desktop app
streamlit run frontends/stapp2.py # Alternative Streamlit UI
```
## 📊 与类似工具的比较
| Feature | GenericAgent | OpenClaw | Claude Code |
|------|:---:|:---:|:---:|
| **Codebase** | ~3K lines | ~530,000 lines | Open-sourced (large) |
| **Deployment** | `pip install` + API Key | Multi-service orchestration | CLI + subscription |
| **Browser Control** | Real browser (session preserved) | Sandbox / headless browser | Via MCP plugin |
| **OS Control** | Mouse/kbd, vision, ADB | Multi-agent delegation | File + terminal |
| **Self-Evolution** | Autonomous skill growth | Plugin ecosystem | Stateless between sessions |
| **Out of the Box** | A few core files + starter skills | Hundreds of modules | Rich CLI toolset |
## 🧠 工作原理
GenericAgent accomplishes complex tasks through **Layered Memory × Minimal Toolset × Autonomous Execution Loop**, continuously accumulating experience during execution.
1️⃣ **Layered Memory System**
- **L0 — Meta Rules**: Core behavioral rules and system constraints of the agent
- **L1 — Insight Index**: Minimal memory index for fast routing and recall
- **L2 — Global Facts**: Stable knowledge accumulated over long-term operation
- **L3 — Task Skills / SOPs**: Reusable workflows for completing specific task types
- **L4 — Session Archive**: Archived task records distilled from finished sessions for long-horizon recall
2️⃣ **Autonomous Execution Loop**
The entire core loop is just **~100 lines of code** (`agent_loop.py`).
3️⃣ **Minimal Toolset**
| Tool | Function |
|------|------|
| `code_run` | Execute arbitrary code |
| `file_read` | Read files |
| `file_write` | Write files |
| `file_patch` | Patch / modify files |
| `web_scan` | Perceive web content |
| `web_execute_js` | Control browser behavior |
| `ask_user` | Human-in-the-loop confirmation |
4️⃣ **Capability Extension Mechanism**
Via `code_run`, GenericAgent can dynamically install Python packages, write new scripts, call external APIs, or control hardware at runtime — crystallizing temporary abilities into permanent tools.
GenericAgent Workflow Diagram
|
|
| *"Order me a milk tea"* — 自动导航外卖 App,选品并完成结账 | *"Find GEM stocks with EXPMA golden cross, turnover > 5%"* — 量化条件筛股 |
| 🌐 自主网页探索 | 💰 支出追踪 | 💬 批量消息 |
|
|
|
|
| 自主浏览并定时汇总网页信息 | *"查找近 3 个月超 ¥2K 的支出"* — 通过 ADB 驱动支付宝 | 批量发送微信消息,完整驱动微信客户端 |
## 📅 最新动态
- **2026-04-11:** 引入 **L4 会话归档记忆**,并接入 scheduler cron 调度
- **2026-03-23:** 支持个人微信接入作为 Bot 前端
- **2026-03-10:** [发布百万级 Skill 库](https://mp.weixin.qq.com/s/q2gQ7YvWoiAcwxzaiwpuiQ?scene=1&click_id=7)
- **2026-03-08:** [发布以 GenericAgent 为核心的"政务龙虾" Dintal Claw](https://mp.weixin.qq.com/s/eiEhwo-j6S-WpLxgBnNxBg)
- **2026-03-01:** [GenericAgent 被机器之心报道](https://mp.weixin.qq.com/s/uVWpTTF5I1yzAENV_qm7yg)
- **2026-01-16:** GenericAgent V1.0 公开版本发布
## 🚀 快速开始
#### 方法一:标准安装
```
# 1. 克隆仓库
git clone https://github.com/lsdefine/GenericAgent.git
cd GenericAgent
# 2. 安装最小依赖
pip install streamlit pywebview
# 3. 配置 API Key
cp mykey_template.py mykey.py
# 编辑 mykey.py,填入你的 LLM API Key
# 4. 启动
python launch.pyw
```
完整引导流程见 [GETTING_STARTED.md](GETTING_STARTED.md)。
📖 新手使用指南(图文版):[飞书文档](https://my.feishu.cn/wiki/CGrDw0T76iNFuskmwxdcWrpinPb)
## 🤖 Bot 接口(可选)
### 微信 Bot(个人微信)
无需额外配置,扫码登录即可:
```
pip install pycryptodome qrcode requests
python frontends/wechatapp.py
```
### QQ 机器人
使用 `qq-botpy` WebSocket 长连接,**无需公网 webhook**:
```
pip install qq-botpy
```
在 `mykey.py` 中补充:
```
qq_app_id = "YOUR_APP_ID"
qq_app_secret = "YOUR_APP_SECRET"
qq_allowed_users = ["YOUR_USER_OPENID"] # 或 ['*'] 公开访问
```
```
python frontends/qqapp.py
```
### 飞书(Lark)
```
pip install lark-oapi
python frontends/fsapp.py
```
```
fs_app_id = "cli_xxx"
fs_app_secret = "xxx"
fs_allowed_users = ["ou_xxx"] # 或 ['*']
```
**入站支持**:文本、富文本 post、图片、文件、音频、media、交互卡片 / 分享卡片
**出站支持**:流式进度卡片、图片回传、文件 / media 回传
**视觉模型**:图片首轮以真正的多模态输入发送给兼容 OpenAI Vision 的后端
详细配置见 [assets/SETUP_FEISHU.md](assets/SETUP_FEISHU.md)
### 企业微信(WeCom)
```
pip install wecom_aibot_sdk
python frontends/wecomapp.py
```
```
wecom_bot_id = "your_bot_id"
wecom_secret = "your_bot_secret"
wecom_allowed_users = ["your_user_id"]
wecom_welcome_message = "你好,我在线上。"
```
### 钉钉(DingTalk)
```
pip install dingtalk-stream
python frontends/dingtalkapp.py
```
```
dingtalk_client_id = "your_app_key"
dingtalk_client_secret = "your_app_secret"
dingtalk_allowed_users = ["your_staff_id"] # 或 ['*']
```
### 其他 App 前端
除默认的 Streamlit Web UI 外,还可以尝试不同风格的前端:
```
python frontends/qtapp.py # 基于 Qt 的桌面应用
streamlit run frontends/stapp2.py # 另一种 Streamlit 风格 UI
```
## 📊 与同类产品对比
| 特性 | GenericAgent | OpenClaw | Claude Code |
|------|:---:|:---:|:---:|
| **代码量** | ~3K 行 | ~530,000 行 | 已开源(体量大) |
| **部署方式** | `pip install` + API Key | 多服务编排 | CLI + 订阅 |
| **浏览器控制** | 注入真实浏览器(保留登录态) | 沙箱 / 无头浏览器 | 通过 MCP 插件 |
| **OS 控制** | 键鼠、视觉、ADB | 多 Agent 委派 | 文件 + 终端 |
| **自我进化** | 自主生长 Skill 和工具 | 插件生态 | 会话间无状态 |
| **出厂配置** | 几个核心文件 + 少量初始 Skills | 数百模块 | 丰富 CLI 工具集 |
## 🧠 工作机制
GenericAgent 通过**分层记忆 × 最小工具集 × 自主执行循环**完成复杂任务,并在执行过程中持续积累经验。
1️⃣ **分层记忆系统**
- **L0 — 元规则(Meta Rules)**:Agent 的基础行为规则和系统约束
- **L1 — 记忆索引(Insight Index)**:极简索引层,用于快速路由与召回
- **L2 — 全局事实(Global Facts)**:在长期运行过程中积累的稳定知识
- **L3 — 任务 Skills / SOPs**:完成特定任务类型的可复用流程
- **L4 — 会话归档(Session Archive)**:从已完成任务中提炼出的归档记录,用于长程召回
2️⃣ **自主执行循环**
整个核心循环仅 **约百行代码**(`agent_loop.py`)。
3️⃣ **最小工具集**
| 工具 | 功能 |
|------|------|
| `code_run` | 执行任意代码 |
| `file_read` | 读取文件 |
| `file_write` | 写入文件 |
| `file_patch` | 修改文件 |
| `web_scan` | 感知网页内容 |
| `web_execute_js` | 控制浏览器行为 |
| `ask_user` | 人机协作确认 |
4️⃣ **能力扩展机制**
通过 `code_run`,GenericAgent 可在运行时动态安装 Python 包、编写新脚本、调用外部 API 或控制硬件,将临时能力固化为永久工具。
GenericAgent 工作流程图
微信群 1![]() |
微信群 2![]() |
飞书群![]() |
标签:3K行代码, Claude, CVE检测, Gemini, Kimi, Kubernetes, LLM代理框架, MiniMax, SEO, Token高效, 代理框架, 低上下文窗口, 分层记忆, 少幻觉, 屏幕视觉, 执行路径结晶化, 技能树, 文件系统操作, 最小化架构, 本地计算机控制, 浏览器控制, 移动设备ADB, 系统级控制, 终端控制, 自主智能体, 自我进化, 自演化代理, 逆向工具, 通用代理, 键盘鼠标输入, 高成功率


