# Workflows

The 19 tools for workflows. Before an agent first makes one, it reads guide topic workflows.

## workflow_blocks

The blocks a workflow is built from (Start (start_trigger), Webhook Trigger (generic_webhook), RSS Feed (rss), App (app), Agent (agent), Condition (condition), Router (router_v2), Evaluator (evaluator), Workflow (workflow_input), Human (human_in_the_loop), Variables (variables), Wait (wait), Response (response), Note (note)): each with its fields (id, type, options, default, when it shows, advanced or not), its outputs and its best practices; and the kinds of item an Agent can create (its artifacts). Give type for one block. Read it before create_workflow or edit_workflow: inputs are set by these field ids.

Parameters:
- `type` (string): One block type.

## app_events

A Tool kit app as an App block uses it: its picks (the app's own things a person picks on the block, such as a spreadsheet and its sheet or a channel: the connected Agents work only with them, event or no event, and the event uses them), and the events that can start a workflow: each one's slug, what it is, its settings for the block's eventConfig (the required ones marked; a setting a pick covers goes in picks) and the fields each event gives. Also whether the person has the app connected in Tool kit: an event of an app that is not connected is not switched on. For an integration (postgresql, s3, snowflake, http…): whether it is connected, its guide topic and its tools; it has no picks and no events.

Parameters:
- `app` (string, required): The Tool kit app or integration, as an App block names it (e.g. gmail, google-sheets, slack, hubspot; postgresql, s3, snowflake, http).

## create_workflow

Make a workflow in a space. It starts with a Start block (id "start"); operations are edit_workflow operations applied to it (add the blocks, connect "start" to the first one), and variables are its workflow variables. computer is the VM its runs get (size, internet, Data files); without it, the default: small (2 CPU, 4 GB), internet on, no files. Read guide topic "workflows" and workflow_blocks first. Then run it with run_workflow and read what each block gave before you hand it over.

Parameters:
- `space_id` (string, required)
- `title` (string, required): Workflow name.
- `description` (string): One line: what it does and when.
- `operations` (object[])
- `variables` (object[]): Workflow variables to add (operation "add").
- `computer` (object): The VM (computer) each run gets, shared by all the run's Agents: its size, its internet, and the Data files put in it. What you leave out stays as it is.

## read_workflow

A workflow as it is now, people's edits included: every block with its inputs (field values), the tags its outputs are read by, and the handles a connection can leave it by; the edges; the workflow variables; its VM (computer: size, internet, Data files and where each is in the run's folder; vm: the VM service of this server, null when it makes none, and the VMs of its runs going on now); its triggers and how each starts it (the schedule, a webhook's URL and auth, an RSS feed's last check, whether an App event is switched on); its last runs; and checks worth fixing.

Parameters:
- `item_id` (string, required)

## render_workflow

See a workflow as people do: a screenshot of its canvas (every block as a card, with its fields in words, and the connections between them), with one block's panel open when block is given (its fields as people set them), and errors the page hit. Check a workflow you built or changed with it before you hand it over.

Parameters:
- `item_id` (string, required)
- `block` (string): A block's id: shows its panel beside the canvas.

## edit_workflow

Change a workflow with operations: add, edit and delete blocks, and their connections. Applied in this order whatever order you give them: deletes, adds, edits, then every connection (so a connection can name a block added in the same call). All or nothing: an unknown field, a reference to a block that does not run before, an output that block lacks, a handle the block does not have, a variable that does not exist or a loop is refused, saying what to fix. variables adds, edits or deletes workflow variables (applied first). computer sets the VM its runs get (size, internet, Data files). Also title, description, and pause_schedule (true pauses the Start block's schedule, false resumes it; the schedule itself is set on the Start block's inputs). read_workflow first: people may have changed it.

Parameters:
- `item_id` (string, required)
- `operations` (object[])
- `variables` (object[])
- `computer` (object): The VM (computer) each run gets, shared by all the run's Agents: its size, its internet, and the Data files put in it. What you leave out stays as it is.
- `title` (string)
- `description` (string)
- `pause_schedule` (boolean)

## get_block_outputs

The outputs of a workflow's blocks as the tags that read them (<blockname.field>), with their types: what you write in a later block's inputs. Without block_ids, every block's.

Parameters:
- `item_id` (string, required)
- `block_ids` (string[])

## get_block_upstream_references

What each given block can read: the outputs of the blocks that run before it (connected to it, directly or through others), as tags, and the workflow variables. A block can read only these.

Parameters:
- `item_id` (string, required)
- `block_ids` (string[], required)

## run_workflow

