Skip to content

Commit 7c676ba

Browse files
authored
Merge pull request #7 from AckerlyLau/main
Fix #6 and improvements in NodeTemplate/Docs
2 parents ff65c39 + eb00d1a commit 7c676ba

20 files changed

Lines changed: 254 additions & 18 deletions

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,93 @@ Key capabilities:
2828
- **Visualization and observability:** **MASFactory Visualizer** provides topology preview, runtime tracing, and human-in-the-loop interaction.
2929
- **Context protocol (`ContextBlock`):** organize Memory / RAG / MCP context sources in a structured way, with automatic injection and on-demand retrieval.
3030

31+
## 🧭 Why Choose MASFactory
32+
33+
As multi-agent systems grow more capable, orchestration is still largely stuck in the age of manual assembly: either teams hand-write workflow code, or they drag and configure nodes one by one on a canvas. With Vibe Graphing, MASFactory aims to free people from tedious orchestration work: express the intent in natural language, let AI draft the collaboration structure, keep refining it with human corrections and confirmations, and finally compile the result into an executable graph workflow.
34+
35+
<p align="center">
36+
<img
37+
src="docs/src/public/imgs/readme/vibegraphing_diagram_en.png"
38+
alt="Vibe Graphing pipeline from intent to executable workflow"
39+
width="780"
40+
/>
41+
</p>
42+
43+
This shifts human effort away from low-level wiring and repetitive configuration, and back toward designing the multi-agent system itself.
44+
45+
Viewed more directly, today's multi-agent development frameworks roughly fall into the following categories:
46+
47+
| Platform Type | Representative Products | Positioning | Support for Multi-Agent Systems |
48+
| --- | --- | --- | --- |
49+
| **Code frameworks** | `MASFactory`, ChatDev2(DevAll), LangGraph, AutoGen | Build complex multi-agent systems | Still highly dependent on handwritten code and engineering implementation |
50+
| **Low-code workflow platforms** | `MASFactory`, ChatDev2(DevAll), Coze, Dify | Lower the barrier to building multi-agent systems with low-code workflows | Difficult to support deep customization and complex topologies for advanced systems |
51+
| **Vibe Graphing orchestration frameworks** | `MASFactory` | Rapidly design and iterate multi-agent systems with lower human cost | Humans do not need to spend much effort on coding or dragging nodes, only on clearly describing needs and refining the design through dialogue |
52+
53+
## 🏗️ System Architecture
54+
55+
MASFactory adopts the widely used graph-centric approach to multi-agent orchestration and abstracts the system into four layers:
56+
57+
<p align="center">
58+
<img
59+
src="docs/src/public/imgs/readme/framework.png"
60+
alt="MASFactory framework layers"
61+
width="860"
62+
/>
63+
</p>
64+
65+
- **Graph skeleton layer:** `Node` and `Edge` are the lowest-level abstractions, using graph structure to represent collaboration relationships, dependencies, and message flow among agents.
66+
- **Component layer:** this layer further packages `Node` and `Edge` into reusable collaboration units, so developers do not need to assemble workflows from scratch every time and can instead build multi-agent systems like reusable blocks:
67+
68+
> - `Agent` is the most basic execution unit: an agent node with roles, instructions, tools, Memory, RAG, and related capabilities, responsible for concrete analysis, generation, and tool-use tasks.
69+
>
70+
> - `Graph` packages multiple nodes as a nestable subgraph, allowing complex workflows to be designed hierarchically and reused locally. A single phase can itself become a node inside a larger graph.
71+
>
72+
> - `Loop` handles iterative tasks such as repeated discussion, continuous revision, or testing until success. It turns "repeat execution until a condition is met" into a standard component.
73+
>
74+
> - `Switch` supports branching and dynamic routing. It can switch execution paths based on explicit conditions or use model capabilities to decide where messages should go, enabling more flexible collaboration topologies.
75+
>
76+
> - `Human` brings human-in-the-loop steps such as confirmation, conversational input, file review, and editing into the graph, so the system is not limited to fully automated execution and can involve people at key stages.
77+
>
78+
> - `ComposedGraph` and `NodeTemplate` provide two additional reuse mechanisms on top of the components above. The former focuses on "declare a structure first, then instantiate and assemble it," while the latter packages common collaboration structures into reusable components. MASFactory includes built-in graph patterns such as `InstructorAssistantGraph` and `BrainstormingGraph` for out-of-the-box use.
79+
80+
**Protocol layer:** through `Message Adapter` and `Context Adapter`, MASFactory unifies communication protocols together with Memory, RAG, MCP, and related context capabilities, making it easier to integrate external frameworks into the system.
81+
82+
- **Interaction layer:** MASFactory supports three development paradigms:
83+
84+
> - Natural-language workflow construction based on `Vibe Graphing`, reducing the human cost of system development.
85+
> - Two code-centric styles, `Declarative` and `Imperative`, for developers who want more flexible control over workflow authoring.
86+
> - Manual workflow design through `MASFactory Visualizer`, preserving familiar low-code drag-and-drop habits.
87+
88+
MASFactory's advantage is not that it offers yet another way to build workflows, but that it unifies code authoring, visual editing, and natural-language-driven orchestration inside the same system. Developers can write workflows by hand, assemble them visually, or let AI draft the structure first and then compile it into an executable multi-agent workflow. These three modes are not isolated from one another; they can coexist inside the same project.
89+
90+
## 🎬 Flexible Combination of Three Development Modes with Unified Runtime Tracing
91+
92+
Whether you start from code, drag-and-drop editing, or Vibe Graphing, the resulting graph structure can enter the same Visualizer for preview, tracing, and human intervention.
93+
94+
### Coding with Graph Preview
95+
96+
<p align="center">
97+
<img src="docs/src/public/imgs/readme/coding.gif" alt="Code preview in MASFactory Visualizer" width="860" />
98+
</p>
99+
100+
### Drag-and-Drop Design
101+
102+
<p align="center">
103+
<img src="docs/src/public/imgs/readme/drag.gif" alt="Drag and drop workflow design" width="860" />
104+
</p>
105+
106+
### Vibe Graphing Interaction
107+
108+
<p align="center">
109+
<img src="docs/src/public/imgs/readme/vibe_2.gif" alt="Vibe Graphing interaction" width="860" />
110+
</p>
111+
112+
### Runtime Monitoring
113+
114+
<p align="center">
115+
<img src="docs/src/public/imgs/readme/monitor.gif" alt="Runtime monitoring and tracing" width="860" />
116+
</p>
117+
31118
## ⚡ Quick Start
32119

