MASFactory is a framework for building agentic systems.
Project description
ใEnglish | Chineseใ
๐ Overview
MASFactory is a graph-first multi-agent orchestration framework designed for VibeGraphing: start from intent, sketch a graph, converge the structure via visual preview/editing, compile it into an executable workflow, and trace runtime states/messages/shared-attributes end-to-end with MASFactory Visualizer.
Documentation: https://bupt-gamma.github.io/MASFactory/
Key capabilities:
- VibeGraphing (intent โ graph): generate a draft structure from intent, then iterate toward an executable workflow.
- Graph composability: scale from simple pipelines to complex workflows with subgraphs, loops, switches, and composite components.
- Visualization & observability: preview topology, trace runtime events, and handle human-in-the-loop requests in VS Code.
- Context protocol (ContextBlock): structure and inject Memory / RAG / MCP context in a controllable way.
โก Quick Start
1) Install MASFactory (PyPI)
Requirements: Python >= 3.10
pip install -U masfactory
Verify installation:
python -c "import masfactory; print('masfactory version:', masfactory.__version__)"
python -c "from masfactory import RootGraph, Graph, Loop, Agent, CustomNode; print('import ok')"
2) Install MASFactory Visualizer (VS Code)
MASFactory Visualizer is a VS Code extension for graph preview, runtime tracing, and human-in-the-loop interactions.
Install from VS Code Marketplace:
- Open VS Code โ Extensions
- Search:
MASFactory Visualizer - Install and reload
Open it:
- Activity Bar โ MASFactory Visualizer โ Graph Preview, or
- Command Palette:
MASFactory Visualizer: Start Graph PreviewMASFactory Visualizer: Open Graph in Editor Tab
๐งฉ Simple Example (from โFirst Codeโ)
This is a minimal two-agent workflow: ENTRY โ analyze โ answer โ EXIT.
import os
from masfactory import RootGraph, Agent, OpenAIModel, NodeTemplate
model = OpenAIModel(
api_key=os.getenv("OPENAI_API_KEY", ""),
base_url=os.getenv("OPENAI_BASE_URL") or os.getenv("BASE_URL") or None,
model_name=os.getenv("OPENAI_MODEL_NAME", "gpt-4o-mini"),
)
BaseAgent = NodeTemplate(Agent, model=model)
g = RootGraph(
name="qa_two_stage",
nodes=[
("analyze", BaseAgent(instructions="You analyze the problem.", prompt_template="Question: {query}")),
("answer", BaseAgent(instructions="You provide the final answer.", prompt_template="Question: {query}\nAnalysis: {analysis}")),
],
edges=[
("entry", "analyze", {"query": "User question"}),
("analyze", "answer", {"query": "Original question", "analysis": "Analysis result"}),
("answer", "exit", {"answer": "Final answer"}),
],
)
g.build()
out, _attrs = g.invoke({"query": "I want to learn Python. Where should I start?"})
print(out["answer"])
โถ๏ธ Run multi-agent reproductions (applications/)
Most workflows require OPENAI_API_KEY. Some scripts also read OPENAI_BASE_URL / BASE_URL and OPENAI_MODEL_NAME.
# ChatDev
python applications/chatdev/workflow/main.py --task "Develop a basic Gomoku game." --name "Gomoku"
# ChatDev Lite (simplified)
python applications/chatdev_lite/workflow/main.py --task "Develop a basic Gomoku game." --name "Gomoku"
# ChatDev Lite (VibeGraphing version)
python applications/chatdev_lite_vibegraph/main.py --task "Write a Ping-Pong (Pong) game." --name "PingPong"
# VibeGraph demo (intent โ graph_design.json โ compile โ run)
python applications/vibegraph_demo/main.py
# AgentVerse ยท PythonCalculator task
python applications/agentverse/tasksolving/pythoncalculator/run.py --task "write a simple calculator GUI using Python3."
# CAMEL role-playing demo
python applications/camel/main.py "Create a sample adder by using python"
๐ Learn MASFactory (docs outline)
Online documentation: https://bupt-gamma.github.io/MASFactory/
- Quick Start: Introduction โ Installation โ Visualizer โ First Code
- Progressive Tutorials: ChatDev Lite (Declarative / Imperative / VibeGraph)
- Development Guide: Concepts โ Message Passing โ NodeTemplate โ Agent Runtime โ Context Adapters โ Visualizer โ Model Adapters
๐๏ธ Project structure
.
โโโ masfactory/ # MASFactory Framework
โ โโโ core/ # Foundation: Node / Edge / Gate / Message
โ โโโ components/ # Components (Agents / Graphs / Controls / CustomNode)
โ โ โโโ agents/ # Agent, DynamicAgent, SingleAgent
โ โ โโโ graphs/ # BaseGraph, Graph, RootGraph, Loop
โ โ โโโ controls/ # LogicSwitch, AgentSwitch
โ โโโ adapters/ # Adapters (Model / Tool / Memory / Retrieval / MCP)
โ โ โโโ context/ # Context pipeline (ContextBlock / policy / renderer / composer)
โ โโโ integrations/ # 3rd-party integrations (MemoryOS / UltraRAG, etc.)
โ โโโ utils/ # Utilities (config, hook, Embedding, etc.)
โ โโโ resources/ # Resources and static files
โ โโโ visualizer/ # MASFactory Visualizer runtime integration
โโโ masfactory-visualizer/ # VSCode extension: MASFactory Visualizer
โโโ graph_design/ # graph_design.json standard (IR for VibeGraphing)
โโโ applications/ # Examples and reproductions based on MASFactory
โ โโโ chatdev_lite/
โ โโโ chatdev/
โ โโโ agentverse/
โ โโโ camel/
โ โโโ number_off_demo.py
โโโ docs/ # VitePress docs
โ โโโ .vitepress/
โ โโโ src/
โ โโโ zh/
โ โโโ en/
โโโ examples/ # Graph patterns (imperative vs declarative)
โโโ README.md # English (default)
โโโ README.zh.md # Chinese
โโโ pyproject.toml
โโโ requirements.txt
โโโ uv.lock
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file masfactory-1.0.0.post4.tar.gz.
File metadata
- Download URL: masfactory-1.0.0.post4.tar.gz
- Upload date:
- Size: 131.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e297569b1282b178a12b692d391e933fcfa9e830ab9b3640ba22118765b8256
|
|
| MD5 |
e5f7ac23145cd0deafb63f05438b1dd3
|
|
| BLAKE2b-256 |
e337bf9b2b1ce01a4fa25765a8d905558fcaeca23461ba49ec5ecf8092799214
|
File details
Details for the file masfactory-1.0.0.post4-py3-none-any.whl.
File metadata
- Download URL: masfactory-1.0.0.post4-py3-none-any.whl
- Upload date:
- Size: 165.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3f0557c0209c1f44f12eb11cd0818c65fc526436f2eb0f425addd1d4b619365
|
|
| MD5 |
bdb9d87a9de89e49345f79d11baf88b3
|
|
| BLAKE2b-256 |
677274ccf1f54ab9da19465ea5bf8fef75225e03f47c8d5d1d6a84f92683ab8c
|