Run a workflow now, as the Run button does, and wait for it (up to wait_seconds; a longer run keeps going: read it with read_workflow_run). It starts at the Start block when that leads somewhere; otherwise at the workflow's event trigger, run by hand; or at the trigger block named by trigger. Returns each block's status, output and time, the error of a block that failed, and the run's result (a Response block's data, or else the output of the last block to finish with nothing after it). An event trigger run by hand, with no workflow_input: at an App event no event comes: the App block passes nothing on, and the Agents connected to it do what their own task says with the app's tools (no Agent connected: refused); an RSS Feed takes the feed's newest item; a Webhook Trigger takes the body of its last call (never called: refused). With trigger and workflow_input, workflow_input is the event (a webhook body, a feed item, an email with the fields app_events lists). With block: run that one block alone, fed by what the blocks before it gave in their last run (Sim's run_block). A run is real: agents act in the person's apps and make and change items. A run that reaches a Human block waits for a person (status paused); resume_workflow_run answers it only when the person asked you to.

Parameters:
- `item_id` (string, required)
- `workflow_input` (object): What the run starts with: for the Start block its Inputs fields by name, and input (text); from an event trigger, the event (leave it out to have the trigger find a stand-in itself).
- `trigger` (string): Start at this trigger block (its id): needed when the workflow has several event triggers and no Start block leading anywhere.
- `block` (string): Run only this block (its id).
- `wait_seconds` (integer): How long to wait for it to finish. Default 120.

## read_workflow_run

One run of a workflow: its status, its result, and for each block what it was given (its inputs with the references filled in), what it returned, how long it took and its error. Without run_id, the latest run. stop: true stops a run that is going.

Parameters:
- `item_id` (string, required)
- `run_id` (string)
- `stop` (boolean)

## list_workflow_runs

A workflow's runs, newest first (read_workflow shows only the last 5): each with its run_id, status, how it was started, when, how long it took, and its error. Read one in full with read_workflow_run, and an Agent block's work in it with read_agent_log.

Parameters:
- `item_id` (string, required)
- `limit` (integer): How many, 20 by default.

## read_agent_log

What an Agent block did in one run, step by step, as the Runs tab shows it: each try and model, its task, what the model said, every tool call with its arguments and what came back (the VM's read, write, edit and bash among them), the nudges, and the answer it submitted. read_workflow_run gives only what the block was given and what it returned; this is how it got there, for finding why a run went wrong or what it wrote in its VM. Without run_id, the latest run. A long log comes in parts: `from` is the character to start at, and `next_from` in the answer is where the next part starts.

Parameters:
- `item_id` (string, required)
- `block` (string, required): The Agent block: its id, or its name.
- `run_id` (string)
- `from` (integer)

## list_data

The person's Data: the files they keep in Artifacts (from any of their spaces) for workflows' VMs, newest first. Each with its id (what a workflow's computer.files takes), name, type, size, when it was added, and the workflows whose runs get it.

## add_data

Add a file to the person's Data (up to 25 MB): from a public URL, as text (CSV, JSON, Markdown…), or as base64. Returns its id: give it in a workflow's computer.files (create_workflow, edit_workflow) and every run finds it in files/ of its folder.

Parameters:
- `url` (string)
- `text` (string)
- `base64` (string)
- `name` (string): The file name with its extension, e.g. "orders.csv". Needed with text or base64.
- `mime` (string): Its type, e.g. "text/csv". Default: the URL's, text/plain for text.

## list_skills

The space's own skills an Agent block can be given (its skills input: [{"skillId": id}]): each one's id, name and description. An Agent sees their names and descriptions and loads one in full when it needs it. With name: that skill's full instructions too.

Parameters:
- `space_id` (string, required)
- `name` (string)

## save_skill

Make a skill in a space, or change one (give its id): reusable Markdown instructions an Agent loads when relevant, such as a scoring rubric, a support procedure or a writing style. name: kebab-case (lead-scoring-rubric); description: what it does and when to use it (up to 1,024 characters; the agent decides from it); content: the instructions (steps, expected output, edge cases; up to 50,000 characters). A whole SKILL.md (frontmatter name and description, then the body) can be given as content.

Parameters:
- `space_id` (string, required)
- `id` (string)
- `name` (string)
- `description` (string)
- `content` (string, required)

## delete_skill

Delete one of a space's own skills (built-in ones can't be deleted). Agents that list it stop saving until it is taken off them.

Parameters:
- `space_id` (string, required)
- `id` (string, required)

## agent_memory

The Agent blocks' memories in a space. Each Agent has its own (no two share one), named agent:<workflow item_id>:<block id>: the final results of its runs, of which it reads its last 5 at the start of each run. Without memory, the list; with it, that Agent's results; with clear: true, they are deleted (its next run starts with none).

Parameters:
- `space_id` (string, required)
- `memory` (string)
- `clear` (boolean)

## resume_workflow_run

Answer a run waiting at a Human block with the values of its Resume Form, by field name (typed: true, 3, not "true"). Resuming is not approving: the workflow's next blocks check what was submitted. Only when the person asked you to answer it for them.

Parameters:
- `item_id` (string, required)
- `run_id` (string, required)
- `block_id` (string, required)
- `values` (object, required)
