Execution flow reference
This page lists every field and option. The overview shows what it does and a first example.
How kdeps resolves, orders, and runs resources in a workflow. kdeps run runs that DAG directly.
Overview
When you run kdeps run workflow.yaml or call POST /api/v1/run, the engine:
- Parses the workflow and builds a dependency graph from
requiresfields - Detects cycles (fails fast if any exist)
- Finds the
targetActionIdresource and walks its transitive dependencies - Topologically sorts resources so dependencies run before dependents. The order is the same on each run. kdeps uses the
requiresof a resource in the order that the resource lists them - Executes resources in that order, running independent resources in parallel (see Independent resources)
Execution order
Dependency graph
How requires works
# workflow.yaml (conceptual)
metadata:
targetActionId: respond # engine walks backward from here
resources:
- actionId: fetchData
component:
name: http_request
with:
url: https://api.example.com/data
- actionId: analyzeData
flow:
requires: [fetchData] # runs only after fetchData succeeds
chat:
context:
prompt: "Analyze: {{ output('fetchData') }}"
- actionId: respond
flow:
requires: [analyzeData] # runs only after analyzeData succeeds
apiResponse:
response: "{{ output('analyzeData') }}"Execution order: fetchData -> analyzeData -> respond
Transitive dependencies
The engine resolves the full transitive closure. If A requires B, and B requires C, then C runs before both:
# resources/example.yaml
- actionId: C
component:
name: exec
with:
command: echo "first"
- actionId: B
requires: [C]
chat:
prompt: "Build on: {{ output('C') }}"
- actionId: A
requires: [B]
apiResponse:
response: "{{ output('B') }}"Execution order: C -> B -> A
Independent resources
Resources that do not depend on each other run in parallel, a maximum of 4 at the same time. A resource starts only after its requires finish:
# resources/example.yaml
- actionId: draft
chat:
prompt: "{{ get('q') }}"
- actionId: reviewScope # requires draft only: runs beside reviewRisks
requires: [draft]
chat:
prompt: "Review the scope: {{ output('draft') }}"
- actionId: reviewRisks
requires: [draft]
chat:
prompt: "Review the risks: {{ output('draft') }}"
- actionId: report
requires: [reviewScope, reviewRisks] # starts when both reviews finish
chat:
prompt: "Merge: {{ output('reviewScope') }} {{ output('reviewRisks') }}"reviewScope and reviewRisks run at the same time. report waits for both.
The engine also orders resources that share a key without requires:
| In a resource's YAML | Effect |
|---|---|
get('k') after another resource's set('k') | waits for the writer |
set('k') after another resource's get('k') or set('k') | keeps their order |
output('id') or get('id') of another resource | waits for that resource |
A component: call runs beside others when the component is read-only in the permission policy (web_search, read_file, web_scraper, ...) and has no teardown:. Each call gets its own inputs and outputs. As a result, three web_search calls with different queries run at the same time. Other components (write_file, bash_exec, http_request, ...) run alone.
A resource whose effects the YAML can't show also runs alone, in its usual place: exec:, python:, items:, loop:, apiResponse:, chat with tools, header or param validations, a computed key (get(name)), 'item'/'loop' storage, session() and memory_* calls.
One cap covers workflow resources, subagents, judges, and loop tool calls. It is the parallel event:
# ~/.kdeps/events/parallel.yaml
name: parallel
items: 4 # tasks that run at once, in each batch
run: cap
disabled: false # true runs everything one at a timeCycle detection
The engine detects cycles during graph construction and fails fast with ErrCodeDependencyCycle:
# This creates a cycle and will fail:
- actionId: A
requires: [B]
- actionId: B
requires: [A] # cycle: A -> B -> ASkip vs check
Both run before the main action, but they behave differently:
| skip | check | |
|---|---|---|
| Logic | ANY expression true triggers skip | ALL expressions must be true |
| On failure | Resource skipped silently, workflow continues | Workflow stops, error returned |
| Error code | N/A | Configurable via validations.error.code |
| Use case | Conditional execution, optional resources | Input validation, preconditions |
Skip example
# resources/example.yaml
validations:
skip:
- get('q') == '' # if query is empty, skip this resourceCheck example
# resources/example.yaml
validations:
check:
- get('apiKey') != nil # must have API key
- len(get('q')) <= 500 # query must be under 500 chars
error:
code: 400
message: Missing API key or query too longLoop execution
When a resource has a loop config, the engine runs the full resource cycle (before -> check -> action -> after) repeatedly:
See Loop for full details.
See also
- Workflow - the YAML pipeline
- Agent loop - the model calls tools
- Validation & control flow - skip, check, and error handling
- Loop - a loop that repeats when a condition is true
