MCPcopy Index your code
hub / github.com/DSGWJQ/Feagent

github.com/DSGWJQ/Feagent @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
17,403 symbols 75,754 edges 1,102 files 14,978 documented · 86%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Feagent - 企业级 AI 工作流编排与智能体协作平台

Python FastAPI React License: MIT

image

✨ 特性亮点

🎙️ 对话式工作流生成与编辑

  • 自然语言创建:通过对话描述需求,AI 自动生成完整工作流
  • 智能修改优化:对话中实时调整节点配置和连接关系
  • 可视化与代码双向同步:拖拽编辑与对话编辑无缝切换

🤖 多 Agent 协作体系

Feagent 采用独特的三 Agent 协作架构,实现智能任务分解与执行:

  • ConversationAgent(大脑):理解用户意图,执行 ReAct 循环,负责目标分解与决策生成
  • WorkflowAgent(执行者):管理节点创建、DAG 执行、状态同步与反思机制
  • CoordinatorAgent(守门人):规则验证、工作流监控、失败处理与子 Agent 管理

核心能力: - ReAct 推理循环:Thought → Action → Observation - 上下文容量感知与自动压缩 - 短期记忆蒸馏与结构化摘要(八段结构) - 动态节点审批与自描述验证 - 工作流依赖图与拓扑排序

🏛️ DDD 四层架构

严格遵循领域驱动设计(DDD-lite)与六边形架构:

Interface Layer(接口层)     ← FastAPI 路由、DTO 转换  
    ↓  
Application Layer(应用层)   ← 用例编排、事务边界  
    ↓  
Domain Layer(领域层)        ← 实体、聚合根、领域服务  
    ↓  
Infrastructure Layer(基础设施) ← ORM、消息队列、缓存

架构优势: - 模块化解耦,易于测试与扩展 - 领域逻辑与技术实现分离 - 支持 TDD 驱动开发

🛠️ 知识库与 RAG 集成

  • 向量存储:ChromaDB + SQLite-vec 双引擎
  • 智能检索:支持全局知识库与工作流级知识库
  • 文档管理:上传、解析、切片、嵌入全自动化

🚀 快速开始

环境要求

  • Python: 3.11+
  • Node.js: 18+
  • pnpm: 8+
  • PostgreSQL: 14+(可选,开发环境可使用 SQLite)

后端初始化

# 1. 克隆仓库  
git clone https://github.com/DSGWJQ/Feagent.git  
cd Feagent  

# 2. 安装依赖  
pip install -e ".[dev]"  

# 3. 配置环境变量  
cp .env.example .env  
# 编辑 .env 文件,配置数据库和 OpenAI API Key  

# 4. 初始化数据库  
alembic upgrade head  

# 5. 启动开发服务器  
python -m uvicorn src.interfaces.api.main:app --reload --port 8000

Windows 用户注意:请使用 python -m uvicorn ... 命令,避免 watchfiles 兼容性问题。

前端初始化

cd web

# 1. 安装依赖  
pnpm install

# 2. 启动开发服务器  
pnpm dev

访问应用

  • 前端界面:http://localhost:5173
  • API 文档:http://localhost:8000/docs
  • ReDoc:http://localhost:8000/redoc

🏗️ 架构设计

系统架构总览

Feagent 采用严格的分层架构设计,确保系统的高内聚、低耦合。

四层架构规范

详细的四层架构规范请参考架构文档。

核心原则: - Interface 层:仅处理 HTTP 协议,DTO 转换 - Application 层:用例编排,事务边界 - Domain 层:零框架依赖,纯领域逻辑 - Infrastructure 层:技术实现,适配器模式

多 Agent 协作流程

详见 current_agents.md

📦 核心功能

工作流管理

  • ✅ 对话式创建与编辑工作流
  • ✅ 可视化拖拽编辑器(ReactFlow)
  • ✅ 动态节点定义与 YAML 规范
  • ✅ 条件分支与循环控制
  • ✅ 工作流版本管理与快照

智能体能力

  • ✅ ReAct 推理循环(Thought-Action-Observation)
  • ✅ 目标分解与子目标栈管理
  • ✅ 意图分类(问候/查询/任务/工作流)
  • ✅ 上下文容量感知(token 计数与预警)
  • ✅ 短期记忆蒸馏(八段结构摘要)

知识库与 RAG

  • ✅ 文档上传与解析(PDF/TXT/MD)
  • ✅ 向量化与相似度检索
  • ✅ 全局知识库 + 工作流级知识库
  • ✅ 上下文注入与压缩

执行与监控

  • ✅ 实时执行日志(SSE 流式推送)
  • ✅ 节点状态跟踪与重试机制
  • ✅ 失败处理(RETRY/SKIP/ABORT/REPLAN)
  • ✅ 动态节点监控与健康检查

