Files
windmill/openflow.openapi.yaml
T
Ruben Fiszel 3b95a2d096 feat: reusable AI agent steps with rigid linking and edit/fork (#9825)
* feat: reusable AI agent steps with hybrid linking and evals

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: make linked AI agents rigid (read-only) with unlink-to-fork

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: show inherited agent config read-only on linked step

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: edit/update a saved agent in place via upsert

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: bind linked AI agent tool inputs to host flow context

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: rebind linked AI agent tool inputs via graph tool nodes

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: linked AI agent tool nodes, step test, and read-only card

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: remove ai_agent resource type migration, sync from hub instead

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: remove AI agent eval suite and run endpoint, defer to later

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: unwire eval routes, types and UI (completes eval removal)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: update reusable AI agents guide for eval removal and tool rebinding

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore: regenerate system prompts for AIAgent agent/tool_inputs schema

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: strip brain transforms on link, avoid dirtying flow on tool open

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: flow-local test form and linked-agent marker in read-only graph

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: store linked tool overrides as diff from resource base

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: resolve linked agent tools in read-only viewer with fallback

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: use operating workspace, block non-static provider, warn on unbound tool inputs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: resolve linked parent's tools from resource for nested agent tool lookup

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: scope linked-agent tools by flow path, thread workspace to path check and embedded viewer

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: strip flow-context tool inputs on agent save, drop unbound-inputs warning

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: persist agent edit mode across tool selection, show linked tool code read-only

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat: show linked agent resource path in node definition panel

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: edit linked tool inputs in step panel, make tool nodes display-only

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: wire step-panel tool bindings (completes display-only pivot)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: single scroll for linked card, agent path as node label, drop fill-inputs in tool cards

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* style: align linked-agent UI with design tokens and components

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: separate linked tool select target from module id to unbreak agent clicks

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@aanthropic.com>

* fix: save agent tool inputs verbatim, host flows override via tool_inputs

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: scope agent edit state by flow path, require linked-tools scope at init

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: block saving an agent whose static provider is incomplete

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: type errors in agent tool bindings and save drawer input

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: key agent edit state by workspace, resync tool bindings on external changes

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: include workspace in linked-tools scope and tool schema fingerprint

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: remove unused workspace prop from FlowModuleSchemaMap

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: drop linked-agent placeholder tool node, path label suffices

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: workspace-qualified resource links, guard stale tool schema loads

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: keep flow tool overrides out of the agent on edit, fold only on unlink

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: fold preserved tool overrides into the step on edit cancel

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: refuse overwriting non-agent resources on save, show memory kind on linked card

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: consume picker value, invalidate edit state on undo/reinit, cap nested agent tools

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: guard in-flight edit fork against restores, migrate edit state on rename

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor: validate agent edit state by fork identity instead of path keys

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: key agent edit entries by fork marker alone, immune to editor nesting

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: keep agent edit state across structural graph edits and flow renames

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6kq9PYqNdc5q7ubidBYAs

* fix: centralize agent edit reanchor, guard in-flight saves, seed rename scope from flow path

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6kq9PYqNdc5q7ubidBYAs

* fix: ancestry-keyed edit reanchor and doc-scope sweep for republished linked tools

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6kq9PYqNdc5q7ubidBYAs

* fix: guard stale linked-tool fetches and resolve while-loop nested linked agents

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6kq9PYqNdc5q7ubidBYAs

* fix: drop empty tool override entries on revert and correct stale viewer comment

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6kq9PYqNdc5q7ubidBYAs

* docs: drop stale eval mention from the linked-agent comment

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: deploy linked agent resource, guard viewer fetches, align tools schema

Address review findings on the reusable-agent branch:

- Cross-workspace deploy never collected a linked step's `agent` resource, so
  the deployed flow failed at runtime unless the agent already existed there.
- The read-only viewer published resolved tools without the generation guard
  flowState uses, letting a superseded link's tools win a race. Share one
  guarded publisher (`publishLinkedAgentTools`) between both call sites.
- `tools` was still required in the OpenFlow AiAgent schema while the
  deserializer defaults it, rejecting hand-authored linked steps; make it
  optional and narrow the call sites.
- Overlay `tool_inputs` in the non-linked branch too, so a flow persisted
  while a step sits in "Editing" mode still binds tools to this flow.
- Cap the linked-tools store's scope map; nothing evicted it before.
- Drop the orphaned `.sqlx` entry left by the eval removal, regenerate the
  copilot OpenFlow schema, and fix the generator's nested-`z.record` arity.
- Move `refreshFlowStateStore` out of `agentEditStore` into its own module.
- Document that linked agents' tool scripts are outside the lock pipeline.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: regenerate system prompts for optional AIAgent tools

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: follow saved-agent deps on deploy, accept the linked shape in the schema

Round-18 review findings:

- Deploying a linked flow queued only the outer ai_agent resource. Follow
  `$res:` refs inside a resource value (every UI-saved agent has a provider
  resource) and the agent's own tools, which reference scripts, flows, MCP
  resources and nested linked agents by bare path.
- The AiAgent input_transforms schema still required provider/output_type,
  so it rejected the very shape linking persists (brain transforms stripped,
  flow-local inputs kept). Only user_message is always present.
- dfs traversed `value.tools` unconditionally through a cast, which throws on
  a linked module that omits it now that the field is optional.
- Trim the flow-refresh invariant comment to the 4-line limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: recurse into inline nested agent tools on deploy, require provider when unlinked

Round-19 review findings:

- The deploy walk only inspected a saved agent's top-level tools, so an inline
  nested agent tool's own scripts, flows and MCP resources were skipped.
  Recurse into it; a linked one is still queued as a resource instead.
- Normalize a `$res:`-prefixed MCP tool resource_path like other refs.
- Dropping provider/output_type from the schema's required list also let a
  standalone providerless agent validate, which deploys clean and then fails
  on every run. The constraint can't go in the schema: an `anyOf` makes
  AiAgent a union, which breaks the FlowModuleValue discriminated union it
  belongs to (verified: zod throws "Invalid discriminated union option").
  Enforce it in validateFlowModules instead, next to the other cross-module
  checks, via a shared collectProviderlessAgentIds.
- Correct the deploy paragraph in the docs: provider resources are traversed
  now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: follow linked tool_inputs overrides on deploy, untrack vitest artifact

Round-20 review findings:

- A linked step's `tool_inputs` override replaces the resource tool's default
  at runtime, so a static `$res:`/`$var:` override is the dependency the flow
  actually uses. The deploy walk queued only the saved agent, leaving runs in
  an empty target workspace to fail on the missing override target. It also
  never scanned an aiagent module's own input_transforms, since the scan was
  gated to script/rawscript/flow.
- Extract the pure walkers to deployDependencies.ts and cover them: three
  rounds have each found a further gap in this one function.
- Untrack a vitest cache artifact committed by accident, and ignore a
  repo-root node_modules/ (only per-package paths were listed).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: collect inline agent provider and tool deps, correct tool_inputs docs

Round-21 review findings:

- An inline agent's provider credential sits inside an object-valued static
  transform, so the top-level string check missed it and such a flow deployed
  without its provider. Walk transform values instead of string-matching them.
- An inline agent's own tools were only partly reachable: getAllModules drops
  MCP and websearch tools, so their resources were never queued. A standalone
  agent module now recurses through agentResourceDependencies, and the module's
  own input_transforms are scanned inside aiAgentModuleDependencies so one
  function owns the whole step rather than splitting it with the caller.
- `tool_inputs` was documented as empty/absent for non-linked steps, which
  contradicts the runtime applying it when `agent` is unset so a flow persisted
  mid-Edit keeps its bindings. Describe that case in both the Rust doc and the
  OpenFlow description.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: keep linked steps brain-free on load, gate stale agent fetches, log linked tools

Round-22 review findings:

- loadSchemaFromModule filled every AI agent schema key with a placeholder
  transform, re-adding provider/memory to a linked step that deliberately
  carries none — persisted on the next save and rejected by the generated
  Copilot schema. Fill only the flow-local keys when the step is linked.
- The linked-resource fetch was neither aborted nor tagged, so switching a
  step from agent A to B could publish A's tools under B and show A's brain
  next to B's link. Tag each result with the (workspace, path) it was fetched
  for and drop the ones that no longer match.
- "Test this step" passed no tools for a linked agent, and the log viewer
  drops tool_call entries it cannot resolve to a definition, so the agent's
  invocations vanished from the log. Pass the resolved resource tools.
- Correct the cancel-edit comment: the runtime does apply tool_inputs on an
  unlinked step, and folding is what leaves nothing for it to overlay.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: pin the edit session across saves, resolve linked tools in the run viewer

Round-23 review findings:

- Cancel stays enabled while a save awaits its requests, and it keeps the
  `tools` array identity, so the old guard passed and the completing save
  relinked the step and cleared the edits Cancel had just kept. It also
  accepted any replacement edit marker. Pin the path being saved and require
  the marker to still hold it, which still tolerates a content-preserving
  refresh re-anchoring the marker onto a clone.
- Resolve linked agents' tools in the run/status viewer too: it reads
  module.value.tools straight from raw_flow, which is empty for a linked step,
  so AIAgentLogViewer dropped every tool_call it could not match and the graph
  drew the agent with no tool nodes. Same gap the previous commit closed for
  "Test this step" only.
- Drop the overlay call-site comment: it claimed resource defaults are
  discarded and unmatched keys ignored, while overlay_tool_inputs preserves
  defaults and inserts new keys, as its own test asserts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: scope linked tools without the trigger-node path, keep the standalone save guard

Round-24 review findings, both regressions from the previous commit:

- Passing `path` to the run viewer's graph also switched on its Trigger node
  (`triggerNode ? path : undefined`), which reads a TriggerContext that
  /run/[...run] does not provide — the page threw "Cannot read properties of
  undefined (reading 'triggersCount')". Give the graph a separate
  `linkedToolsPath` for the tools bucket so the two stay independent.
- The rewritten save guard tracked only the edit path, so a plain "Save as
  agent" no longer noticed the step being replaced mid-request (undo, session
  sync): the replacement has no edit path either, so the stale completion
  relinked it and stripped its brain. Keep the array-identity check when there
  is no edit session, and use path re-anchoring only when there is one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: keep recorded tool calls in run history, send tool_inputs from step previews

Round-25 review findings:

- The agent log viewer dropped any recorded tool_call whose definition it
  could not find among the supplied tools, so renaming or removing a tool —
  or losing read access to a linked agent's resource — erased calls that had
  actually run. Render the recorded call labelled by its function name; its
  args, logs and result come from the child job, not the definition.
- "Test this step" sent tool_inputs only for a linked step, but a step forked
  for editing has no `agent` while still carrying the flow's bindings, which
  the runtime overlays. The preview ran resource-authored defaults instead of
  the bindings under test. Send them from both branches.
- Polling a running flow replaces `job` every tick, so the run viewer re-read
  every linked agent's resource each time. Key the fetch on the set of linked
  steps instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: never discard edits made during a save, isolate the run viewer tools bucket

Round-26 review findings:

- The agent editor stays live while a save is in flight, so edits made after
  the snapshot were not in the resource yet linking stripped them from the
  step too, losing them outright. Compare the config against the snapshot on
  completion and, if it moved, leave the step alone and tell the user to save
  again.
- The run viewer published into the editor's `${ws}:${flow path}` bucket, so
  opening an older run in the preview pane could flip the edited flow's tool
  nodes to that run's agent. Key it by job instead.
- Drop the now-unreachable undefined filter in the agent log viewer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: claim the linked-tools generation on direct publishes and clears

Round-27 review findings:

- The step editor wrote resolved tools (and cleared them on unlink) straight
  into the store, leaving the fetch generation untouched. An older in-flight
  load for the previous agent then still passed its own check and overwrote
  them, so the graph and binding editor could show agent A while the step
  links to B. Claim the generation before those writes.
- Correct two comments that still described unmatched tool calls as dropped;
  they are kept and labelled by their recorded name.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: retain the loaded linked agent, rebuild run logs when tools resolve

Round-28 review findings:

- Rejecting a superseded resource response left the card with nothing: a late
  reply for a previous agent replaces `linkedResource.current` and no refetch
  follows, so the linked step lost its brain, tools and provider warning until
  remount. Retain the last response that matched the current link instead.
- The agent log viewer built its module list on mount only, so a linked
  agent's asynchronously resolved tools never replaced the placeholders, and
  switching between completed runs reused the first snapshot. Rebuild on a
  value key — callers rebuild the agentJob object each render, so tracking its
  identity would reload in a loop.
- Refresh a linked-tools scope's recency when it is read, not only when it is
  published: a run viewer opens one bucket per nested job, which could
  otherwise evict the bucket a still-displayed run is using.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: supersede stale log reloads and stale tools on a link change

Round-29 review findings, both on the reloads added last round:

- Every prop change starts another loadToolCalls, and it awaits child-job
  requests before writing the shared view, so a slower reload for a previous
  run could restore its logs and tool states over the run now selected — or
  replace newly resolved definitions with an earlier empty-tools snapshot.
  Build the states locally and let only the newest load publish, including the
  parent's index-keyed job cache.
- While a newly linked agent resolves, the previous agent's tools stayed in
  the store, so its bindings were editable against a step already linked
  elsewhere, and a failed load left them indefinitely. Clear them once the
  link moves away from what this component published; tools resolved at flow
  load are untouched, so selecting a step still doesn't flicker.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: resolve a run's linked agents in the run's own workspace

Round-30 review finding: the run viewer fetched linked agent resources with
the navigation workspace, but session and fork previews render it with
`workspaceId` pointing elsewhere. Those runs resolved nothing — or an
unrelated resource sharing the path — losing tool nodes and log definitions.
Prefer the explicit override, then the job's own workspace. The store scope
stays keyed on `workspace` so it still matches what FlowGraphV2 reads; the
job id in the key already makes the bucket unique.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: refetch a run viewer's linked tools if its scope is evicted

Round-31 review nit: the viewer publishes one scope per mounted nested job,
hidden ones included, so a loop with many loaded iterations can push a
displayed scope past the store's cap. Nothing refetched it afterwards — the
set of linked steps had not changed — leaving the run without tool nodes or
log definitions. Track the store and republish when the bucket is gone;
publishing always writes a key, so this settles instead of looping.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: retain in-use linked-tool scopes instead of refetching evicted ones

Round-32 review findings. Republishing an evicted scope settles for one
scope but not against the cap: with more than 32 mounted nested jobs holding
linked agents, restoring one necessarily evicts another, and that mutation
reran every viewer's effect — an endless round of resource requests.

Hold a scope for as long as a viewer is mounted and skip retained scopes when
evicting, so buckets in use are never dropped and nothing has to refetch. The
cap yields to correctness when everything mounted is in use.

Dropping the publish key also restores refetching when the fetch workspace
changes for an otherwise unchanged job and link.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: guard non-static brain edits during save, retain every displayed scope

Round-33 review findings:

- The in-flight edit guard compared the saved config, which holds only static
  brain values. A computed system prompt, memory or temperature changed while
  the save was awaiting the API therefore compared equal, and linking stripped
  it with no warning. Compare what linking actually discards — every brain
  transform and the tools — leaving the flow-local inputs free to change.
- Retaining run-viewer scopes made them fill the cap, and eviction then picked
  any unretained scope, including the editor bucket a user is looking at, with
  nothing to refetch it. Retain the scope each graph draws from for as long as
  it is mounted, so every displayed bucket is protected.
- A failed agent job has no parseable action list; the loader returned early
  and left the previously selected step's tool tree under the new header.
  Clear the view instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: resolve only flow modules in viewer scans, prune scopes on release

Round-34 review findings:

- Both viewer scans used the default dfs, which descends into agent tools, and
  published each linked agent under its bare id. Tool ids imported from a
  resource are not flow-global, so a nested linked agent sharing an id with a
  top-level step superseded that step's fetch and showed its tools instead.
  Scan flow modules only — the graph resolves the store per module node.
- Scopes skipped while retained were never reconsidered, so closing views left
  the store over its cap for the tab's life. Prune on release too.
- Correct two comments that still argued the premises the retain mechanism and
  the read-recency policy replaced.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: don't report success when a save left the step unlinked

Round-35 review nits:

- persist warns that changes made during the save are not in the resource and
  leaves the step alone, but both callers then toasted success unconditionally,
  burying the only actionable message. Report whether the step was linked.
- Condense the tool_inputs invariant to the four-line limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: seed the published link at mount, keep run history for toolless agents

Round-36 review findings:

- `publishedFor` started unset, but initFlowState has already published for the
  step's link by then. A link change landing before this component's own
  request therefore skipped the clear, leaving the previous agent's tools under
  the new link — indefinitely if the new one fails. Seed it from the link at
  mount.
- A standalone agent that omits `tools` kept `undefined` here, and the gate
  downstream then hid the AI message and tool-call history behind the generic
  result view. Default to an empty list like the other consumers.
- A save that lands after the step was replaced writes the resource but leaves
  the step alone; say so instead of closing the drawer with no outcome.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: qualify nested agent tool store keys, keep an empty tools identity stable

Round-37 review findings:

- The step editor keyed the linked-tools store by the bare module id for
  nested agent tools too. Those ids come from a resource and are not
  flow-global, so a nested linked agent sharing an id with a top-level step
  read that step's tools — then overwrote them once its own fetch landed.
  Qualify the key by the parent agent, as the edit store already does; flow
  modules keep the bare id the graph looks up.
- The `tools` binding handed the editor a fresh [] on every read when the
  module omits the field — a shape this PR made valid — so the save guard's
  identity check never matched and such a step could never link. Read through
  one shared empty array instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: accept the first tool on an agent module that omits tools

Round-38 review nit: the graph's tool insert required an existing `tools`
array, so a module authored without the field — valid since `tools` became
optional — swallowed the insert while still pushing history and dispatching a
change. Create the array on first use.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: don't evict a scope on the write that created it, and cover the store

Round-39 review findings:

- A rename removed the retained old key from the order but the new one is not
  retained until readers re-run, so eviction deleted the fresh bucket
  immediately. Reorder without evicting; the next publish or release enforces
  the cap, by which point the new key is held.
- Writing the test for that surfaced the same shape in touchScope: it evicts
  right after appending, so once every older scope is retained the scope just
  published was the only eligible victim and was dropped at once. Exclude the
  scope being written.

Add the store's first test: retention, eviction past the cap, pruning on
release, and the rename handoff — four rounds landed fixes here with nothing
pinning the behaviour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: re-resolve linked agents when a wholesale edit changes the links

Round-40 review findings:

- Undo/redo, YAML apply, AI apply and session restore swap a step's `agent`
  without re-running initFlowState, and the step editor only watches the step
  it is mounted on — so an unselected step kept showing, and binding against,
  the previous agent's tools. Re-resolve from the editor whenever the set of
  links changes.
- Document that linked resolution is live rather than pinned: an edit landing
  mid-run affects steps that have not started, and a nested agent tool looks
  its definition up by id when its own job starts, so it can run a changed
  definition. Pinning would mean carrying the resolved definition into the
  child job instead of its id; inline agents are unaffected because their
  tools are snapshotted with the flow value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: per-module empty tools identity, invalidate tools when a link is replaced

Both findings are over-corrections in the two preceding commits:

- The shared empty-tools array made identity stable, but stable everywhere: a
  wholesale edit that keeps the module id reuses the component, so when both
  the old and the replacement module omit tools the save guard saw no change
  and could link and clear the replacement. Hand out one empty array per
  module value, which a replacement always renews.
- The editor's link watcher resolved the replacement agent without dropping
  the previous one's tools first, so a step selected before the fetch landed
  still showed agent A under link B — and the freshly mounted editor seeds
  itself from B, so it could not tell. Clear the entry when the link for a
  module changes, seeding the map from the graph so the first run doesn't
  refetch what initFlowState just resolved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: reserve graph space for linked tools, re-resolve only changed links

Round-41 review nits:

- The layout reservation read the module's own `tools`, which is empty for a
  linked agent, so its display-only tool nodes were drawn over the node above
  in read-only viewers. Count the resolved tools for a linked step.
- The editor's link watcher refetched every linked agent on each run. Resolve
  only modules whose link actually changed, and skip the pass entirely on a
  rename, where the scope sweep has already carried the buckets over.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: protect a renamed scope until it is retained, drop the phantom tool row

Round-42 review nits:

- Readers release the old scope before retaining the new one, so a migrated
  bucket is unretained in between and, over the cap with everything else held,
  was the only thing eviction could take. Protect a just-migrated scope until a
  reader retains it, and cover that release/retain order in the store test.
- The layout reserved an add-tool row for linked agents, which have no add-tool
  node, leaving dead vertical space. Match computeAIToolNodes.
- Re-resolving links no longer short-circuits on a rename: comparing each
  module still costs nothing when only the path changed, and a restore that
  renames and relinks in one tick now gets both.
- Hoist the duplicated linked-tools lookup in the graph's store update.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: kill a scope's in-flight fetches before migrating it

Round-43 review finding: fetch generations are keyed by (scope, module), so a
resolution still running against the pre-rename scope keeps a valid generation
there. It publishes into the old bucket after the rename, and the doc-scope
sweep — which gives the source precedence — carries it forward over a link
resolved since under the new scope, leaving the graph and binding editor on the
previous agent's tool ids with nothing to refetch them.

Invalidate the source scope's fetches before each migration, and pin the
behaviour: the new test fails without the invalidation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: re-resolve links a scope sweep cancelled, and only sweep a real bucket

Round-44 review findings, both on the previous commit:

- Invalidating the source scope killed fetches that were perfectly current —
  a link still loading when the rename landed — and nothing restarted them,
  because the watcher already records that link. Resolve again, in the
  destination, every link the migration left without tools.
- The doc-scope sweep ran on every store version bump, so during a draft
  refresh the first completed fetch cancelled the others mid-flight. Skip the
  sweep entirely when the source scope holds nothing.
- Condense a six-line invariant to the four-line limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: split rename from doc sweep, hide brain fields of nested linked agents

Round-45 review findings:

- Two reviewers disagreed about invalidating a scope whose bucket is empty,
  because the two callers differ. A rename is a cut-off: every fetch still
  running against the old scope is stale whether or not anything resolved
  there, so it always invalidates. The doc-scope sweep has no cut-off — those
  fetches belong to the refresh in progress — so it still waits until that
  scope holds something.
- Recording the swept links as published undid the rename+relink fix: a
  restore that renames and swaps a link in one tick would keep the previous
  agent's tools with nothing to refetch them. Leave that comparison to the
  watcher, which compares links rather than presence.
- A nested agent that is itself linked was offered the whole agent schema in
  the tool bindings, but the runtime overlays only its flow-local inputs, so
  the rest were collected and dropped. Show what actually applies.
- Condense the hybrid-linking comment to the constraint.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: don't resolve a shared agent's tool defaults when loading it

Round-46 review finding: the whole agent resource was interpolated before
tool_inputs was overlaid, so each tool's default `$res:`/`$var:` resolved
first. A host flow overriding a default that points at the author's resource
still had to resolve that resource, and an unused tool whose default is
unreadable in the consumer's permission context failed the agent outright —
defeating the point of sharing an agent across contexts.

Read the resource raw, overlay the host's overrides, and interpolate only the
brain; each tool resolves its effective inputs when it executes. The nested
tool lookup reads raw too, since it only needs definitions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: interpolate the brain before overlaying caller inputs

Round-47 review findings, all on the previous commit:

- user_message and user_attachments were inserted before interpolation, so
  they went through it a second time: a user message of `$WM_TOKEN` expanded
  to the job token and was sent to the model provider. Interpolate the
  resource first, then overlay the already-resolved flow-local inputs.
- The relink watcher skips tool nodes, so a linked agent nested as a tool kept
  the previous agent's entry through undo, YAML/AI apply or a session restore,
  and the step editor seeds itself from the new link and cannot tell. Emit the
  ancestry-qualified key for those too.
- Correct the guide, which still named the interpolation path this branch
  replaced, and condense two invariants to the four-line limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: deploy $jsonvar deps, key run logs by tool identity, seed only top links

Round-48 review findings:

- The deploy walkers recognised `$res:` and `$var:` but not `$jsonvar:`, which
  the worker resolves too, so a secret referenced that way by an agent brain,
  a saved tool default or a host override never reached the target workspace.
- The run log rebuilt only when a tool's name or the tool count changed, so a
  refreshed resource that altered a tool's path, code or id behind the same
  name kept showing the old definition. Key on the array identity instead: the
  store swaps it exactly when the contents differ.
- Nested linked agents were seeded as already published, but initFlowState
  resolves only top-level links, so their tools never loaded until their
  editor was opened. Seed what initFlowState actually publishes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: let the watcher's fetch survive the step editor's stale-clear

Round-49 review nits:

- On a relink the step editor claimed the fetch generation before clearing the
  previous agent's tools, which discarded the watcher's already-running fetch
  for the new link. The tool nodes then only appeared if the step stayed
  selected until the editor's own refetch landed. Clear without claiming: the
  watcher superseded the old fetch when the link changed, so nothing stale can
  return. Unlink still claims, since no watcher fetch covers it.
- Condense the store's opening invariant to the four-line limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs: condense the stale-clear invariant

Round-50 review nit. Also records why the branch deliberately doesn't claim a
fetch generation: a reviewer asked for the opposite this round, but writing
`agent` re-runs the editor's watcher, which supersedes the old fetch and
starts one for the new link — claiming here would discard it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: guard Edit/Unlink by step identity, not just the link path

Round-51 review finding: forkFromResource compared only the agent path after
its fetch, so a module replaced mid-request while keeping the same link passed
the check — the stale continuation then wrote the fetched brain and tools into
the replacement and unlinked it. Compare the step's own `tools` array too,
which is one instance per module value and so identifies the step.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: report an Edit or Unlink abandoned because the step changed

Round-52 non-blocking note: forkFromResource returns undefined when the step
was replaced mid-request, and both callers treated that as do-nothing, so the
click looked ignored. Say what happened, as the save path already does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: hugocasa <hugo@casademont.ch>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@aanthropic.com>
2026-07-28 01:38:16 +02:00

1324 lines
47 KiB
YAML

openapi: '3.0.3'
info:
version: 1.773.0
title: OpenFlow Spec
contact:
name: Ruben Fiszel
email: ruben@windmill.dev
url: https://windmill.dev
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
paths: {}
externalDocs:
description: documentation portal
url: https://windmill.dev
components:
schemas:
OpenFlow:
type: object
description: Top-level flow definition containing metadata, configuration, and the flow structure
properties:
summary:
type: string
description: Short description of what this flow does
description:
type: string
description: Detailed documentation for this flow
value:
$ref: '#/components/schemas/FlowValue'
schema:
type: object
description: JSON Schema for flow inputs. Use this to define input parameters, their types, defaults, and validation. For resource inputs, set type to 'object' and format to 'resource-<type>' (e.g., 'resource-stripe')
on_behalf_of_email:
type: string
description: The flow will be run with the permissions of the user with this email.
required:
- summary
- value
FlowValue:
type: object
description: The flow structure containing modules and optional preprocessor/failure handlers
properties:
modules:
type: array
description: Array of steps that execute in sequence. Each step can be a script, subflow, loop, or branch
items:
$ref: '#/components/schemas/FlowModule'
failure_module:
description: Special module that executes when the flow fails. Receives error object with message, name, stack, and step_id. Must have id 'failure'. Only supports script/rawscript types
$ref: '#/components/schemas/FlowModule'
preprocessor_module:
description: Special module that runs before the first step on external triggers. Must have id 'preprocessor'. Only supports script/rawscript types. Cannot reference other step results
$ref: '#/components/schemas/FlowModule'
same_worker:
type: boolean
description: If true, all steps run on the same worker for better performance
preserve_step_tags:
type: boolean
description: If true and the flow runs on a custom worker tag, steps that declare their own non-empty tag run on it instead of inheriting the flow tag. Steps without their own tag still inherit the flow tag.
concurrent_limit:
type: number
description: Maximum number of concurrent executions of this flow
concurrency_key:
type: string
description: Expression to group concurrent executions (e.g., by user ID)
concurrency_time_window_s:
type: number
description: Time window in seconds for concurrent_limit
debounce_delay_s:
type: integer
description: Delay in seconds to debounce flow executions
debounce_key:
type: string
description: Expression to group debounced executions
debounce_args_to_accumulate:
type: array
description: Arguments to accumulate across debounced executions
items:
type: string
max_total_debouncing_time:
type: integer
description: Maximum total time in seconds that a job can be debounced
max_total_debounces_amount:
type: integer
description: Maximum number of times a job can be debounced
skip_expr:
type: string
description: JavaScript expression to conditionally skip the entire flow
cache_ttl:
type: number
description: Cache duration in seconds for flow results
cache_ignore_s3_path:
type: boolean
delete_after_secs:
type: integer
description: If set, delete the flow job's args, result and logs after this many seconds following job completion
flow_env:
type: object
description: "Environment variables available to all steps. Values can be strings, JSON values, or special references: '$var:path' (workspace variable) or '$res:path' (resource)."
additionalProperties: {}
priority:
type: number
description: Execution priority (higher numbers run first)
early_return:
type: string
description: JavaScript expression to return early from the flow
chat_input_enabled:
type: boolean
description: Whether this flow accepts chat-style input
notes:
type: array
description: Sticky notes attached to the flow
items:
$ref: '#/components/schemas/FlowNote'
groups:
type: array
description: Semantic groups of modules for organizational purposes
items:
$ref: '#/components/schemas/FlowGroup'
required:
- modules
Retry:
type: object
description: Retry configuration for failed module executions
properties:
constant:
type: object
description: Retry with constant delay between attempts
properties:
attempts:
type: integer
description: Number of retry attempts
seconds:
type: integer
description: Seconds to wait between retries
exponential:
type: object
description: Retry with exponential backoff (delay doubles each time)
properties:
attempts:
type: integer
description: Number of retry attempts
multiplier:
type: integer
description: Multiplier for exponential backoff
seconds:
type: integer
minimum: 1
description: Initial delay in seconds
random_factor:
type: integer
minimum: 0
maximum: 100
description: Random jitter percentage (0-100) to avoid thundering herd
retry_if:
$ref: '#/components/schemas/RetryIf'
FlowNote:
type: object
description: A sticky note attached to a flow for documentation and annotation
properties:
id:
type: string
description: Unique identifier for the note
text:
type: string
description: Content of the note
position:
type: object
description: Position of the note in the flow editor
properties:
x:
type: number
description: X coordinate
y:
type: number
description: Y coordinate
required:
- x
- y
size:
type: object
description: Size of the note in the flow editor
properties:
width:
type: number
description: Width in pixels
height:
type: number
description: Height in pixels
required:
- width
- height
color:
type: string
description: Color of the note (e.g., "yellow", "#ffff00")
type:
type: string
enum: [free, group]
description: Type of note - 'free' for standalone notes, 'group' for notes that group other nodes
locked:
type: boolean
default: false
description: Whether the note is locked and cannot be edited or moved
contained_node_ids:
type: array
items:
type: string
description: For group notes, the IDs of nodes contained within this group
required:
- id
- text
- color
- type
FlowGroup:
type: object
description: A semantic group of flow modules for organizational purposes. Does not affect execution — modules remain in their original position in the flow. Groups provide naming and collapsibility in the editor. Members are computed dynamically from all nodes on paths between start_id and end_id.
properties:
summary:
type: string
description: Display name for this group
note:
type: string
description: Markdown note shown below the group header
autocollapse:
type: boolean
default: false
description: If true, this group is collapsed by default in the flow editor. UI hint only.
start_id:
type: string
description: ID of the first flow module in this group (topological entry point)
end_id:
type: string
description: ID of the last flow module in this group (topological exit point)
color:
type: string
description: Color for the group in the flow editor
required:
- start_id
- end_id
RetryIf:
type: object
description: Conditional retry based on error or result
properties:
expr:
type: string
description: JavaScript expression that returns true to retry. Has access to 'result' and 'error' variables
required:
- expr
StopAfterIf:
type: object
description: Early termination condition for a module
properties:
skip_if_stopped:
type: boolean
description: If true, following steps are skipped when this condition triggers
expr:
type: string
description: JavaScript expression evaluated after the module runs. Can use 'result' (step's result) or 'flow_input'. Return true to stop
error_message:
type: string
nullable: true
description: Custom error message when stopping with an error. Mutually exclusive with skip_if_stopped. If set to a non-empty string, the flow stops with this error. If empty string, a default error message is used. If null or omitted, no error is raised.
error_include_result:
type: boolean
description: "When stopping with an error (error_message set), embed the stopping step's own result inside the raised error object (as error.result) instead of discarding it. The top-level result stays { error }. Defaults to false."
required:
- expr
FlowModule:
type: object
description: A single step in a flow. Can be a script, subflow, loop, or branch
properties:
id:
type: string
description: Unique identifier for this step. Used to reference results via 'results.step_id'. Must be a valid identifier (alphanumeric, underscore, hyphen)
value:
$ref: '#/components/schemas/FlowModuleValue'
stop_after_if:
description: Early termination condition evaluated after this step completes
$ref: '#/components/schemas/StopAfterIf'
stop_after_all_iters_if:
description: For loops only - early termination condition evaluated after all iterations complete
$ref: '#/components/schemas/StopAfterIf'
skip_if:
type: object
description: Conditionally skip this step based on previous results or flow inputs
properties:
expr:
type: string
description: JavaScript expression that returns true to skip. Can use 'flow_input' or 'results.<step_id>'
required:
- expr
sleep:
description: Delay before executing this step (in seconds or as expression)
$ref: '#/components/schemas/InputTransform'
cache_ttl:
type: number
description: Cache duration in seconds for this step's results
cache_ignore_s3_path:
type: boolean
timeout:
description: Maximum execution time in seconds (static value or expression)
$ref: '#/components/schemas/InputTransform'
delete_after_secs:
type: integer
description: If set, delete the step's args, result and logs after this many seconds following job completion
summary:
type: string
description: Short description of what this step does
mock:
type: object
description: Mock configuration for testing without executing the actual step
properties:
enabled:
type: boolean
description: If true, return mock value instead of executing
return_value:
description: Value to return when mocked
suspend:
type: object
description: Configuration for approval/resume steps that wait for user input
properties:
required_events:
type: integer
description: Number of approvals required before continuing
timeout:
type: integer
description: Timeout in seconds before auto-continuing or canceling
resume_form:
type: object
description: Form schema for collecting input when resuming
properties:
schema:
type: object
description: JSON Schema for the resume form
user_auth_required:
type: boolean
description: If true, only authenticated users can approve
user_groups_required:
description: Expression or list of groups that can approve
$ref: '#/components/schemas/InputTransform'
self_approval_disabled:
type: boolean
description: If true, the user who started the flow cannot approve
hide_cancel:
type: boolean
description: If true, hide the cancel button on the approval form
continue_on_disapprove_timeout:
type: boolean
description: If true, continue flow on timeout instead of canceling
priority:
type: number
description: Execution priority for this step (higher numbers run first)
continue_on_error:
type: boolean
description: If true, flow continues even if this step fails
retry:
description: Retry configuration if this step fails
$ref: '#/components/schemas/Retry'
debouncing:
description: "Debounce configuration for this step (EE only)"
type: object
properties:
debounce_delay_s:
type: integer
description: Delay in seconds to debounce this step's executions across flow runs
debounce_key:
type: string
description: "Expression to group debounced executions. Supports $workspace and $args[name]. Default: $workspace/flow/<flow_path>-<step_id>"
debounce_args_to_accumulate:
type: array
description: Array-type arguments to accumulate across debounced executions
items:
type: string
max_total_debouncing_time:
type: integer
description: Maximum total time in seconds before forced execution
max_total_debounces_amount:
type: integer
description: Maximum number of debounces before forced execution
required:
- value
- id
InputTransform:
description: Maps input parameters for a step. Can be a static value or a JavaScript expression that references previous results or flow inputs
oneOf:
- $ref: '#/components/schemas/StaticTransform'
- $ref: '#/components/schemas/JavascriptTransform'
- $ref: '#/components/schemas/AiTransform'
discriminator:
propertyName: type
mapping:
static: '#/components/schemas/StaticTransform'
javascript: '#/components/schemas/JavascriptTransform'
ai: '#/components/schemas/AiTransform'
StaticTransform:
type: object
description: Static value passed directly to the step. Use for hardcoded values or resource references like '$res:path/to/resource'
properties:
value:
description: The static value. For resources, use format '$res:path/to/resource'
type:
type: string
enum:
- static
required:
- type
JavascriptTransform:
type: object
description: JavaScript expression evaluated at runtime. Can reference previous step results via 'results.step_id' or flow inputs via 'flow_input.property'. Inside for loops, use 'flow_input.iter.value' for the current iteration value (in while loops it equals 'flow_input.iter.index')
properties:
expr:
type: string
description: JavaScript expression returning the value. Available variables - results (object with all previous step results), flow_input (flow inputs), flow_input.iter (in loops)
type:
type: string
enum:
- javascript
required:
- expr
- type
AiTransform:
type: object
description: Value resolved by the AI runtime for this input. The AI engine decides how to satisfy the parameter.
properties:
type:
type: string
enum:
- ai
required:
- type
# Provider configuration schemas
AIProviderKind:
type: string
description: Supported AI provider types
enum:
- openai
- azure_openai
- azure_foundry
- anthropic
- mistral
- deepseek
- googleai
- groq
- openrouter
- togetherai
- customai
- aws_bedrock
ProviderConfig:
type: object
description: Complete AI provider configuration with resource reference and model selection
properties:
kind:
$ref: '#/components/schemas/AIProviderKind'
resource:
type: string
description: Resource reference in format '$res:{resource_path}' pointing to provider credentials
model:
type: string
description: Model identifier (e.g., 'gpt-4', 'claude-3-opus-20240229', 'gemini-pro')
reasoning_effort:
type: string
description: Provider-native reasoning effort token (e.g. 'low', 'high', 'none') for models that support extended thinking. Optional; unset leaves the provider default.
required:
- kind
- resource
- model
StaticProviderTransform:
type: object
description: Static provider configuration passed directly to the AI agent
properties:
value:
$ref: '#/components/schemas/ProviderConfig'
type:
type: string
enum:
- static
required:
- type
- value
ProviderTransform:
description: Provider configuration - can be static (ProviderConfig), JavaScript expression, or AI-determined
oneOf:
- $ref: '#/components/schemas/StaticProviderTransform'
- $ref: '#/components/schemas/JavascriptTransform'
- $ref: '#/components/schemas/AiTransform'
discriminator:
propertyName: type
mapping:
static: '#/components/schemas/StaticProviderTransform'
javascript: '#/components/schemas/JavascriptTransform'
ai: '#/components/schemas/AiTransform'
# Memory configuration schemas
MemoryOff:
type: object
description: No conversation memory/context
properties:
kind:
type: string
enum:
- 'off'
required:
- kind
MemoryAuto:
type: object
description: Automatic context management
properties:
kind:
type: string
enum:
- auto
context_length:
type: integer
description: Maximum number of messages to retain in context
memory_id:
type: string
description: Identifier for persistent memory across agent invocations
required:
- kind
MemoryMessage:
type: object
description: A single message in conversation history
properties:
role:
type: string
enum:
- user
- assistant
- system
content:
type: string
required:
- role
- content
MemoryManual:
type: object
description: Explicit message history
properties:
kind:
type: string
enum:
- manual
messages:
type: array
items:
$ref: '#/components/schemas/MemoryMessage'
required:
- kind
- messages
MemoryConfig:
description: Conversation memory configuration
oneOf:
- $ref: '#/components/schemas/MemoryOff'
- $ref: '#/components/schemas/MemoryAuto'
- $ref: '#/components/schemas/MemoryManual'
discriminator:
propertyName: kind
mapping:
'off': '#/components/schemas/MemoryOff'
auto: '#/components/schemas/MemoryAuto'
manual: '#/components/schemas/MemoryManual'
StaticMemoryTransform:
type: object
description: Static memory configuration passed directly to the AI agent
properties:
value:
$ref: '#/components/schemas/MemoryConfig'
type:
type: string
enum:
- static
required:
- type
- value
MemoryTransform:
description: Memory configuration - can be static (MemoryConfig), JavaScript expression, or AI-determined
oneOf:
- $ref: '#/components/schemas/StaticMemoryTransform'
- $ref: '#/components/schemas/JavascriptTransform'
- $ref: '#/components/schemas/AiTransform'
discriminator:
propertyName: type
mapping:
static: '#/components/schemas/StaticMemoryTransform'
javascript: '#/components/schemas/JavascriptTransform'
ai: '#/components/schemas/AiTransform'
FlowModuleValue:
description: The actual implementation of a flow step. Can be a script (inline or referenced), subflow, loop, branch, or special module type
oneOf:
- $ref: '#/components/schemas/RawScript'
- $ref: '#/components/schemas/PathScript'
- $ref: '#/components/schemas/PathFlow'
- $ref: '#/components/schemas/ForloopFlow'
- $ref: '#/components/schemas/WhileloopFlow'
- $ref: '#/components/schemas/BranchOne'
- $ref: '#/components/schemas/BranchAll'
- $ref: '#/components/schemas/Identity'
- $ref: '#/components/schemas/AiAgent'
discriminator:
propertyName: type
mapping:
rawscript: '#/components/schemas/RawScript'
script: '#/components/schemas/PathScript'
flow: '#/components/schemas/PathFlow'
forloopflow: '#/components/schemas/ForloopFlow'
whileloopflow: '#/components/schemas/WhileloopFlow'
branchone: '#/components/schemas/BranchOne'
branchall: '#/components/schemas/BranchAll'
identity: '#/components/schemas/Identity'
aiagent: '#/components/schemas/AiAgent'
RawScript:
type: object
description: Inline script with code defined directly in the flow. Use 'bun' as default language if unspecified. The script receives arguments from input_transforms
properties:
# to be made required once migration is over
input_transforms:
type: object
description: Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments
additionalProperties:
$ref: '#/components/schemas/InputTransform'
content:
type: string
description: The script source code. Should export a 'main' function
language:
type: string
description: Programming language for this script
enum:
- deno
- bun
- bunnative
- python3
- go
- bash
- powershell
- postgresql
- mysql
- bigquery
- snowflake
- mssql
- oracledb
- graphql
- nativets
- php
- rust
- ansible
- csharp
- nu
- java
- ruby
- rlang
- duckdb
# for related places search: ADD_NEW_LANG
path:
type: string
description: Optional path for saving this script
lock:
type: string
description: Lock file content for dependencies
type:
type: string
enum:
- rawscript
tag:
type: string
description: Worker group tag for execution routing
concurrent_limit:
type: number
description: Maximum concurrent executions of this script
concurrency_time_window_s:
type: number
description: Time window for concurrent_limit
custom_concurrency_key:
type: string
description: Custom key for grouping concurrent executions
is_trigger:
type: boolean
description: If true, this script is a trigger that can start the flow
assets:
type: array
description: External resources this script accesses (S3 objects, resources, etc.)
items:
type: object
required:
- path
- kind
properties:
path:
type: string
description: Path to the asset
kind:
type: string
description: Type of asset
enum:
- s3object
- resource
- ducklake
- datatable
- volume
access_type:
type: string
nullable: true
description: Access level for this asset
enum: [r, w, rw]
alt_access_type:
type: string
nullable: true
description: Alternative access level
enum: [r, w, rw]
required:
- type
- content
- language
- input_transforms
PathScript:
type: object
description: Reference to an existing script by path. Use this when calling a previously saved script instead of writing inline code
properties:
input_transforms:
type: object
description: Map of parameter names to their values (static or JavaScript expressions). These become the script's input arguments
additionalProperties:
$ref: '#/components/schemas/InputTransform'
path:
type: string
description: Path to the script in the workspace (e.g., 'f/scripts/send_email')
hash:
type: string
description: Optional specific version hash of the script to use
type:
type: string
enum:
- script
tag_override:
type: string
description: Override the script's default worker group tag
is_trigger:
type: boolean
description: If true, this script is a trigger that can start the flow
required:
- type
- path
- input_transforms
PathFlow:
type: object
description: Reference to an existing flow by path. Use this to call another flow as a subflow
properties:
input_transforms:
type: object
description: Map of parameter names to their values (static or JavaScript expressions). These become the subflow's input arguments
additionalProperties:
$ref: '#/components/schemas/InputTransform'
path:
type: string
description: Path to the flow in the workspace (e.g., 'f/flows/process_user')
type:
type: string
enum:
- flow
required:
- type
- path
- input_transforms
ForloopFlow:
type: object
description: Executes nested modules in a loop over an iterator. Inside the loop, use 'flow_input.iter.value' to access the current iteration value, and 'flow_input.iter.index' for the index. Supports parallel execution for better performance on I/O-bound operations
properties:
modules:
type: array
description: Steps to execute for each iteration. These can reference the iteration value via 'flow_input.iter.value'
items:
$ref: '#/components/schemas/FlowModule'
iterator:
description: JavaScript expression that returns an array to iterate over. Can reference 'results.step_id' or 'flow_input'
$ref: '#/components/schemas/InputTransform'
skip_failures:
type: boolean
description: If true, iteration failures don't stop the loop. Failed iterations return null
type:
type: string
enum:
- forloopflow
parallel:
type: boolean
description: If true, iterations run concurrently (faster for I/O-bound operations). Use with parallelism to control concurrency
parallelism:
description: Maximum number of concurrent iterations when parallel=true. Limits resource usage. Can be static number or expression
$ref: '#/components/schemas/InputTransform'
squash:
type: boolean
required:
- modules
- iterator
- skip_failures
- type
WhileloopFlow:
type: object
description: Executes nested modules repeatedly until stopped. The implicit iterator is the iteration counter, so 'flow_input.iter.value' equals 'flow_input.iter.index' (0, 1, 2, ...) and never carries state. To carry state across iterations, a step reads its own previous-iteration result via 'results.<its_own_id>' with a first-iteration fallback - the loop's stop_after_if must then be on that inner step (a plain single-step body with stop_after_if on the loop module does not resolve 'results' across iterations and never terminates); plain counters can instead be derived from 'flow_input.iter.index', which works in every configuration. stop_after_if is evaluated after each iteration - on the loop module 'result' is the last iteration's result
properties:
modules:
type: array
description: Steps to execute in each iteration
items:
$ref: '#/components/schemas/FlowModule'
skip_failures:
type: boolean
description: If true, iteration failures don't stop the loop. Failed iterations return null
type:
type: string
enum:
- whileloopflow
parallel:
type: boolean
description: If true, iterations run concurrently (use with caution in while loops)
parallelism:
description: Maximum number of concurrent iterations when parallel=true
$ref: '#/components/schemas/InputTransform'
squash:
type: boolean
required:
- modules
- skip_failures
- type
BranchOne:
type: object
description: Conditional branching where only the first matching branch executes. Branches are evaluated in order, and the first one with a true expression runs. If no branches match, the default branch executes
properties:
branches:
type: array
description: Array of branches to evaluate in order. The first branch with expr evaluating to true executes
items:
type: object
properties:
summary:
type: string
description: Short description of this branch condition
expr:
type: string
description: JavaScript expression that returns boolean. Can use 'results.step_id' or 'flow_input'. First true expr wins
modules:
type: array
description: Steps to execute if this branch's expr is true
items:
$ref: '#/components/schemas/FlowModule'
required:
- modules
- expr
default:
type: array
description: Steps to execute if no branch expressions match
items:
$ref: '#/components/schemas/FlowModule'
type:
type: string
enum:
- branchone
required:
- branches
- default
- type
BranchAll:
type: object
description: Parallel branching where all branches execute simultaneously. Unlike BranchOne, all branches run regardless of conditions. Useful for executing independent tasks concurrently
properties:
branches:
type: array
description: Array of branches that all execute (either in parallel or sequentially)
items:
type: object
properties:
summary:
type: string
description: Short description of this branch's purpose
skip_failure:
type: boolean
description: If true, failure in this branch doesn't fail the entire flow
modules:
type: array
description: Steps to execute in this branch
items:
$ref: '#/components/schemas/FlowModule'
required:
- modules
type:
type: string
enum:
- branchall
parallel:
type: boolean
description: If true, all branches execute concurrently. If false, they execute sequentially
required:
- branches
- type
AgentTool:
type: object
description: A tool available to an AI agent. Can be a flow module or an external MCP (Model Context Protocol) tool
properties:
id:
type: string
description: Unique identifier for this tool. Cannot contain spaces - use underscores instead (e.g., 'get_user_data' not 'get user data')
summary:
type: string
description: Short description of what this tool does (shown to the AI)
description:
type: string
description: Free-text description of the tool given to the AI to decide when and how to call it. Overrides the description auto-derived from the underlying script.
value:
$ref: '#/components/schemas/ToolValue'
required:
- id
- value
ToolValue:
description: The implementation of a tool. Can be a flow module (script/flow) or an MCP tool reference
oneOf:
- $ref: '#/components/schemas/FlowModuleTool'
- $ref: '#/components/schemas/McpToolValue'
- $ref: '#/components/schemas/WebsearchToolValue'
discriminator:
propertyName: tool_type
mapping:
flowmodule: '#/components/schemas/FlowModuleTool'
mcp: '#/components/schemas/McpToolValue'
websearch: '#/components/schemas/WebsearchToolValue'
FlowModuleTool:
description: A tool implemented as a flow module (script, flow, etc.). The AI can call this like any other flow module
allOf:
- type: object
properties:
tool_type:
type: string
enum:
- flowmodule
required:
- tool_type
- $ref: '#/components/schemas/FlowModuleValue'
WebsearchToolValue:
type: object
description: A tool implemented as a websearch tool. The AI can call this like any other websearch tool
properties:
tool_type:
type: string
enum:
- websearch
required:
- tool_type
McpToolValue:
type: object
description: Reference to an external MCP (Model Context Protocol) tool. The AI can call tools from MCP servers
properties:
tool_type:
type: string
enum:
- mcp
resource_path:
type: string
description: Path to the MCP resource/server configuration
include_tools:
type: array
description: Whitelist of specific tools to include from this MCP server
items:
type: string
exclude_tools:
type: array
description: Blacklist of tools to exclude from this MCP server
items:
type: string
required:
- tool_type
- resource_path
AiAgent:
type: object
description: AI agent step that can use tools to accomplish tasks. The agent receives inputs and can call any of its configured tools to complete the task
properties:
input_transforms:
type: object
description: Input parameters for the AI agent mapped to their values
properties:
provider:
$ref: '#/components/schemas/ProviderTransform'
output_type:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
Output format type.
Valid values: 'text' (default) - plain text response, 'image' - image generation
user_message:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: The user's prompt/message to the AI agent. Supports variable interpolation with flow.input syntax.
system_prompt:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: System instructions that guide the AI's behavior, persona, and response style. Optional.
streaming:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
Boolean. If true, stream the AI response incrementally.
Streaming events include: token_delta, reasoning_token_delta, tool_call, tool_call_arguments, tool_execution, tool_result
memory:
$ref: '#/components/schemas/MemoryTransform'
output_schema:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
JSON Schema object defining structured output format. Used when you need the AI to return data in a specific shape.
Supports standard JSON Schema properties: type, properties, required, items, enum, pattern, minLength, maxLength, minimum, maximum, etc.
Example: { type: 'object', properties: { name: { type: 'string' }, age: { type: 'integer' } }, required: ['name'] }
user_attachments:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
Array of file references (images or PDFs) for the AI agent.
Format: Array<{ bucket: string, key: string }> - S3 object references
Example: [{ bucket: 'my-bucket', key: 'documents/report.pdf' }]
max_completion_tokens:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
Integer. Maximum number of tokens the AI will generate in its response.
Range: 1 to 4,294,967,295. Typical values: 256-4096 for most use cases.
temperature:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
Float. Controls randomness/creativity of responses.
Range: 0.0 to 2.0 (provider-dependent)
- 0.0 = deterministic, focused responses
- 0.7 = balanced (common default)
- 1.0+ = more creative/random
max_iterations:
allOf:
- $ref: '#/components/schemas/InputTransform'
description: |
Number. Limits how many times the agent can loop through reasoning and tool use.
Range: 1-1000.
# Only the flow-local inputs are always present: a step linked to an `ai_agent` resource
# (see `agent`) keeps just those and takes provider/output_type from the resource.
required:
- user_message
tools:
type: array
description: Array of tools the agent can use. The agent decides which tools to call based on the task
items:
$ref: '#/components/schemas/AgentTool'
type:
type: string
enum:
- aiagent
tag:
type: string
description: Worker group tag for execution routing. If not set, the AI agent step runs on the flow's tag (default `flow`)
omit_output_from_conversation:
type: boolean
default: false
description: If true, this AI agent step does not persist its assistant or tool messages to the flow conversation when chat mode is enabled.
agent:
type: string
description: |
Path of a reusable `ai_agent` resource (hybrid linking). When set, the agent brain
config (provider/model/system prompt/etc.) and tool set are resolved at runtime from
that resource; the module's input_transforms then only carry the flow-local inputs
(user_message/user_attachments).
tool_inputs:
type: object
description: |
Host-local wiring for an agent's tool inputs, keyed by tool id then input key. Binds the
referenced agent's tools to this flow's context (flow_input/results) without mutating the
shared resource; overlaid onto the tools' input_transforms at runtime — including when
`agent` is unset, since a step forked for editing keeps these overrides until it is saved
back or unlinked.
additionalProperties:
type: object
additionalProperties:
$ref: '#/components/schemas/InputTransform'
parallel:
type: boolean
description: If true, the agent can execute multiple tool calls in parallel
required:
- type
- input_transforms
Identity:
type: object
description: Pass-through module that returns its input unchanged. Useful for flow structure or as a placeholder
properties:
type:
type: string
enum:
- identity
flow:
type: boolean
description: If true, marks this as a flow identity (special handling)
required:
- type
FlowStatus:
type: object
properties:
step:
type: integer
modules:
type: array
items:
$ref: '#/components/schemas/FlowStatusModule'
user_states:
additionalProperties: true
preprocessor_module:
allOf:
- $ref: '#/components/schemas/FlowStatusModule'
failure_module:
allOf:
- $ref: '#/components/schemas/FlowStatusModule'
- type: object
properties:
parent_module:
type: string
retry:
type: object
properties:
fail_count:
type: integer
failed_jobs:
type: array
items:
type: string
format: uuid
required:
- step
- modules
- failure_module
FlowStatusModule:
type: object
properties:
type:
type: string
enum:
- WaitingForPriorSteps
- WaitingForEvents
- WaitingForExecutor
- InProgress
- Success
- Failure
id:
type: string
job:
type: string
format: uuid
count:
type: integer
progress:
type: integer
iterator:
type: object
properties:
index:
type: integer
itered:
type: array
items: {}
itered_len:
type: integer
args: {}
flow_jobs:
type: array
items:
type: string
flow_jobs_success:
type: array
items:
type: boolean
flow_jobs_duration:
type: object
properties:
started_at:
type: array
items:
type: string
duration_ms:
type: array
items:
type: integer
branch_chosen:
type: object
properties:
type:
type: string
enum: [branch, default]
branch:
type: integer
required:
- type
branchall:
type: object
properties:
branch:
type: integer
len:
type: integer
required:
- branch
- len
approvers:
type: array
items:
type: object
properties:
resume_id:
type: integer
approver:
type: string
required:
- resume_id
- approver
failed_retries:
type: array
items:
type: string
format: uuid
skipped:
type: boolean
agent_actions:
type: array
items:
type: object
oneOf:
- type: object
properties:
job_id:
type: string
format: uuid
function_name:
type: string
type:
type: string
enum: [tool_call]
module_id:
type: string
required:
- job_id
- function_name
- type
- module_id
- type: object
properties:
call_id:
type: string
format: uuid
function_name:
type: string
resource_path:
type: string
type:
type: string
enum: [mcp_tool_call]
arguments:
type: object
required:
- call_id
- function_name
- resource_path
- type
- type: object
properties:
type:
type: string
enum: [web_search]
required:
- type
- type: object
properties:
type:
type: string
enum: [message]
required:
- content
- type
agent_actions_success:
type: array
items:
type: boolean
required: [type]