Skip to content

0136 — Workflow step kinds, typed outputs and graph-editing tools ​

Context ​

plugins/workflows/engine.py runs a recipe DAG whose steps each delegate to a subagent through subagent and prompt. Steps pass a single text blob through {{steps.<id>.output}}. This supports reusable prompt pipelines, but extracting structured fields, performing deterministic transformations and branching need a richer authoring model.

Hermes Workflow Studio provides typed ports, Python code nodes, conditional branches, a reusable node library and about eighteen small agent tools for editing a graph. It does not provide durable background runs. We adopt its authoring model while keeping our engine's background runs, human gates, resume, run history and tracing.

This amends ADR 0002's subagent-only step model and its deferral of code execution and conditionals. Recipes remain declarative DAGs; explicit code steps use the existing execute_code trust model.

Decision ​

D1 — Step kinds are optional and backward compatible. A step gains an optional kind: subagent, code, condition or tool (added by D7). The default is subagent, with today's subagent and prompt behaviour. Recipes without kind or outputs run exactly as before. Every existing recipe remains valid unchanged.

D2 — Named, typed outputs supplement the raw output. A step may declare outputs: [{name, type}], where type is text or json. A step with declared outputs must produce a JSON object containing the named fields with their declared types. Each field is reachable as {{steps.<id>.outputs.<name>}}. {{steps.<id>.output}} stays the whole raw output, including for steps that declare named outputs. Steps without declarations retain today's behaviour.

D3 — Code steps execute through a plugin service. Python code runs through the execute_code plugin's execute_code.run service, resolved with graph.sdk.service("execute_code.run") at call time following ADR 0116. The workflow engine never imports execute_code directly and never executes the script in the gateway process. Rendered input templates arrive as a JSON inputs dict; the step output is the script's result.

If execute_code is disabled or the service is unavailable, the step fails with an actionable message telling the operator to enable a version of execute_code that provides execute_code.run. There is no in-process fallback. The trust model is the same as execute_code, including the process boundary discussed in ADR 0134: process separation, not a sandbox. This decision does not require session kernels to be enabled.

D4 — Conditions select branches and record skipped work. A condition step evaluates a small safe expression to true or false. The expression language allows comparisons, and / or / not, literals and template references; it allows no calls or attribute access. Template references are resolved as data, not treated as permission for general attribute access.

Steps declare when: {step: <condition id>, is: true|false} to select a branch. The condition must be resolved before the guarded step runs. A step whose when does not match is recorded with the new skipped status. Dependents that require that step are skipped too, transitively. Skipped is not failed; an untaken branch is an expected execution outcome.

D5 — Small graph-editing tools accompany save_workflow. Add get_workflow, add_workflow_step, update_workflow_step, remove_workflow_step, connect_workflow_steps and disconnect_workflow_steps beside save_workflow. get_workflow reads the recipe for inspection. Each editing tool validates the candidate recipe with validate_recipe and saves the writable copy only when valid. Invalid edits return the validation errors without saving, leaving the existing recipe intact. These tools share the whole-recipe validation contract instead of letting incremental graph edits bypass it.

D6 — Studio design precedes boarding UI work. The Studio refresh covers a node palette, data versus order edges, live runs on the canvas, single-step rerun, import/export and a gallery. designSystem designs it and Josh approves it before it is boarded. This refresh is out of scope for the engine cards.

D7 — Tool steps (2026-12-01). A step may use kind: tool with tool: <name> and args: {name: template} to call one tool with rendered arguments. It runs through the execute_code plugin's execute_code.call_tool service, following ADR 0116. The service applies the same policy as execute_code's bridged calls (ADR 0103 S4): only tools in execute_code's bridge allowlist (tools / extra_tools) can run, the enforcement denylist and rate limits apply, and every call writes the ptc: audit row. Workflow-editing tools and run_workflow are refused so a recipe cannot recurse. No new path around tool policy is added.

Rejected alternatives ​

  • Replace our engine with Hermes's engine. Rejected because it lacks durable background execution. Adopt the authoring model while retaining our existing execution lifecycle and observability.
  • Arbitrary tool-call steps. Originally deferred pending a fenced tool bridge; D7 resolves this with execute_code.call_tool under the existing bridge policy.

Consequences ​

  • Compatibility. Every recipe in plugins/workflows/recipes remains valid unchanged. Existing raw-output references and subagent execution keep their behaviour; typed output contracts and new kinds are opt-in.
  • Execution and validation. The engine gains deterministic Python transformations and conditional branches, while validation gains step-kind, output-contract and branch-reference checks. Code steps depend on an available execute_code service and carry its existing trust requirements.
  • Tool access. Tool steps also require execute_code. An operator widens what they can call through execute_code's extra_tools setting; enforcement and recursion refusals still apply.
  • Run records and Studio. Run records gain skipped. Consumers must distinguish skipped work from failure, and the Studio must render the new kinds and statuses as follow-up UI work.
  • Durability and evidence. Background runs, human gates, resume, run history and tracing remain engine responsibilities. Receipts stay bound to each physical run, step and execution segment: outputs seeded on resume are not_executed in the current segment, with earlier receipts retained under their original identity. Unsupported capture, captured-empty, partial loss and not-executed remain distinct; consumers inspect capability, status and loss counters alongside tool_calls, whose empty map alone cannot establish review coverage.

Part of the protoLabs autonomous development studio.