33120
### 1) Install MASFactory (PyPI)

README.zh.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,91 @@
2727
- **可视化与可观测:** 配套 **MASFactory Visualizer** 提供拓扑预览、运行追踪与人机交互能力。
2828
- **上下文协议(ContextBlock):** 以结构化方式组织 Memory / RAG / MCP 等上下文源,支持自动注入与按需检索。
2929

30+
## 🧭 为什么选择 MASFactory
31+
32+
随着多智能体能力快速增强,系统编排却仍停留在手工编排的时代:要么手写工作流代码,要么在画布里逐个节点拖拽配置。MASFactory 希望通过 Vibe Graphing, 把人类从繁复的编排工作中解放出来:先用自然语言表达意图,让 AI 起草协作结构,再由人持续纠正和确认,最后把结果编译成可执行图工作流。
33+
34+
<p align="center">
35+
<img
36+
src="docs/src/public/imgs/readme/vibegraphing_diagram.png"
37+
alt="Vibe Graphing 从意图到可执行工作流"
38+
width="780"
39+
/>
40+
</p>
41+
42+
这样一来,人类的开发重点就从低层连线和重复配置,转移到了多智能体的设计本身。
43+
44+
如果用更直观的方式来看今天的多智能体开发工具,大致可以分成下面几类:
45+
46+
| 平台类型 | 代表产品 | 定位 | 对多智能体的支持 |
47+
| -------------------------- | -------------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------ |
48+
| **代码框架** | `MASFactory`、ChatDev2(DevAll)、LangGraph、AutoGen | 构建复杂多智能体系统 | 高度依赖手写代码与工程实现 |
49+
| **低代码工作流平台** | `MASFactory`、ChatDev2(DevAll)、Coze、Dify | 低门槛低代码开发多智能体系统 | 难以支撑复杂多智能体系统的深度定制与复杂拓扑 |
50+
| **Vibe Graphing 编排框架** | `MASFactory` | 低人力成本实现多智能体系统快速设计和迭代 | 人类无需付出过多的开发、拖拽的操作,只需要将自己的需求描述清楚,并在对话中细化设计细节。 |
51+
52+
## 🏗️ 系统框架图
53+
MASFactory采用业界常用的以Graph为中心的多智能体编排方法,将系统抽象为4层:
54+
<p align="center">
55+
<img
56+
src="docs/src/public/imgs/readme/framework.png"
57+
alt="MASFactory 框架分层"
58+
width="860"
59+
/>
60+
</p>
61+
- **图骨架层**:以 `Node``Edge` 作为最底层抽象,用图结构表达多智能体之间的协作关系、依赖关系和消息流动
62+
- **组件层**:组件层的作用,是把底层的 `Node``Edge` 进一步封装成可复用的协作单元,让开发者不必每次都从最底层手工拼装工作流,而是可以像搭积木一样组织多智能体系统:
63+
64+
> - `Agent` 是最基础的执行单元,对应一个具备角色、指令、工具、Memory、RAG 等能力的智能体节点,负责完成具体分析、生成、调用等任务。
65+
>
66+
> - `Graph` 用于把多个节点封装成可嵌套的子图,让复杂流程可以分层设计、局部复用,也让“一个阶段”本身还能继续作为“另一个更大图里的节点”。
67+
>
68+
> - `Loop` 用于处理多轮迭代型任务,例如反复讨论、持续修订、测试直到通过等场景,本质上把“重复执行直到满足条件”为止的控制逻辑做成了标准组件。
69+
>
70+
> - `Switch` 用于做分支判断和动态路由,可以按照显式条件切换执行路径,也可以结合模型能力决定消息应该流向哪个节点,从而支持更灵活的协作拓扑。
71+
>
72+
> - `Human` 则把人工确认、对话输入、文件审阅与编辑等 Human-in-the-loop 环节纳入图中,使多智能体系统不再是纯自动流程,而是能够在关键步骤引入人类参与。
73+
>
74+
> - `ComposedGraph``NodeTemplate` 是MASFactory 在上述组件的基础之上进一步提供了两套复用能力组件,前者负责“先声明模板、后实例化装配”,后者负责把常见协作结构直接封装成可复用组件。MASFactory内置了常用的图结构(`InstructorAssistantGraph``BrainstormingGraph`等),方便用户开箱即用。
75+
76+
**协议层**:通过 `Message Adapter``Context Adapter`,统一处理通信协议以及 Memory、RAG、MCP 等上下文能力,方便用户接入相关框架增强自己的多智能体系统。
77+
78+
- **交互层**:MASFactory同时提供三类开发范式:
79+
80+
> - 基于`Vibe Graphing`的自然语言交互构造智能体工作流,降低系统开发的人力开支。
81+
> - 基于`声明式``命令式`的两种代码开发方式,可以更加灵活自由地编写工作流。
82+
> - 通过 `MASFactory Visualizer`以拖拽的方式手动设计工作流,兼容大家的低代码开发习惯。
83+
84+
MASFactory 的优势并不在于“再提供一种工作流搭建方式”,而在于它把代码开发、可视化编辑和自然语言驱动编排统一进了同一套系统。开发者既可以自己写,也可以自己拖拽,还可以先让 AI 起草系统结构,再编译成可运行的多智能体工作流——以上三中方式并不是相互割裂独立的,而是可以在同一个项目中同时使用。
85+
86+
## 🎬 三种开发方式自由组合,并提供统一的运行时追踪
87+
88+
无论你先写代码、先拖拽,还是先做 Vibe Graphing,对应的图结构都能进入同一个 Visualizer 里做预览、追踪和人工介入。
89+
90+
### 代码编写与图结构实时预览
91+
92+
<p align="center">
93+
<img src="docs/src/public/imgs/readme/coding.gif" alt="MASFactory Visualizer 代码预览" width="860" />
94+
</p>
95+
96+
### 拖拽式设计
97+
98+
<p align="center">
99+
<img src="docs/src/public/imgs/readme/drag.gif" alt="拖拽式工作流设计" width="860" />
100+
</p>
101+
102+
### Vibe Graphing 交互
103+
104+
<p align="center">
105+
<img src="docs/src/public/imgs/readme/vibe_2.gif" alt="Vibe Graphing 交互式构图" width="860" />
106+
</p>
107+
108+
### 运行时监测
109+
110+
<p align="center">
111+
<img src="docs/src/public/imgs/readme/monitor.gif" alt="运行时监测与追踪" width="860" />
112+
</p>
113+
114+
30115
## ⚡ 快速开始
31116

