freshcrate
Skin:/
Home > MCP Servers > agentica

agentica

Agentica: Lightweight async-first Python framework for AI agents. 轻量级异步优先的AI Agent框架,支持工具调用、RAG、多智能体和MCP。

Why this rank:Strong adoptionRecent releaseHealthy release cadence

Description

Agentica: Lightweight async-first Python framework for AI agents. 轻量级异步优先的AI Agent框架,支持工具调用、RAG、多智能体和MCP。

README

🇨🇳中文 | 🌐English | 🇯🇵日本語


Agentica: Build AI Agents

PyPI version Downloads License Apache 2.0 python_version GitHub issues Wechat Group

Agentica 不是套一层 LLM API 的聊天壳,而是一个 Async-First 的 agent harness。 它让 Agent 能真正跑起来: 调工具、跑长任务、做多智能体协作、跨会话保留记忆,并通过 Skill system 接入可演进的 self-learn 工作流。

能力 说明
Long-running Agent Loop Runner 驱动的 LLM ↔ Tool 循环,内置压缩、重试、成本预算、死循环防护
Works Beyond Chat 文件、执行、搜索、浏览器、MCP、多智能体、Workflow,不依附单一 IDE 场景
Memory That Survives Sessions Workspace 记忆按条目存储、相关性召回,并可把确认过的偏好同步到 ~/.agentica/AGENTS.md
Skill-Based Self-Learn SkillTool 可加载外部技能;内置 Agent 持续学习策略
Open, Composable Harness 模型、工具、记忆、Skill、Guardrails、MCP 都是可替换部件,而不是封闭 SaaS 黑盒

架构

Agentica 提供了从底层模型路由到顶层多智能体协作的完整抽象:

Agentica Architecture

核心执行引擎 (Agentic Loop)

Agentica 的单体 Agent 运行在一个纯粹的基于控制流的 while(true) 引擎中,严格依据工具调用来驱动,并内置了防死循环、成本追踪、上下文微压缩(Compaction)和四层安全护栏:

Agentica Loop Architecture

安装

pip install -U agentica

快速开始

import asyncio
from agentica import Agent, ZhipuAI

async def main():
    agent = Agent(model=ZhipuAI())
    result = await agent.run("一句话介绍北京")
    print(result.content)

asyncio.run(main())
北京是中国的首都,是一座拥有三千多年历史的文化名城,也是全国的政治、文化和国际交流中心。

需要先设置 API Key:

export ZHIPUAI_API_KEY="your-api-key"      # 智谱AI(glm-4.7-flash 免费)
export OPENAI_API_KEY="sk-xxx"              # OpenAI
export DEEPSEEK_API_KEY="your-api-key"      # DeepSeek

功能特性

  • Async-First — 原生 async API,asyncio.gather() 并行工具执行,同步适配器兼容
  • Runner Agentic Loop — LLM ↔ 工具调用自动循环,多轮链式推理、死循环检测、成本预算、压缩 pipeline、API 重试
  • 20+ 模型 — OpenAI / DeepSeek / Claude / 智谱 / Qwen / Moonshot / Ollama / LiteLLM 等
  • 40+ 内置工具 — 搜索、代码执行、文件操作、浏览器、OCR、图像生成
  • RAG — 知识库管理、混合检索、Rerank,集成 LangChain / LlamaIndex
  • 多智能体Agent.as_tool()(轻量组合)、Swarm(并行/自治)和 Workflow(确定性编排)
  • 安全守卫 — 输入/输出/工具级 Guardrails,流式实时检测
  • MCP / ACP — Model Context Protocol 和 Agent Communication Protocol 支持
  • Skill 系统 — 基于 Markdown 的技能注入,支持项目级、用户级和外部托管 skill 目录
  • 多模态 — 文本、图像、音频、视频理解
  • 持久化记忆 — 索引/内容分离、相关性召回、四类型分类、drift 防御,并可同步长期偏好到全局 AGENTS.md

Workspace 记忆

Workspace 提供跨会话的持久化记忆,采用索引/召回设计;需要时还可以把确认过的用户/反馈记忆编译进全局 ~/.agentica/AGENTS.md,让新 session 自动继承:

from agentica import Workspace

