Skip to content
Talk to our solutions team

Core Concepts

The mental model behind AI Flow. Read this once and the API, the authoring guide, and the operations docs will all make sense.

You author a flow (a DAG of tasks). You submit a request to AI Flow over HTTP. AI Flow hands it to the execution engine (the flow engine), which plans the flow and, for each task, asks the orchestrator (the agent fabric) to pick a healthy agent. The agent runs the task and streams the result back. The engine merges results into a shared context, follows the flow’s routing to the next task, and repeats until a terminal node. Everything — the instance, its runs, and the conversational request/response turns — is persisted to a per-tenant PostgreSQL database.

author flow ─▶ submit request ─▶ engine plans ─▶ orchestrator selects agent
│ │
└──────────── persisted as instance/runs ◀── agent runs task, streams result
LayerComponentWhat it owns
ServiceAI Flow (aiflow.svc)HTTP surface, persistence, conversation memory, per-tenant wiring.
Enginethe flow engineParse → plan → dispatch → route; control-flow nodes; retry/timeout; pipelines.
Fabricthe agent fabricgRPC orchestrator↔agent transport; agent health & capacity; agent selection.

AI Flow is intentionally thin — it wires the other two together and remembers everything.

Three words for the same authored artifact: a directed graph of tasks. “Pipeline” is the word the REST layer uses; internally it’s a workflow definition. See [authoring-flows.md](/blocks/ai/AI Flow/authoring-flows/) for how to write one.

A definition is versioned and identified by definitionid. Definitions are delivered per tenant through the forge-meta product-config system (not baked into the binary).

One execution of a definition. It carries:

  • context — the shared bag of data (smap.Map) that tasks read and write,
  • states — an ordered history (Created → Executing → … → Completed/Errored),
  • metadata — plan, tenant, affinity, and bookkeeping for foreach/map/wait/subworkflow.

Persisted as mlflow_instance.

A single node-execution attempt within an instance, bound to the agent (workerid) that ran it, with its own context/states and resumedata. Control nodes create synthetic run records. Persisted as mlflow_instance_run.

A task is one step. The engine infers the node’s kind from which key you use:

  • Task (shell:, print:, httpclient:, …) — dispatched to an agent.
  • Assign (assign:/pass:) — inject/reshape context, inline.
  • Choice (choice:) — conditional routing, inline.
  • ForEach (foreach:) — sequential iteration.
  • Map (map:) — parallel fan-out.
  • Wait (wait:) — suspend for a signal or timeout.
  • SubWorkflow (subworkflow:/flow:) — call a child flow.
  • Fail / Succeed — terminate.

The single shared data structure per run. Seeded from vars: + start-time overrides. Written by Assign, task outputs (merged back, with _result as the latest), routing set:, iteration (_item/_index/_results), and signals (_signal). Strings are templated with Liquid ({{var}}); conditions are evaluated by the platform scripting runtime (JavaScript by default).

AI Flow adds a chat abstraction on top of pipelines:

  • A conversation (mlflow_instance_conversation) is a session bound to an instance.
  • Each turn is a request (mlflow_instance_request, holds record.prompt) and a response (mlflow_instance_response, holds the model output).
  • Conversation memory = the requests/responses flagged inmemory=true. On each new request, AI Flow replays them as chat history (role:user/role:assistant) into the pipeline’s environment. “Cleaning” memory sets inmemory=false (a soft eviction — nothing is deleted).
  • An agent is a remote worker node. It dials the orchestrator, sends heartbeats with its CPU/memory/GPU/disk metrics and capabilities (tags, loaded models, tenant list, capacity), and executes tasks. Registered in mlflowagentlist.
  • The orchestrator is the gRPC server agents connect to. It tracks each agent’s health and capacity and, via the selector, picks an agent for each task.

For each Task node the engine asks the orchestrator for a worker. Selectors on the task (tag, model, gpu, freegpu, cpu, memory, id/workerid, group) narrow the choice; otherwise the least-loaded healthy agent wins. Selection is tenant-scoped. If a matching agent exists but is at capacity, the work is queued and retried; if no agent could ever match (bad tag/model), it fails fast.

  • Affinity pins tasks to agents across runs (scopes: single-agent, definition, payload). Bindings live in mlflow_affinity_binding.
  • Task groups co-locate a set of tasks on one agent within a single run — lighter than affinity, for tasks sharing a workspace.

When no agent is available, the task is persisted as a mlflow_work_item and the instance goes Queued. A background drain loop retries it (fairly across tenants). Orphaned instances are re-queued on restart. This is what makes bursty load safe.

Tenant identity is Customer:Product:Environment:Tenant. It flows from the JWT/header into a per-tenant engine, definition set, and PostgreSQL schema (with row-level security via app.tenant_id). Agents declare which tenants they serve (--tenants, --exclusive).

Flows can pause and resume:

  • Wait suspends until a signal (POST /workflow/signal) or a timeout.
  • SubWorkflow suspends the parent until the child completes.
  • Queued work resumes when an agent frees up.
  • Iteration checkpoints let a large ForEach/Map resume mid-collection (opt-in).

The definition’s shape picks how it runs:

TypeChosen byBehavior
DAGdefaultGraph with next:/error: routing.
Arraylist: trueSequential list.
Stateflowstates:Event-driven state machine.
DataPipelinepipeline: trueSource/sink streaming (what conversational requests use).
ConceptPersisted asOwned by
Definitionforge-meta config → parsed in memoryAI Flow / the flow engine
Instancemlflow_instancethe flow engine (the platform data layer store)
Runmlflow_instance_runthe flow engine (the platform data layer store)
Conversationmlflow_instance_conversationAI Flow
Request / Responsemlflow_instance_request / _responseAI Flow
Engine recordmlflowengineinstanceAI Flow
Agentmlflowagentlistthe agent fabric selector store
Queued workmlflow_work_itemthe flow engine
Affinity bindingmlflow_affinity_bindingthe flow engine

Next: [authoring-flows.md](/blocks/ai/AI Flow/authoring-flows/) to write one, or [rest-api.md](/api/AI Flow/) to drive it over HTTP.