Skip to content

Agents, workflows, and policy

In a glimpse introduced the authored objects. This page is about the three that do the work at runtime, and specifically about how they relate: a workflow, an agent and the policy that governs both.

Workflows and agents are two answers to the same question, which is what to call next. Policy is indifferent to which answer you chose: the same rules reach a workflow step and an agent's tool call through the same enforcement path.

flowchart LR
  W["Workflow<br/>fixed composition"] --> I["sealed block invocation"]
  A["Agent<br/>model-selected composition"] --> I
  P["effective signed policy<br/>resolved before execution"] --> G{"kernel gate"}
  I --> G
  G -->|allow / transform / retry| X["block executes"]
  G -->|deny / require approval| D["typed decision evidence"]
  X --> D

The diagram is the invariant: workflows and agents choose work differently, but neither has a route around the same sealed invocation and policy gate.

Both start from reviewed code

A workflow and an agent are both compositions of published reusable capability blocks. Neither contains the code it runs. A block is sealed into a content-addressed capsule at publish time and referenced by digest, so what a composition actually names is a specific set of reviewed bytes with a declared typed interface.

This is why the two composition styles can be governed identically. Whatever decides the order of calls, the calls themselves land on the same artifacts, through the same invocation path, under the same enforcement points.

Workflows: when you know the sequence

A workflow is the right shape when the order of work is known in advance, which covers most business processes. The authoring surface is structured YAML read top to bottom: a step calls a block and saves its result, a conditional branches, a loop iterates within a bound, a failure handler catches a declared error class, a step waits for a human decision with a timeout.

Two properties make a workflow reviewable rather than merely readable.

Everything in it is one of exactly two things. Either a call into sealed, reviewed code, or a control-flow primitive from the closed set. There is no third category: no inline scripts, no embedded code blocks, no string evaluation, nowhere for unreviewed logic to sit. Arbitrary computation lives inside a block, where it was reviewed. Composition lives in the primitive set, which is fixed. See The two categories rule.

flow: refunds.v3

expects:
  customer_id: string
  amount: float
  reason: string

returns:
  decision: enum[approved, denied, escalated]

policy:
  attach:
    - org.acme.refund-governance@2

steps:
  - do: customer.lookup
    bind: { id: $.customer_id }
    save: $.customer

  - try:
      - do: payments.refund
        bind:
          amount: $.amount
          customer: $.customer
        retry:
          max_attempts: 3
          backoff: exponential

    catch:
      - kind: payments.gateway.unavailable
        then:
          - return: { decision: escalated }

  - return: { decision: approved }

The authoring surface is sugar over a fixed execution surface. The compiler lowers the YAML deterministically into a graph over fifteen kernel primitives and nothing else. What a compliance reviewer reads as business logic, and what the kernel executes as primitives, are the same artifact viewed at two levels. See Lowering and Workflow primitives.

A workflow declares its own input and output contract, and a published workflow is itself invocable as a capability whose body is YAML rather than code, which is what makes sub-workflow composition symmetric with calling a block. Bindings and saved paths are type-checked against the published manifests of every referenced block at publish time, so a mismatch is a publish error rather than a runtime surprise. See Workflow contracts and Publish-time validation.

Agents: when you do not

Often the sequence is exactly the part you want the model to work out. The request arrives open-ended, and which block to call, in what order and how many times is a decision for the agent.

An agent in Xratu is a reusable capability artifact, declared in YAML as a first-class concept. It is not a kernel primitive, not a separate packaging model and not an unstructured runtime object outside the capability system. That framing is what keeps it governable: an agent is published, versioned, pinned and referenced exactly like any other artifact.

agent: support.refund_agent

policy:
  attach:
    - org.acme.refund-governance@2

tools:
  - customer.lookup
  - payments.refund
  - ticket.create

limits:
  max_iters: 8
  max_tool_calls: 16

What the declaration adds is an envelope. It names the model binding the agent reasons with, the tools it may reach, the limits it runs under (how many iterations, how many tool calls, how long), and where its result is saved. Tool scope bounds what the agent can touch at all; limits bound how long it may keep going before the run is cut. See Agents, subagents, and tools and Limits and iteration bounds.

An agent may delegate to subagents, which are also reusable capability artifacts, narrower in scope, each running under its own declared envelope of limits, policy and tool scope. Delegation is declared rather than inferred: routing does not depend on prose or on semantic hints, and merge behaviour is declared by the author. The orchestration principle is that the system must not guess. See Subagents and Delegation and delegation envelopes.

