# Flow Agent

> Edit a flow draft from chat in the v2 flow editor.

**URL:** https://inference.sh/docs/flows/flow-agent
**Last updated:** 2026-10-31

---

Edit a flow draft from chat in the v2 flow editor.

---

## Open the flow agent

1. Open a flow at `/flows/{id}` in the [v2 editor](/docs/flows/creating#v2-editor).
2. Stay in **flow** view, not the **app** run view.
3. In the bottom-left toolbar, next to **undo** and **redo**, click **agent**.

A **flow agent** panel opens on the right. It runs the platform agent `infsh/flow-agent`. The button shows only when you can edit the flow.

The chat takes text only; it does not accept files or images.

---

## What it can do

Ask it to build or change the draft graph: add app and utility nodes, connect steps, wire inputs, set the flow input schema, map outputs, rename nodes, tidy the layout, or undo recent edits.

- "Add an upscale app after `generate_image` and wire the image output."
- "Define flow inputs: `text` (string, required) and `voice` (file)."
- "Organize the canvas and map the final image to the output node."

Agent edits and manual edits go to the same draft, and collaborators see them through the editor's sync.

---

## How edits reach the graph

The agent runs on the platform. Graph changes run in your browser as [client tools](/docs/api/agent/client-tools), on the same path the editor uses before it calls `POST /flows/{id}/actions`.

| Client tool | Purpose |
|-------------|---------|
| `get_flow_state` | Snapshot of the draft: each node's id, type, position, app ids, input and output field names, edges, wired values (`formValues`) and `outputMappings` |
| `search_apps` | Search the app catalog; returns `app_id`, `app_version_id` and `ref` for `node.add` |
| `apply_flow_actions` | Apply a batch of graph actions |
| `organize_nodes` | Auto-arrange the canvas |

### `apply_flow_actions`

Takes an `actions` array of the [graph action types](/docs/api/rest/flows#action-types) (`node.add`, `edge.add`, `node.set_input`, `flow.set_output_mapping` and the rest).

| Rule | Detail |
|------|--------|
| Batch | The editor applies the batch at once, then syncs it to the server |
| `undo` / `redo` | Must be the only action in the batch: `[{ "type": "undo" }]`. They use the same per-user action log as the toolbar buttons ([Undo and redo](/docs/api/rest/flows#undo-and-redo)) |
| `node.add` | Include `app_id` and `app_version_id` from `search_apps` in `payload.data`. The panel loads the app version so node forms and schemas work |
| Connections | `node.set_input` with a `connection` gets `connection.type` from the source node's output schema when it is omitted |
| Output mappings | `flow.set_output_mapping` gets `mapping.schema` and `mapping.type` from the source output field when they are omitted |
| Errors | A batch that fails validation or that the server rejects returns `{ error: "…" }`: empty `actions`, an unknown action type, an app version not found, an output the source node doesn't have, or the editor's sync error. The tool call is marked failed and the model reads the text |

Without the web app, edit the graph with `POST /flows/{id}/actions` or `belt flow edit` ([Apply graph actions](/docs/api/rest/flows#apply-graph-actions)).

---

## Next

→ [Creating a Flow](/docs/flows/creating)  
→ [Connecting Nodes](/docs/flows/connecting)  
→ [Client tools](/docs/api/agent/client-tools)