32117
### 1) 安装 MASFactory(PyPI)

docs/src/examples/agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ model = OpenAIModel(
3030
agent = SingleAgent(
3131
name="demo_single",
3232
model=model,
33-
instructions="Reply in JSON with field {answer}.",
33+
instructions="Reply in JSON with an 'answer' field.",
3434
prompt_template="Question: {query}",
3535
)
3636

docs/src/guide/context_adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ from datetime import datetime, timezone
289289
from masfactory import Agent, SimpleKeywordRetriever
290290

291291
def get_utc_now() -> str:
292-
\"\"\"Get current UTC time in ISO format.\"\"\"
292+
"""Get current UTC time in ISO format."""
293293
return datetime.now(timezone.utc).isoformat()
294294

295295
retriever = SimpleKeywordRetriever({"doc": "..."}, passive=False, active=True)

docs/src/guide/node_template.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,24 @@ from masfactory.core.node_template import template_defaults_for, template_overri
164164
Phase = NodeTemplate(
165165
Loop,
166166
nodes=[
167-
("assistant", NodeTemplate(Agent)),
168-
("instructor", NodeTemplate(Agent)),
167+
(
168+
"assistant",
169+
NodeTemplate(
170+
Agent,
171+
model=object(), # build() example only
172+
instructions="You are the Assistant.",
173+
prompt_template="{workspace}",
174+
),
175+
),
176+
(
177+
"instructor",
178+
NodeTemplate(
179+
Agent,
180+
model=object(), # build() example only
181+
instructions="You are the Instructor.",
182+
prompt_template="{workspace}",
183+
),
184+
),
169185
],
170186
edges=[
171187
("CONTROLLER", "assistant", {"workspace": ""}),

docs/src/progressive/chatdev_declarative.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Start from the minimal phase:
1717

1818
`ENTRY → instructor → assistant → EXIT`
1919

20+
To keep `user_demand` transparent, `ENTRY` also passes it directly to `assistant`.
21+
2022
In this structure, `Assistant` produces a draft/result, and `Instructor` provides guidance to converge the output.
2123

2224
<ThemedDiagram
@@ -58,7 +60,8 @@ Assistant = NodeTemplate(
5860
)
5961

6062
# 3) Assemble the graph with nodes/edges:
61-
# ENTRY → instructor → assistant → EXIT
63+
# Main flow: ENTRY → instructor → assistant → EXIT
64+
# Plus a direct ENTRY → assistant edge to pass user_demand transparently.
6265
# Note: `Edge.keys` defines the message field contract. `Agent.output_keys` is aggregated from outgoing edges.
6366
g = RootGraph(
6467
name="p1_workflow_decl",
@@ -68,6 +71,7 @@ g = RootGraph(
6871
],
6972
edges=[
7073
("ENTRY", "instructor", {"user_demand": "user demand"}),
74+
("ENTRY", "assistant", {"user_demand": "user demand"}),
7175
("instructor", "assistant", {"instructor_guidance": "Instructor guidance"}),
7276
("assistant", "EXIT", {"assistant_response": "Assistant response"}),
7377
],
@@ -84,7 +88,7 @@ print(out["assistant_response"])
8488
## Step 2 — Multi-turn collaboration with Loop (edge messages)
8589

8690
Step 1 runs only once. In practice, a phase usually needs multiple turns to converge.
87-
Here we introduce `Loop` and place the `Instructor → Assistant` link inside the loop body. Each turn, fields are carried by edge keys.
91+
Here we introduce `Loop` and place the `Instructor → Assistant` link inside the loop body. To keep `user_demand` transparent, `CONTROLLER` also passes it directly to `assistant` each turn.
8892

8993
<ThemedDiagram
9094
light="/imgs/tutorial/chatdev-lite/prog-04-loop-edge-en-light.svg"
@@ -137,6 +141,7 @@ DialogLoop = NodeTemplate(
137141
edges=[
138142
# Loop does not use ENTRY/EXIT; it uses CONTROLLER as the scheduling endpoint.
139143
("CONTROLLER", "instructor", {"user_demand": "user demand", "assistant_response": "previous Assistant response"}),
144+
("CONTROLLER", "assistant", {"user_demand": "user demand"}),
140145
("instructor", "assistant", {"instructor_guidance": "Instructor guidance"}),
141146
("assistant", "CONTROLLER", {"assistant_response": "Assistant response"}),
142147
],
@@ -641,4 +646,3 @@ print("done, manual bytes:", len(str(out_attrs.get("manual", ""))))
641646
- This chapter is designed for quickly learning MASFactory’s declarative paradigm, so it omits some implementation details of ChatDev.
642647
For complete reproductions, refer to: [ChatDev-Lite](https://github.com/BUPT-GAMMA/MASFactory/tree/main/applications/chatdev_lite) or [ChatDev](https://github.com/BUPT-GAMMA/MASFactory/tree/main/applications/chatdev).
643648
:::
644-

docs/src/progressive/chatdev_imperative.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Start from:
1717

1818
`ENTRY → instructor → assistant → EXIT`
1919

20+
To keep `user_demand` transparent, `ENTRY` also passes it directly to `assistant`.
21+
2022
<ThemedDiagram
2123
light="/imgs/tutorial/chatdev-lite/prog-01-workflow-en-light.svg"
2224
dark="/imgs/tutorial/chatdev-lite/prog-01-workflow-en-dark.svg"
@@ -58,6 +60,7 @@ assistant = g.create_node(
5860
)
5961

6062
g.edge_from_entry(instructor, {"user_demand": "user demand"})
63+
g.edge_from_entry(assistant, {"user_demand": "user demand"})
6164
g.create_edge(instructor, assistant, {"instructor_guidance": "Instructor guidance"})
6265
g.edge_to_exit(assistant, {"assistant_response": "Assistant response"})
6366

@@ -72,7 +75,7 @@ print(out["assistant_response"])
7275
## Step 2 — Multi-turn collaboration with Loop (edge messages)
7376

7477
Wrap Step 1 into a loop to support multi-turn convergence.
75-
To demonstrate horizontal passing, we keep using edge keys inside the loop and iterate via `assistant_response``instructor_guidance`.
78+
To demonstrate horizontal passing, we keep using edge keys inside the loop and iterate via `assistant_response``instructor_guidance`, while `CONTROLLER` keeps passing `user_demand` directly to `assistant`.
7679

7780
<ThemedDiagram
7881
light="/imgs/tutorial/chatdev-lite/prog-04-loop-edge-en-light.svg"
@@ -125,6 +128,7 @@ instructor = dialog.create_node(
125128
)
126129

127130
dialog.edge_from_controller(instructor, {"user_demand": "user demand", "assistant_response": "previous Assistant response"})
131+
dialog.edge_from_controller(assistant, {"user_demand": "user demand"})
128132
dialog.create_edge(instructor, assistant, {"instructor_guidance": "Instructor guidance"})
129133
dialog.edge_to_controller(assistant, {"assistant_response": "Assistant response"})
130134

@@ -580,4 +584,3 @@ print("done, manual bytes:", len(str(out_attrs.get("manual", ""))))
580584
- This chapter is designed for quickly learning MASFactory’s imperative paradigm, so it omits some implementation details of ChatDev.
581585
For complete reproductions, refer to: [ChatDev-Lite](https://github.com/BUPT-GAMMA/MASFactory/tree/main/applications/chatdev_lite) or [ChatDev](https://github.com/BUPT-GAMMA/MASFactory/tree/main/applications/chatdev).
582586
:::
583-
9.93 MB
Loading
9.82 MB
Loading
586 KB
Loading

0 commit comments

Comments
 (0)