AI agent guide — authoring Event Script flows
At a glance
- Read this if you are an AI agent asked to write or modify an Event Script flow. It is the context you need — you should not have to read the engine source.
- Generate from rules. The flow grammar and its machine-readable form
event-script-flow.jsonare the source of truth. Validate against them.- A flow is a YAML file compiled and validated by the engine (
CompileFlows). Your job is to produce one that passes — the invariants are the contract.
How flows are deployed & triggered
A flow is not called directly:
- Write the flow YAML under
src/main/resources/flows/. - Register its file in the
flows.yamlmanifest. - Map an HTTP endpoint to it in
rest.yaml(flow: {flow-id}) — or trigger it by event.
The engine compiles every registered flow at startup; a flow that violates the grammar fails to load. So correctness is checkable before runtime.
Generate deterministically
Use event-script-flow.json to look up the exact execution types, task
fields, and mapping namespaces; use flow-grammar.md for the rules. Then verify:
Pre-write checklist - [ ]
flow.id,flow.description,flow.ttl(≥1s),first.task, andtasksare present. - [ ] Every task hasdescription,input,output, and a validexecution. - [ ] There is ≥1 task withexecution: end. - [ ]nextmatches the execution type:decision≥2;sequential/response/pipelineexactly 1;end/sinknone. - [ ]forkhas ajoin;pipelinehas apipelinelist; adecisiontask'soutputmaps a value intodecision. - [ ] If the sameprocessis used twice, each such task has a uniquename. - [ ] Everysource -> targetuses valid namespaces (see the grammar's mapping section);ext:targets requireexternal.state.machine.
Recipe
- Header: set
flow.id,description,ttl, optionalexception; pickfirst.task. - Tasks: for each, set
process(orflow://),description,input,output,execution, and thenext/join/pipelineits type requires. - Terminate: ensure at least one
endtask whoseoutputbuilds the response. - Wire up: register in
flows.yaml; add arest.yamlmapping if HTTP-facing.
Worked example
A minimal flow: receive a POST, call a greeting function, return its result.
flow:
id: 'greeting-flow'
description: 'Greet a caller by name'
ttl: 10s
first.task: 'greeting.service'
tasks:
- input:
- 'input.body.name -> name'
process: 'greeting.service'
output:
- 'result.message -> output.body.message'
description: 'Build the greeting'
execution: end
A decision example (branch on a function result):
- input:
- 'input.body.amount -> amount'
process: 'risk.scorer'
output:
- 'result.high_risk -> decision'
description: 'Score and branch'
execution: decision
next:
- 'approve.task' # decision = false -> next[0]
- 'review.task' # decision = true -> next[1]
See also
- Event Script flow grammar +
event-script-flow.json— the source of truth. - Event Script Syntax — worked examples and the full data-mapping catalog.