Skip to main content

gMAS

Build multi-agent systems whose roles and connections can change while they run.

CI Documentation PyPI GitHub release Python 3.12–3.13 License: MIT

Documentation · Quick start · API reference · Benchmarks · Releases

gMAS is an open-source Python framework for building and running graph-based multi-agent systems with LLMs. Nodes hold roles and tasks; edges carry work and context; the runner schedules model and tool calls. Budgets, memory, events, and changes to the remaining plan stay visible in the same execution model.

gMAS system overview: authored setup flows into a mutable RoleGraph, runner and scheduler, answer and trace, with an adaptation loop

Project status: gMAS is an early release for developers and researchers. The public API is tested on Python 3.12 and 3.13. Pin a version for production experiments and expect some advanced APIs to evolve.

What stays explicit

Agent workflows quickly accumulate dependencies, parallel branches, tool permissions, budgets, and failure paths. gMAS keeps them in the graph and runner configuration instead of spreading them across prompt templates and callbacks:

  • the team is stored in RoleGraph;
  • the scheduler derives execution order and parallel groups from the graph;
  • each role can have its own instructions, model, tools, and local state;
  • the runner records outputs, token use, latency, errors, and topology changes;
  • typed policies can stop, skip, reroute, or recover work during the same run;
  • the graph can be exported for routing, pruning, and graph analysis.

Core capabilities

Area What gMAS provides
Graph model Agents, task nodes, weighted communication edges, conditions, execution boundaries, node state, and graph features
Execution Synchronous, asynchronous, streaming, sequential, and graph-derived parallel execution
Runtime control Early stop, skip/force, conditional routing, edge edits, recovery chains, plan rebuilds, and final-responder changes
Models A simple callable interface, OpenAI-compatible endpoints, and per-agent caller selection
Tools Registry-based tools, custom function tools, shell, code, file search, web search, MCP, and optional computer-use integrations
Context Per-agent state, hidden channels, working and long-term memory, and optional shared memory
Reliability Timeouts, retries, fallbacks, error policies, token/time budgets, and loop limits
Observability Typed lifecycle events, callbacks, streaming, metrics, JSONL traces, and complete execution results
Graph ML Adjacency and edge tensors, embeddings, pruning hooks, GNN routing, and PyTorch Geometric export

Install

gMAS requires Python 3.12 or 3.13.

python -m pip install frontier-ai-gmas

With uv:

uv add frontier-ai-gmas

The distribution is named frontier-ai-gmas on PyPI, while the Python import package is named gmas. Verify the installed version with:

python -c "import gmas; print(gmas.__version__)"

Install only the integrations you need:

pip install "frontier-ai-gmas[web-search]"
pip install "frontier-ai-gmas[mcp]"
pip install "frontier-ai-gmas[embeddings,pyg]"
pip install "frontier-ai-gmas[viz]"
Extra Purpose
web-search / web-fast Search and fast HTML extraction
selenium Browser-backed web interaction
mcp Model Context Protocol tools
embeddings Sentence-transformer embeddings
pyg PyTorch Geometric graph export and GNN workflows
viz Graphviz and Matplotlib visualization
computer-use-* Platform-specific screen and computer-use support

See the installation guide for the full extras matrix and development setup.

Quick start

The runner accepts any Callable[[str], str]. This keeps the graph independent of a particular model vendor.

import os

from openai import OpenAI

from gmas.builder import build_property_graph
from gmas.core import AgentProfile
from gmas.execution import MACPRunner


client = OpenAI(
    api_key=os.environ["LLM_API_KEY"],
    base_url=os.environ.get("LLM_BASE_URL"),
)


def call_llm(prompt: str) -> str:
    response = client.responses.create(
        model=os.environ["LLM_MODEL"],
        input=prompt,
    )
    return response.output_text


agents = [
    AgentProfile(
        agent_id="researcher",
        display_name="Researcher",
        description="Collect the relevant facts and assumptions.",
    ),
    AgentProfile(
        agent_id="reviewer",
        display_name="Reviewer",
        description="Check the evidence and identify weak claims.",
    ),
    AgentProfile(
        agent_id="writer",
        display_name="Writer",
        description="Produce the final concise answer.",
    ),
]

graph = build_property_graph(
    agents,
    workflow_edges=[
        ("researcher", "reviewer"),
        ("reviewer", "writer"),
    ],
    query="What would make this system safe to deploy?",
)

result = MACPRunner(llm_caller=call_llm).run_round(graph)

print(result.final_answer)
print(result.execution_order)
print(result.total_tokens, result.total_time)

run_round returns MACPResult, including the final answer, execution order, messages, timing, and token totals. Tools, parallel branches, memory, per-agent models, callbacks, budgets, and routing conditions can be added to the same graph.

The execution model

Execution has five stages:

  1. Authored setup — define the task, roles, prompts, tools, and initial connections.
  2. Live role graph — keep agents, edges, conditions, state, memory, and learned features in RoleGraph.
  3. Planning and scheduling — derive the executable subgraph, dependency order, parallel groups, and final responder.
  4. Agent execution — call models and tools under retry, timeout, loop, and budget policies.
  5. Adaptation and results — update the remaining plan when allowed, then return the answer together with its trace and metrics.

RoleGraph remains available throughout the run; it is not discarded after the initial plan is built.

Runtime adaptation

Dynamic topology is opt-in. A topology hook observes a completed step and returns a bounded TopologyAction; the runner validates and applies it to the remaining plan.

from gmas.execution import MACPRunner, RunnerConfig, StepContext, TopologyAction


def stop_after_approval(ctx: StepContext, graph) -> TopologyAction | None:
    if ctx.agent_id == "reviewer" and "APPROVED" in (ctx.response or ""):
        return TopologyAction(
            early_stop=True,
            early_stop_reason="The reviewer approved the current answer.",
        )
    return None


config = RunnerConfig(
    enable_dynamic_topology=True,
    topology_hooks=[stop_after_approval],
)

runner = MACPRunner(llm_caller=call_llm, config=config)
result = runner.run_round(graph)

Topology actions can:

  • stop execution with a recorded reason;
  • skip or force selected agents;
  • add or remove communication edges;
  • insert recovery work into the remaining plan;
  • change the final responder;
  • trigger a plan rebuild after graph changes.

See Dynamic topology for hooks, early-stop conditions, conditional edges, and direct graph mutation.

Execution modes

The runner exposes blocking, async, and event-streaming interfaces:

from gmas.execution import StreamEventType

# Blocking
result = runner.run_round(graph)

# Async
result = await runner.arun_round(graph)

# Streaming
for event in runner.stream(graph):
    if event.event_type == StreamEventType.AGENT_OUTPUT:
        print(event.agent_id, event.content)

# Async streaming
async for event in runner.astream(graph):
    if event.event_type == StreamEventType.AGENT_OUTPUT:
        print(event.agent_id, event.content)

Streaming covers run and agent lifecycle events, token events, errors and retries, parallel groups, memory access, budget warnings, topology changes, pruning, fallbacks, and the final result.

Read Running agents, Streaming, and Parallel execution for details.

Models and tools

A caller factory can assign a different synchronous or asynchronous model caller to each agent. Callers may use hosted APIs, OpenAI-compatible gateways, or local models.

ToolRegistry owns the tools available to a run. Built-in and optional tools cover shell execution, code interpretation, file search, web search and fetch, browser actions, MCP, and computer use. Python functions can also be registered as typed tools and converted to OpenAI-compatible schemas.

Memory, budgets, and reliability

RunnerConfig holds execution policy outside agent prompts. It configures:

  • per-run timeouts, retry count, delay, and exponential backoff;
  • total token and time budgets;
  • maximum tool and loop iterations;
  • continue, retry, fallback, or raise behavior for failures;
  • local working memory, long-term memory, and shared-memory access;
  • hidden-state channels and embedding propagation;
  • parallelism and routing policy.

Budget stops and recovery paths appear in the result and event stream.

See Memory, Error handling, and the MACPRunner guide.

Observability

MACPResult includes the final answer, final agent, execution order, per-agent messages, step results, token and timing totals, errors, fallbacks, pruned agents, budget information, hidden states, early-stop details, and the number of topology modifications.

Lifecycle callbacks make the same information available while the run is in progress. Built-in handlers support terminal output, metrics collection, and file traces; custom sync and async handlers can integrate application logging, telemetry, or UI updates.

See Callbacks and Reproducibility.

Graph learning and research workflows

RoleGraph can expose the live multi-agent system as numerical graph data:

  • adjacency and weighted-edge tensors;
  • node and edge attributes;
  • role embeddings and hidden states;
  • PyTorch Geometric Data export;
  • scheduler hooks for learned routing and pruning.

These interfaces support experiments that learn routing or prune a graph. They are optional; ordinary graph execution does not require PyTorch Geometric.

Start with GNN routing and the GNN example.

Benchmarks and reproducibility

Benchmark code is kept separate from product examples. Each evaluation track has its own directory, entry point, input notes, and output contract under benchmarks/.

Track What it evaluates
Matched topology gMAS and LangGraph under matched roles, prompts, models, and graph shapes
Runtime controls Early stopping, disabled nodes, reachability, adaptation, hidden channels, and multi-model execution
GAIA Tool-enabled question answering under a fixed tool budget
AgentPrune Learned graph pruning on the MultiAgentBench research-idea track
Terminal-Bench Single-agent and conditional-team terminal task harnesses

Reported results, statistical tests, limitations, and reproduction notes live together in the benchmark documentation. Comparative numbers are intentionally kept out of the front page so that results are read with their scope and caveats.

Scope

gMAS fits workflows that need to:

  • model a team with explicit dependencies and parallel branches;
  • inspect or visualize how work moves between roles;
  • change the remaining workflow based on intermediate results;
  • enforce tool, token, time, or iteration budgets centrally;
  • mix models or tool permissions across agents;
  • collect reproducible traces and per-agent metrics;
  • train or evaluate routing and graph-pruning policies.

A direct function chain is usually simpler for a fixed one-model pipeline. For durable checkpointing and human-in-the-loop resume, review the trade-offs in gMAS and LangGraph.

Ecosystem

Project Role
gMAS This repository: the Python graph engine, agents, runners, tools, memory, and evaluation harnesses
flowMAS Visual workflow studio, demo API, and self-hosted observability built on the gMAS SDK

gMAS is a standalone framework. flowMAS is a separate downstream application that consumes the SDK without changing the core library.

Documentation

The complete documentation is published at frontier-ai-next.github.io/gMAS.

Goal Start here
Install gMAS and its extras Installation
Build a first agent graph Quick start
Understand the data model Key concepts
Configure the runner MACPRunner
Add tools and callbacks Tools · Callbacks
Change a graph during execution Dynamic topology
Stream progress into an application Streaming
Reproduce reported results Benchmarks
Review framework trade-offs gMAS and LangGraph
Browse Python APIs API reference

Repository layout

gmas/
├── .github/        # CI, Pages, releases, and contribution templates
├── src/gmas/       # library code
├── tests/          # unit and integration tests
├── examples/       # focused runnable examples
├── benchmarks/     # evaluation harnesses and data contracts
├── docs/           # guides, API reference, and reported results
└── pyproject.toml  # package metadata and optional dependencies

examples/ contains small API demonstrations. benchmarks/ contains evaluation entry points and their run contracts; benchmark configuration is not part of the public library API.

Development

Install the development environment:

git clone https://github.com/frontier-ai-next/gmas.git
cd gmas
uv sync --all-extras --group test --group lint --group typecheck --group docs

Run the release checks:

uv run tox -e lint,quick
uv run --group docs mkdocs build --strict

The test matrix covers Python 3.12 and 3.13. Type checking is currently an advisory check while known type debt is reduced.

See CONTRIBUTING.md for branch, style, test, and pull-request guidance. Release maintainers should also review the release checklist.

Contributing

Open an issue for bugs, missing documentation, new adapters, or API proposals. Discuss larger changes before implementation when they affect graph semantics or public interfaces.

When contributing code:

  1. keep changes focused and add tests for observable behavior;
  2. preserve typed boundaries around graphs, runners, tools, and results;
  3. update the relevant guide when a public API changes;
  4. do not commit credentials, benchmark outputs, or provider-specific secrets;
  5. use Conventional Commits so release tooling can calculate version changes.

License

gMAS is released under the MIT License.

Download files

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

Source Distribution

frontier_ai_gmas-0.1.2.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

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

frontier_ai_gmas-0.1.2-py3-none-any.whl (329.8 kB view details)

Uploaded Python 3

File details

Details for the file frontier_ai_gmas-0.1.2.tar.gz.

File metadata

  • Download URL: frontier_ai_gmas-0.1.2.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for frontier_ai_gmas-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c32bf0b97c2fd1e74ec2632407748c027e964653f0ea2686fe08be77f4cfcaed
MD5 42f97479c0642ec34f209f53b6e2a5d8
BLAKE2b-256 597097d5d7e83af6592d641a2f609ce1285f0da167d24e4061f70c08a8bd5ff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for frontier_ai_gmas-0.1.2.tar.gz:

Publisher: release.yml on frontier-ai-next/gMAS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frontier_ai_gmas-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for frontier_ai_gmas-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0e4a7e9396c63dda6d73be1214c11df062bf625c8d85334ee69d50e9dee8dc05
MD5 174a27563293eb2b13c61f5acfdf4eb9
BLAKE2b-256 e78786da98bde518654c0a01b485a08bd0eaa5c59fc3c7de448a958425dacf32

See more details on using hashes here.

Provenance

The following attestation bundles were made for frontier_ai_gmas-0.1.2-py3-none-any.whl:

Publisher: release.yml on frontier-ai-next/gMAS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page