🛠️ 扩展开发

开发规范

请务必阅读以下文档: - 开发规范文档

技术栈

后端: - Python 3.11+ - FastAPI - SQLAlchemy - Alembic - Pydantic v2

前端: - React 18 - TypeScript - Vite - Tailwind CSS - ReactFlow

测试

# 运行所有测试  
pytest

# 运行单元测试  
pytest tests/unit

# 运行集成测试  
pytest tests/integration

# 生成覆盖率报告  
pytest --cov=src --cov-report=html

添加新节点类型

  1. definitions/nodes/ 创建 YAML 定义文件
  2. 遵循 JSON Schema 规范验证
  3. 实现节点执行逻辑
  4. 运行 python scripts/validate_node_definitions.py 验证

📚 文档资料

架构与设计文档

API 文档

启动后端服务后访问: - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc

文档导航

完整的文档索引请参考 文档目录

🤝 贡献指南

我们欢迎所有形式的贡献!

贡献流程

  1. Fork 本仓库
  2. 创建特性分支 bash git checkout -b feature/AmazingFeature
  3. 提交更改 bash git commit -m 'Add some AmazingFeature'
  4. 推送到分支 bash git push origin feature/AmazingFeature
  5. 开启 Pull Request

代码规范

  • 遵循 PEP 8(Python)与 Airbnb Style Guide(TypeScript)
  • 使用 ruff 和 black 格式化代码
  • 编写单元测试(覆盖率 > 80%)
  • 更新相关文档

开发前必读

在开始任何开发任务前,请先查看: - 开发规范 - 架构设计

📄 许可证

本项目采用 MIT 许可证。详见 LICENSE 文件。

📞 联系方式


🌟 Star History

如果这个项目对你有帮助,请给我们一个 ⭐️ Star!

Extension points exported contracts — how you extend this code

FormValues (Interface)
* 表单字段类型 * * 为什么和 CreateAgentDto 一样? * - 表单的数据结构和 API 请求的数据结构一致 * - 可以直接将表单值传给 API
web/src/features/agents/components/CreateAgentForm.tsx
ValidationErrorDetail (Interface)
* Structured validation error interface
web/tests/e2e/deterministic/ux-wf-102-validation-error.spec.ts
CustomRenderOptions (Interface)
* 自定义渲染函数 * * 为什么需要这个? * - 自动包装 QueryClientProvider、ConfigProvider 和 Router * - 避免每个测试都要手动包装 * - 提供统一的测试环境 * * 使用
web/src/test/utils.tsx
SeedWorkflowResponse (Interface)
* Seed Workflow 响应类型
web/tests/e2e/fixtures/workflowFixtures.ts
StreamingMessageListProps (Interface)
* 流式消息列表组件
web/src/shared/components/StreamingMessageDisplay.tsx
SeedWorkflowOptions (Interface)
* Seed Workflow 选项
web/tests/e2e/fixtures/workflowFixtures.ts
Workflow (Interface)
(no doc)
web/src/types/workflow.ts
CleanupOptions (Interface)
* 清理选项
web/tests/e2e/fixtures/workflowFixtures.ts

Core symbols most depended-on inside this repo

get
called by 1368
src/domain/services/tool_engine.py
append
called by 1113
src/domain/ports/memory_provider.py
get
called by 785
src/domain/ports/memory_cache.py
log
called by 338
src/domain/services/management_modules.py
get
called by 284
src/infrastructure/memory/in_memory_cache.py
info
called by 207
src/domain/services/unified_log_collector.py
patch
called by 186
web/src/shared/utils/request.ts
add_node
called by 165
src/domain/entities/workflow.py

Shape

Method 12,043
Class 3,375
Function 1,727
Interface 128
Route 127
Enum 3

Languages

Python98%
TypeScript2%

Modules by API surface

src/domain/agents/coordinator_agent.py216 symbols
tests/unit/domain/services/test_coordinator_runbook.py104 symbols
src/domain/services/logging_metrics.py102 symbols
src/domain/agents/workflow_agent.py101 symbols
tests/unit/domain/services/test_logging_metrics.py95 symbols
src/domain/services/management_modules.py94 symbols
tests/unit/domain/services/test_tool_engine.py82 symbols
tests/unit/domain/services/test_configurable_rule_engine.py81 symbols
tests/unit/domain/services/test_management_modules.py80 symbols
tests/unit/domain/services/test_supervision_modules.py78 symbols
tests/unit/domain/services/test_supervision_strategy.py73 symbols
tests/unit/domain/services/test_coordinator_extensions.py71 symbols

Datastores touched

mydbDatabase · 1 repos
testdbDatabase · 1 repos

For agents

$ claude mcp add Feagent \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact