kyegomez/swarms

[feat][graph_workflow][sub-workflow composition]

Open

#1,560 opened on Apr 21, 2026

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Python (948 forks)github user discovery
FEATenhancementgood first issue

Repository metrics

Stars
 (6,809 stars)
PR merge metrics
 (PR metrics pending)

Description

Problem

GraphWorkflow nodes are always individual agents. There is no way to use one GraphWorkflow as a node inside another, which rules out reusable graph modules and multi-level orchestration.

Proposed feature

A node can itself be a GraphWorkflow. The outer graph treats the inner graph as a single black-box node whose input is the node's upstream payload and whose output is the inner graph's final result.

Design sketch

  • GraphWorkflow.add_node(x) accepts either an Agent or another GraphWorkflow.
  • Inner graph's inputs are merged upstream outputs; inner graph's final layer output becomes the node's output.
  • Topology serialization (save_spec() / from_topology_spec()) is extended to support nested specs — the inner graph's spec is embedded as {"type": "subgraph", "spec": {...}}.
  • Checkpoint format stores inner-graph state under the parent node's ID for clean restart.

Tradeoff

Checkpoint format has to handle nesting. Nested topology serialization adds a small amount of parsing complexity at load time.

Files

  • swarms/structs/graph_workflow.py

Why

Enables reusable graph modules — a "research pipeline" subgraph can be dropped into multiple outer workflows. Also pairs with topology serialization for shareable, composable graph libraries.

Contributor guide