# Extract and publish reusable subflows

Turn a contiguous branch into a typed immutable graph with explicit boundaries and independent state identities.

Canonical URL: https://opennodeflow.dev/wiki/subflows/
JSON reference: https://opennodeflow.dev/wiki/subflows/index.json
Source snapshot: 2026-10-23

A subflow is a versioned node asset containing a typed graph. Insert it like another library node, then inspect its exact pinned body. Publishing a new body version does not upgrade existing callers. Use a subflow for a reusable branch that deserves a stable interface, rather than merely to hide an untidy canvas.

## Extract a selection

Select executable nodes and choose Create subflow. Give the asset a useful name. ONF publishes the reusable asset immediately and places a draft replacement instance in the parent canvas. Save the parent to commit that replacement. Undo can restore the old parent selection without deleting the newly published shared asset.

Crossing wires become typed boundary sockets and retain their crossing edge identities. Unconnected internal inputs and terminal outputs may also be exposed. Input literals move onto the parent instance while remaining internal defaults; a connected boundary value overrides them.

Trigger nodes stay in the parent and cannot be selected for extraction. A selection that leaves and reenters through unselected nodes may collapse into a cycle and is rejected. Select a contiguous branch instead. Include every send/receive sharing a [remote channel](/wiki/remote-routes/); partial-channel extraction is rejected.

## Design the interface

Open Subflows to edit the graph, public inputs/outputs, documentation and organization. A wired internal input cannot also become an exposed boundary parameter. Types and versions come from the internal sockets; exposing a boundary does not cast a value.

Conditional extracted outputs begin optional because their source branch may not execute. Mark one Required only when every valid execution produces it. Input mappings may fan one public parameter into compatible internal sockets. Each public output has one source.

Publication validates the complete graph and creates an immutable version. Loading an older version into the editor and publishing creates a new latest version. It never replaces historical bodies or repins callers.

## State and accepted runs

At acceptance, ONF expands the pinned graph and exact dependencies into the executable run snapshot. Each nested instance has stable internal execution identities. Two instances of one subflow do not share node-local checkpoints.

Extracting existing nodes creates new nested IDs and therefore a **fresh node-state scope** for that branch. The old state remains retained; extraction does not migrate it. Shared workspace/namespace storage has separate scope and is unchanged.

The subflow exit waits for its internal terminal branches, including branches without public outputs. Optional skipped output branches do not create unconditional failures, while required boundary values still validate. Historical inspection follows captured pins and origin paths.

## Limits and next steps

Subflows are acyclic, contain no triggers and reject recursive references. Maximum nesting is eight levels; each asset is limited to 500 internal nodes, 2,000 wires and 100 public inputs/outputs. Expanded runs have their own 2,000-node limit including adapters.

Use the published body as the basis for [collections](/wiki/collections/) or [Repeat / Until](/wiki/control-flow/) only after checking their stricter wait, retry and budget rules. Read the subflow's book documentation and validate every caller before enabling automated effects.

---

## Documentation provenance

- `docs/SUBFLOWS.md`
- `docs/TYPES-AND-VERSIONING.md`
- `docs/REMOTE-ROUTES.md`

This page describes maintained source, not a live inventory or an authorization to perform actions.