workspace = Workspace("./workspace")
workspace.initialize()

# 写入带类型的记忆条目(每条独立文件,自动更新索引)
await workspace.write_memory_entry(
    title="Python Style",
    content="User prefers concise, typed Python.",
    memory_type="feedback",              # user|feedback|project|reference
    description="python coding style",   # 相关性匹配关键词
    sync_to_global_agent_md=True,        # 同步到 ~/.agentica/AGENTS.md 的 Learned Preferences 区块
)

# 相关性召回(根据当前 query 返回最相关的 ≤5 条)
memory = await workspace.get_relevant_memories(query="how to write python")

Agent 自动根据当前 query 召回最相关记忆,而非全量注入:

from agentica import DeepAgent, Workspace
from agentica.agent.config import WorkspaceMemoryConfig

agent = DeepAgent(
    workspace=Workspace("./workspace"),
    long_term_memory_config=WorkspaceMemoryConfig(
        max_memory_entries=5,  # 最多注入 5 条相关记忆
        sync_memories_to_global_agent_md=True,
    ),
)

DeepAgent 默认启用 SkillTool(auto_load=True),会自动发现 ~/.agentica/skills/.agentica/skills/ 目录下的 skill;同时默认开启 tool_config.auto_load_mcp=True,启动时会自动读取工作目录里的 mcp_config.json/yaml/yml。这样 DeepAgent 开箱就是带 skills + MCP + memory 的一键完全体。

CLI

agentica --model_provider zhipuai --model_name glm-4.7-flash

安装外部 skill 集合时,推荐使用新的 skills 命令

agentica skills install https://github.com/obra/superpowers
agentica skills list
agentica skills remove learn-from-experience
agentica skills reload

如果你已经进入交互式 CLI,也可以直接在会话里安装、查看和卸载 skills:

> /skills install https://github.com/obra/superpowers
> /skills list
> /skills inspect learn-from-experience
> /skills remove learn-from-experience
> /skills reload

也支持安装本地目录或指定目标目录:

agentica skills install /path/to/skill-repo --target-dir ~/.agentica/skills

如果你安装到自定义目录而不是标准搜索路径,记得把这个目录加入 AGENTICA_EXTRA_SKILL_PATH,这样 DeepAgent 和 CLI 才会自动发现它。

Web UI / Gateway

Gateway 现在已经集成到 agentica 主库中

安装 Gateway 运行时:

pip install -U "agentica[gateway]"

设置一个最小可运行配置后直接启动:

export AGENTICA_MODEL_PROVIDER=zhipuai
export AGENTICA_MODEL_NAME=glm-4.7-flash
export GATEWAY_TOKEN=change-me
agentica-gateway

默认会启动在 http://127.0.0.1:8789/chat。如需改监听地址,可设置 HOSTPORT;如需接入 Telegram / Discord / Slack,可分别安装 agentica[telegram]agentica[discord]agentica[slack]

Gateway 内置了 Web UI、API、WebSocket、cron scheduler,以及飞书 / Telegram / Discord 等 channel 接入能力,适合把 agentica 从本地 CLI 扩展到常驻服务。

示例

查看 examples/ 获取完整示例,涵盖:

类别 内容
基础用法 Hello World、流式输出、结构化输出、多轮对话、多模态、Agentic Loop 对比
工具 自定义工具、Async 工具、搜索、代码执行、并行工具、并发安全、成本追踪、沙箱隔离、压缩
Agent 模式 Agent 作为工具、并行执行、团队协作、辩论、路由分发、Swarm、子 Agent、模型层钩子、会话恢复
安全护栏 输入/输出/工具级 Guardrails、流式护栏
记忆 会话历史、WorkingMemory、上下文压缩、Workspace 记忆、LLM 自动记忆
RAG PDF 问答、高级 RAG、LangChain / LlamaIndex 集成
工作流 数据管道、投资研究、新闻报道、代码审查
MCP Stdio / SSE / HTTP 传输、JSON 配置
可观测性 Langfuse、Token 追踪、Usage 聚合
应用 LLM OS、深度研究、客服系统、金融研究(6-Agent 流水线)

→ 查看完整示例目录

文档

完整使用文档:https://shibing624.github.io/agentica

社区与支持

  • GitHub Issues提交 issue
  • 微信群 — 添加微信号 xuming624,备注 "llm",加入技术交流群

引用

如果您在研究中使用了 Agentica,请引用:

Xu, M. (2026). Agentica: A Human-Centric Framework for Large Language Model Agent Workflows. GitHub. https://github.com/shibing624/agentica

许可证

Apache License 2.0

贡献

欢迎贡献!请查看 CONTRIBUTING.md

致谢

Release History

VersionChangesUrgencyDate
v1.4.6Cross-provider fallback now supports tool-calling turns: the fallback model can run tools and answer, while its provider-specific transcript is compacted (identity-marker based) so replay to the recovered primary stays clean. Fallback models are cloned per run for concurrency safety, and candidate dedup uses object identity. Adds edit-time LSP diagnostics CLI flags (--enable-diagnostics/--diagnostics-server), richer agentica doctor (workspace git + multi-server LSP checks, graceful MCP degradatiHigh6/3/2026
v1.4.4## Highlights ### perf(hooks): MemoryExtractHooks 优化 - 新增 `WorkspaceMemoryConfig.auto_extract_memory_background: bool = False` —— 开启后 memory 抽取以 `asyncio.create_task` 后台运行,**不再阻塞 `on_agent_end`**。适用于 FastAPI / asyncio.run 等长 event loop 场景,砍掉每轮响应 ~30s 抽取延迟。 - `MemoryExtractHooks` 现优先使用 `agent.auxiliary_model` 跑抽取调用,失败回退到 `agent.model`。副 model 通常更便宜更快,token 成本与主流程隔离。 - ⚠️ `auto_extract_memory_background=True` **不要**在 `agent.run_sync()` / `run_stream_sync()` 下使用:临时 loop 会在 task 完成前关闭,memory 静默丢失。High5/11/2026
v1.4.3Skill lifecycle refactor + VaG decoupling. ## Breaking changes (PyPI users action required) The skill lifecycle has been slimmed down. VaG (Verifier-as-Gatekeeper) experimental code is now a research module under `evaluation/vag/` and is no longer part of the SDK. ### Removed public exports - `SkillCandidate`, `GateVerdict`, `SkillGateResult`, `SkillAdmissionGate`, `skill_fingerprint` - `PROVENANCE_FILENAME`, `get_provenance_path`, `append_provenance_event`, `read_provenance_events` ### RemoHigh5/10/2026
v1.4.1# v1.4.1 — DX overhaul: top-level exports, sync-first docs, history filter ## Highlights ### Simpler imports — no more deep paths `OpenAIChat` and the 6 default `Builtin*Tool`s are now eager top-level exports: ```python from agentica import ( Agent, DeepAgent, Workspace, tool, OpenAIChat, BuiltinFileTool, BuiltinExecuteTool, BuiltinFetchUrlTool, BuiltinWebSearchTool, BuiltinTodoTool, BuiltinTaskTool, HistoryConfig, WorkspaceMemoryConfig, RunConfig, ) ``` Other model proviHigh4/28/2026
v1.4.0## What's Changed * [Draft] sdk-dev v1.3.6: packaging refactor + extras + API convergence by @shibing624 in https://github.com/shibing624/agentica/pull/25 **Full Changelog**: https://github.com/shibing624/agentica/compare/v1.3.4...v1.4.0High4/23/2026
1.2.3## What's Changed * Dev by @shibing624 in https://github.com/shibing624/agentica/pull/21 **Full Changelog**: https://github.com/shibing624/agentica/compare/1.1.0...1.2.3Low12/21/2025
1.0.10# v1.0.10 修复后的效果: ✅ 推理内容完整且无重复 ✅ 流式和非流式响应的推理内容一致 ✅ 正确处理大量小 chunk 的累积(如 deepseek-r1 的reasoning chunks) ✅ 支持各种推理模型(o1、deepseek-r1、gemini-2.5-pro 等) **Full Changelog**: https://github.com/shibing624/agentica/compare/1.0.7...1.0.10Low6/19/2025
1.0.6# v1.0.6 ## Support Model Context Protocol (MCP) Tools This module provides a client implementation for the [Model Context Protocol (MCP)](https://spec.modelcontextprotocol.io/), allowing you to easily integrate MCP servers with your Agentica agents. ## Features - Support for stdio, SSE, and StreamableHttp transport modes - Explicit parameter names for each transport type - Async context manager-based API for easy resource management - Tool caching for improved performance - AutoLow5/19/2025
1.0.0## v1.0.0 # Model Context Protocol (MCP) Tools This module provides a client implementation for the [Model Context Protocol (MCP)](https://spec.modelcontextprotocol.io/), allowing you to easily integrate MCP servers with your Agentica agents. ## Features - Support for both stdio and SSE transport modes - Explicit parameter names for each transport type - Async context manager-based API for easy resource management - Tool caching for improved performance - Automatic tool registratLow4/20/2025
0.2.3## v0.2.3 ZhipuAI提供了免费的模型api,包括:模型:glm-4-flash, glm-4v-flash, CogView-3-Flash, CogVideoX-Flash 和工具:文档(PDF、DOC、PPT、JPG等格式)内容抽取, Web-Search-Pro 免费专区:https://bigmodel.cn/dev/activities/free/glm-4-flash 均已经兼容到agentica库。 调用示例: https://github.com/shibing624/agentica/blob/main/examples/40_web_search_zhipuai_demo.py **Full Changelog**: https://github.com/shibing624/agentica/compare/0.2.0...0.2.3Low12/29/2024
0.2.0## v0.2.0 版本 - 支持了多模态大模型; - 改进了workflow的逻辑; - 升级Assistant为Agent的处理; - 支持multi-agent的2种模式:team和workflow。 - 所有的demo全部重写了。 | 示例 | 描述 | |--------------------------------------------------------------------------------Low12/23/2024
0.1.0`agentica`是一个Agent构建工具,功能: - 简单代码快速编排Agent,支持 Reflection(反思)、Plan and Solve(计划并执行)、RAG、Agent、Multi-Agent、Multi-Role、Workflow等功能 - Agent支持prompt自定义,支持多种工具调用(tool_calls) - 支持OpenAI/Azure/Claude/Ollama/Together API调用 实现的demo示例有: | 示例 | 描述 Low7/2/2024
0.0.6**Full Changelog**: https://github.com/shibing624/agentica/compare/0.0.5...0.0.6Low7/1/2024
0.0.5**Full Changelog**: https://github.com/shibing624/actionflow/compare/0.0.4...0.0.5Low6/28/2024
0.0.4## What's Changed * Dev by @shibing624 in https://github.com/shibing624/actionflow/pull/3 ## New Contributors * @shibing624 made their first contribution in https://github.com/shibing624/actionflow/pull/3 **Full Changelog**: https://github.com/shibing624/actionflow/commits/0.0.4Low6/26/2024

Dependencies & License Audit

Loading dependencies...

Similar Packages

agentscopeBuild and run agents you can see, understand and trust.v2.0.1
multi-agent-orchestration-frameworkModular multi-agent orchestration framework powered by LangGraph and FastAPI.v0.1.0
agentroveYour own Claude Code UI, sandbox, in-browser VS Code, terminal, multi-provider support (Anthropic, OpenAI, GitHub Copilot, OpenRouter), custom skills, and MCP servers.v0.1.38
open-computer-useMCP server that gives any LLM its own computer — managed Docker workspaces with live browser, terminal, code execution, document skills, and autonomous sub-agents. Self-hosted, open-source, pluggable v0.9.6.0
scraper-mcp🌐 Streamline web scraping with Scraper MCP, a server that optimizes content for AI by filtering data and reducing token usage for LLMs.main@2026-06-05

More in MCP Servers

node9-proxyThe Execution Security Layer for the Agentic Era. Providing deterministic "Sudo" governance and audit logs for autonomous AI agents.
mcp-compressorAn MCP server wrapper for reducing tokens consumed by MCP tools.
claude-plugins-officialOfficial, Anthropic-managed directory of high quality Claude Code Plugins.
langchain4jLangChain4j is an open-source Java library that simplifies the integration of LLMs into Java applications through a unified API, providing access to popular LLMs and vector databases. It makes impleme