Agents and subagents that collaborate need somewhere to put working state, so a shared context channel exists automatically for an agent, and for an agent that delegates. It carries run-local and session-local working memory, expires with the run or session retention boundary, and is not a durable cross-run memory service. The kernel owns the structure, its ordered mutation, its revisions and its persistence; the agent and its blocks own what the contents mean. Authors only become explicit when they want to control exposure, compaction, refinement or merge behaviour, and the compaction and refinement capabilities they name are themselves versioned blocks. See Shared context and Run working memory.

Workflows and agents are not alternatives you must choose between for a whole system. A workflow step can invoke an agent, and an agent can be given a published workflow as one of its tools.

Policy: the same law over both

Policy is a named, versioned, signed bundle of rules. Every rule, whatever it governs and whoever wrote it, has the same machine-enforceable shape: the point in execution at which it is enforced, what it applies to, the condition under which it fires, the effect it produces, typed arguments for that effect, a human-readable reason, and references to the regulation or internal policy it came from. See The canonical rule shape.

Bundles come from three sources and are indistinguishable at runtime: signed industry baselines published and maintained by Xratu, bundles authored by an organisation's own governance team (usually extending a baseline), and signed third-party bundles from a consultancy or consortium. Only the signer and the bundle identifier differ. See Bundle sources.

Bundles attach at seven levels, and the levels exist because each is authored by a different person at a different moment:

Level Authored by Scope
Tenant Governance team The whole organisation
Workspace Department compliance owner One business unit
Project Project owner One deployment
Flow Workflow author A single workflow
Agent Agent author A single agent
Capability Block author or security A single artifact, sealed at publish
Inline Workflow author A single step

Most levels are empty for most workflows. See The attachment hierarchy.

The default is central-first. Organisation and workspace bundles attach to everything in scope automatically, workflow authors do not declare company-wide governance in their YAML, and a workflow author cannot opt out of an inherited rule. Local policy can add or tighten; loosening requires a signed exemption. See Central-first attachment.

At build time the control plane walks the hierarchy, gathers every rule that targets each step, merges them most-restrictive-wins, verifies any required bundle bindings, and freezes the result as that step's effective policy inside the signed run-plan. See Merge resolution.

Why the same policy covers an agent

When an agent decides to call a block, the call arrives at the same enforcement point as the same call made from a workflow step. The block is the same sealed artifact at the same digest. The effective policy on it was resolved at build time from the same hierarchy. The kernel enforces at the same six points and enacts the same nine effects.

An approval threshold attached at workspace level therefore holds over an agent without the agent being told about it, without a prompt mentioning it and without a second model checking the first. The agent decides what to attempt. It does not decide whether the rule applies, because the path from its decision to an effect in the world runs through the gate.

Policy is also not restricted to gating calls. Enforcement covers writes to shared context, model invocations, delegation, results coming back from a call, and events on their way out, which is what lets a rule redact a value before it is written, downgrade the model bound to an agent, or refuse to emit an output whose citations are incomplete. Rules can reference kernel-computed scores in the same predicate language they use for anything else. See Enforcement, The effect set and Score-backed policy rules.

Every enforcement decision produces a typed record:

{
  "trace_id": "...",
  "run_fingerprint": "...",
  "hook": "pre_call",
  "target": { "capability": "payment.refund", "step_id": "refund_1" },
  "rule_id": "human_required",
  "bundle": "org.acme.refund-governance",
  "bundle_version": 2,
  "attachment_level": "workspace",
  "input_hash": "sha256:...",
  "effect": "require_approval",
  "effect_args": { "approver": "role:finance_manager", "sla": "24h" },
  "decided_at": "2026-05-14T14:23:11Z",
  "reason": "amount £250 ≥ £50 threshold",
  "references": ["FCA SYSC 9.1.1R"],
  "exemption_ref": null
}

The record names the rule, the bundle and version it came from, the attachment level that contributed it, the effect, the reason and any exemption applied. That is the audit trail and the input to scoring. See Policy decision evidence.

What these three are not

A workflow is not a state machine you maintain by hand. Loops are bounded primitives with declared limits rather than back-edges and a counter kept in state, and failure handling is a declared boundary rather than a branch on an error flag.

An agent is not an exception to governance. It is a published artifact with a declared envelope, and the only thing it decides is what to attempt.

Policy is not text given to a model, and not a quality checklist applied afterwards. It is a gate evaluated before the action, with output-quality enforcement as one of the things the same surface can express. See From quality envelope to action gate.

Policy is not resolved at runtime. The kernel does not merge bundles, interpret regulation or resolve versions while a run is in flight.