Skip to main content

A self-evolving AI agent with dynamic toolkit management.

Project description

Tea Agent v0.9.22

⚠️ 这是一个 AI 写 AI 的实验项目,不做任何质量担保。

一个自进化 AI 编程助手 — 工具驱动、自我进化、多界面形态

Python License: MIT

Tea Agent 是一款会自我进化的 AI 编程助手,拥有 60+ 可调用的工具,能自主编写代码、调试、搜索、文件操作、浏览器操控,并能在运行中动态加载新工具。支持 GUI / TUI / CLI 三种界面。


✨ 核心特性

  • 🧠 自进化引擎 — Agent 可以修改自身代码、创建新工具、优化提示词,实现自主进化
  • 🧰 60+ 内置工具 — 涵盖文件操作、代码编辑、搜索、截图、OCR、包管理、Git 等
  • 🖥️ 三态界面 — GUI(Tkinter)、TUI(Textual)、CLI,按需切换
  • 📚 项目知识库 — 自动构建符号索引、调用图,支持代码影响分析
  • 🔄 断点续聊 — 聊天记录持久化,重启后恢复上下文
  • 📋 Plan / TODO — 内置任务规划与追踪系统
  • 🌐 MCP 协议 — 支持连接外部 MCP Server,扩展第三方工具
  • 🎯 模式切换 — design / develop / test / review / docs / devops 六阶段工作流

📦 安装

# 从 PyPI 安装
pip install tea_agent

# 或从源码
git clone https://github.com/sunkwei/tea_agent
cd tea_agent
pip install -e .

Playwright 浏览器(可选,用于 JS 渲染页面抓取):

playwright install chromium

🚀 快速开始

# 启动 GUI(默认)
tea_agent

# 启动 TUI
tea-agent-tui

# 启动 CLI
tea-agent-cli

🧰 工具概览(60+)

类别 工具
📁 文件操作 toolkit_file, toolkit_save_file, toolkit_explr
✏️ 代码编辑 toolkit_edit, toolkit_diff, toolkit_self_evolve
🔍 搜索 toolkit_search, toolkit_lsp, toolkit_query_chat_history
📸 截图/OCR toolkit_screenshot, toolkit_ocr, toolkit_screen_read
🖱️ 操控 toolkit_input, toolkit_browser_tab, toolkit_js_fetch
📦 包管理 toolkit_pkg, toolkit_build, toolkit_format_code
🧪 测试 toolkit_run_tests, toolkit_test_gui
🗓️ 工具 toolkit_lunar, toolkit_weather_my, toolkit_gettime
🔧 系统 toolkit_exec, toolkit_config, toolkit_os_info
🧠 记忆/知识 toolkit_memory, toolkit_kb, toolkit_reflection

完整列表见 docs/TOOLS.md(每小时自动更新)


🏗️ 项目结构

tea_agent/
├── gui.py              # GUI 主界面(Tkinter)
├── tui.py              # TUI 界面(Textual)
├── cli.py / tlk.py     # CLI 交互
├── agent.py            # Agent 核心引擎
├── config.py           # 配置管理
├── memory.py           # 长期记忆
├── prompt_manager.py   # 提示词版本管理
├── toolkit/            # 60+ 工具模块
├── session/            # 会话管理(Tool/Schemata)
├── multi_agent/        # 多 Agent 协作
├── lsp/                # LSP 语言服务
├── store/              # 数据存储
└── _gui/               # GUI 资源(图标、字体)

🔧 配置

配置文件 ~/.tea_agent/config.yaml

main_model:
  api_key: "sk-xxx"
  api_url: "https://api.openai.com/v1"
  model_name: "gpt-4o"
  max_context_tokens: 0   # 0=不限制,>0 时启用渐进式 token 裁剪
cheap_model:
  api_key: ""
  api_url: ""
  model_name: ""
  max_context_tokens: 0   # 独立配置,适用于本地小模型
embedding:
  provider: openai
  model: text-embedding-3-small

上下文窗口控制

max_context_tokens 用于限制发送给 LLM 的最大上下文 token 数:

  • 0(默认)= 不限制,发送全部历史
  • 32000 = 适合 32K 窗口模型
  • 128000 = 适合 GPT-4o / Claude 等大窗口模型

启用后,系统会自动预估 token 数,超出预算时按优先级渐进裁剪:

  1. 删除旧的 [历史记录] 条目
  2. 替换旧工具输出为占位符
  3. 清空 thinking 内容
  4. 截断长文本
  5. 删除旧轮次(保留最近 5 轮)

主模型和便宜模型独立配置,互不影响。

Agent 可在运行时通过 toolkit_config 自主调优参数。


📄 许可证

MIT License © 2024-2026 sunkw

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tea_agent-0.9.24.tar.gz (446.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tea_agent-0.9.24-py3-none-any.whl (538.7 kB view details)

Uploaded Python 3

File details

Details for the file tea_agent-0.9.24.tar.gz.

File metadata

  • Download URL: tea_agent-0.9.24.tar.gz
  • Upload date:
  • Size: 446.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for tea_agent-0.9.24.tar.gz
Algorithm Hash digest
SHA256 9ce5b306d89fd298094e9ca7974a5b82a07538b0ec9594a51189d5a828e6aab7
MD5 881a9d68d0b6c91664448a265df3e098
BLAKE2b-256 90866c867895fe40c267c992c473f7cf6315bc801654319ce060753895edc048

See more details on using hashes here.

File details

Details for the file tea_agent-0.9.24-py3-none-any.whl.

File metadata

  • Download URL: tea_agent-0.9.24-py3-none-any.whl
  • Upload date:
  • Size: 538.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for tea_agent-0.9.24-py3-none-any.whl
Algorithm Hash digest
SHA256 00d0fab4d325d37e72bdc753f6b8576864579e4c66224ce53f7c239a65ea4e2e
MD5 1ada04227604408763f2d7eb65a970d9
BLAKE2b-256 cc62e9576997c3a5a27a92fe24f5746881682e8e7039bc56bc3f139a1f77abed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page