DSL Examples

Current workflow examples organised by execution pattern.

Browse by topic

SectionContents
General PatternsTriggers, schedules, matrices, conditions, and error handling
Workflow-linked Agent SessionsHuman and Agent collaboration inside a durable Workflow
Pipeline IntegrationAutomated paths, interactive exception paths, Decisions, and side effects

Minimal Agent workflow

yaml
1apiVersion: xema.dev/workflow/v1alpha1
2kind: Workflow
3metadata:
4  name: assess-request
5  version: 1.0.0
6
7on:
8  workflow_dispatch:
9    inputs:
10      request:
11        type: string
12        required: true
13
14jobs:
15  assess:
16    uses: xema/[email protected]
17    with:
18      agentRef: request-analyst@2
19      deliverableSpecRef: request-assessment@1
20      agentContext:
21        prompt: ${{ inputs.request }}

Scheduled workflow

yaml
1on:
2  schedule:
3    - cron: "0 9 * * MON"
4      timezone: UTC
5      inputs:
6        reportType: weekly

Webhook-triggered workflow

yaml
1on:
2  webhook:
3    - event: customer.case.opened
4      filters:
5        priority: high

Live Session inside a workflow

yaml
1jobs:
2  collaborate:
3    uses: xema/[email protected]
4    timeout: 24h
5    with:
6      agentRef: operations-coordinator@5
7      deliverableSpecRef: resolution-record@1
8      agentContext:
9        prompt: Work with the operator to resolve this exception.
10      agentSession: true
11    outputs:
12      sessionId: ${{ job.outputs.sessionId }}
13      resolution: ${{ job.outputs.structuredOutput }}

Conditional paths

yaml
1jobs:
2  assess:
3    uses: xema/[email protected]
4    with:
5      agentRef: risk-reviewer@4
6      deliverableSpecRef: risk-assessment@2
7      agentContext:
8        prompt: Assess the request.
9    outputs:
10      assessment: ${{ job.outputs.structuredOutput }}
11
12  review-required:
13    needs: [assess]
14    if: ${{ needs.assess.outputs.assessment.risk == 'high' }}
15    uses: xema/decision-[email protected]
16    with:
17      subject: ${{ needs.assess.outputs.assessment }}
18      recipients:
19        - kind: human
20          target:
21            userId: ${{ trigger.actorSubject }}
22      policy:
23        kind: single

Matrix expansion

yaml
1jobs:
2  assess-regions:
3    strategy:
4      matrix:
5        region: [eu-west, eu-central, eu-north]
6      maxParallel: 3
7    uses: xema/[email protected]
8    with:
9      agentRef: regional-reviewer@2
10      deliverableSpecRef: regional-assessment@1
11      agentContext:
12        prompt: Assess the operating posture for ${{ matrix.region }}.

See Agent Step for the current action contract.