# Pull Workflow Graph Tool

`pull_workflow_graph` reads a workflow's whole graph, its nodes, edges and frames, as one JSON
document that `push_workflow_graph` accepts back unchanged.

## When to Use

The agent uses it to keep a workflow as a file: pull the graph into a file, edit it locally (and
track it in git, if it likes), then push it back with `push_workflow_graph`. To inspect a workflow,
`get_workflow` reads it in topological order with summaries; for a small change, the per-node tools
(`add_workflow_node`, `edit_workflow_node`, `connect_workflow_nodes`) are the normal path.

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `workflow_id` | string | Yes | Workflow slug or id ULID |

## Returns

| Field | Type | Description |
|-------|------|-------------|
| `graph` | object | The graph document: `nodes`, `edges` and `frames` |
| `workflow_id` | string | The workflow's slug |
| `name` | string | The workflow's name |
| `version_id` | string | The current version's id ULID |
| `revision` | string | When the workflow last changed (RFC 3339); pass it to `push_workflow_graph` as `base_revision` |

The graph document is the workflow as it is stored:

| Field | Shape |
|-------|-------|
| `nodes` | In stored order. Each node has `id` (kebab-case, unique in the workflow), `node` as `{ "<node tag>": { …config… } }`, `label` when one is set, and `disabled: true` when it is switched off |
| `edges` | Each edge is `{ "from": [node id, socket], "to": [node id, socket] }` |
| `frames` | Each frame has `id`, `title`, `ink`, and the ids of its member `nodes`; a node is in at most one frame |

## Example Scenario

```json
{ "workflow_id": "invoice-intake" }
```

returns

```json
{
  "graph": {
    "nodes": [
      { "id": "manual-trigger", "node": { "manual_trigger": {} } },
      { "id": "extract-amount", "node": { "js_script": { "script": "return { amount: input.amount };" } }, "label": "Extract Amount" }
    ],
    "edges": [
      { "from": ["manual-trigger", "output"], "to": ["extract-amount", "input"] }
    ],
    "frames": [
      { "id": "intake", "title": "Intake", "ink": "emerald", "nodes": ["extract-amount", "manual-trigger"] }
    ]
  },
  "workflow_id": "invoice-intake",
  "name": "Invoice intake",
  "version_id": "01M7KD3Q8V6M3K9T1R5X7B0N4E",
  "revision": "2026-11-17T09:12:44.103Z"
}
```

A coding agent writes `graph` to `workflows/invoice-intake.json`, keeps `revision` for the push,
and edits the file.

## Notes

- Reads the current version, the one on the canvas, even when another version is pinned
- Node positions are not part of the document, and a push refuses them; every push lays the graph out
- Nodes come in stored order, so two pulls of the same workflow differ only where the graph changed
- Workflow settings (name, description, enabled, timeout) are not part of the graph; they stay with `update_workflow_config`
- Node ids are graph-local strings, not entity ids
- Risk: read
