Skip to content

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

@kyegomez

Description

@kyegomez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions