Overview
Workflows are immutable workflow-policy versions stored in the gateway and matched per request. They currently control gateway-owned behavior such as:- cache
- budgets
- audit logging
- usage tracking
- guardrails: which plugin instances run, in which phase, in what order
- translated-route failover
Scope Fields
Workflow scope is defined by these fields:scope_provider_namescope_modelscope_user_path
scope_provider_name is the configured provider instance name, not the provider type.
Examples:
- provider type:
openai - provider name:
openai_primary
Matching Precedence
Workflow matching is user-path first. For a request withuser_path=/team/team1/user, the gateway checks path-scoped candidates from deepest to root first:
provider_name + model + /team/team1/userprovider_name + /team/team1/user/team/team1/userprovider_name + model + /team/team1provider_name + /team/team1/team/team1provider_name + model + /teamprovider_name + /team/teamprovider_name + model + /provider_name + //provider_name + modelprovider_nameglobal
- a deeper
user_pathworkflow beats a broader provider-only or provider+model workflow - within the same path depth, provider+model is more specific than provider-only
- if no path-scoped workflow matches, the gateway falls back to provider+model, then provider, then global
Guardrail Steps
The workflow payload lists the guardrail instances to run assteps. Each
step names an instance (ref), the phase it runs in, and its position:
phaseisprompt(default when omitted),response, orstream. The instance’s plugin must implement that phase;GET /admin/workflows/guardrailslists each instance with itsphases.- Within a phase, steps run in ascending
step(a non-negative integer); equalstepvalues run in parallel. At most one content-editing instance may share astep. - The same
refmay appear once per phase. features.guardrails: falsedisables every step of the workflow.
"schema_version": 1 with "guardrails": [{"ref", "step"}])
are still accepted and compile as prompt-phase steps. Stored version 1
workflows are returned unchanged; the dashboard always writes version 2.
Workflow views (GET /admin/workflows, GET /admin/workflows/:id) expose the
hash of each compiled chain as chain_hashes ({"prompt": "...", "response": "...", "stream": "..."}).
The prompt hash is part of the semantic response cache key, so changing a
prompt-phase guardrail invalidates cached answers produced under the old rules.
Examples
Path Inheritance
If you have:- workflow A:
scope_user_path=/team - workflow B:
scope_user_path=/team/team1
user_path=/team/team1/user, workflow B wins.
If workflow B does not exist, workflow A wins.
Provider-Name Scoping
If you have two OpenAI providers:openai_primaryopenai_backup
scope_provider_name=openai_primaryscope_provider_name=openai_backup
openai, they are different workflow scopes.
API Example
Create a workflow scoped to one configured provider name, one model, and one user-path subtree:Notes
scope_modelrequiresscope_provider_namescope_user_pathis normalized to canonical slash form- managed API keys can override the request user path header; workflow matching uses the effective request user path
- budget enforcement runs only when the global budget feature and the matched workflow’s
budgetfeature are both enabled; see Budgets - every
refmust name an existing guardrail instance; a guardrail referenced by an active workflow cannot be deleted