Skip to main content

MASFactory is a framework for building agentic systems.

Project description

MASFactory MASFactory

ใ€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:

  1. Open VS Code โ†’ Extensions
  2. Search: MASFactory Visualizer
  3. Install and reload

Open it:

  • Activity Bar โ†’ MASFactory Visualizer โ†’ Graph Preview, or
  • Command Palette:
    • MASFactory Visualizer: Start Graph Preview
    • MASFactory 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


Download files

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

Source Distribution

masfactory-1.0.0.post6.tar.gz (131.8 kB view details)

Uploaded Source

Built Distribution

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

masfactory-1.0.0.post6-py3-none-any.whl (165.1 kB view details)

Uploaded Python 3

File details

Details for the file masfactory-1.0.0.post6.tar.gz.

File metadata

  • Download URL: masfactory-1.0.0.post6.tar.gz
  • Upload date:
  • Size: 131.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for masfactory-1.0.0.post6.tar.gz
Algorithm Hash digest
SHA256 a3a35d2dc28ce59c67e40e45dcc30ae10d2ec077bfa7eef10a8765913f6dee33
MD5 4367eea16a25b58604de5502412d9940
BLAKE2b-256 c5942d9696047d7bbfebf899156f591ab5f407bda60ad654690b22211eef3969

See more details on using hashes here.

File details

Details for the file masfactory-1.0.0.post6-py3-none-any.whl.

File metadata

File hashes

Hashes for masfactory-1.0.0.post6-py3-none-any.whl
Algorithm Hash digest
SHA256 5f78b6501cd632547b9359305f02b87bc8241adb94aeb516bf767e1c386ae915
MD5 9da25ed0a02e4ee58dabc83fd73aafe3
BLAKE2b-256 64e44bca398383f127b47e803c573f6db3b68fa9b5642989cba509bd51505390

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