Use this file as the fast local reference for action-step behavior when authoring JSON definitions offline.
For broader shape and validation rules, also read:
agent-definition-contract.mdstart-here.mdexamples/README.md
- Required top-level keys:
version- optional
inputs - optional
action_execution - optional
runtime_vars agent_schemaactions
action_execution- Allowed values:
sequential,parallel - Omitted means
sequential. parallelonly changes scheduling across matching top-level actions.- Each individual action's
runlist stays sequential in both modes.
- Allowed values:
- Runtime may force a parallel-capable invocation tree down to sequential with
--action-execution sequential. - That runtime override is invocation-scoped and inherits to child-agent steps; parent JSON
action_executiondoes not override child JSON. - A hard failure in one top-level action does not prevent later eligible top-level actions from running.
- Cargo AI aggregates top-level hard failures after all eligible actions finish.
- Cargo AI prints one run-level header,
Action execution: sequentialorAction execution: parallel, before action work begins. - In redirected, piped, CI, or simpler terminal output, Cargo AI prefixes parent-visible action output with deterministic labels such as
[Action 1: generate_images]. - In append-only output, long-running steps also emit a step-start liveness line such as
step 2/2 generate_image started; waiting for provider response.... - Terminal lane summaries and the final run footer also include wall-clock durations, for example
completed in 31s.and✅ Run complete in 32s.. - When attached directly to an interactive terminal, Cargo AI switches to a compact live lane dashboard instead of append-only lifecycle lines.
- The first live dashboard slice keeps each lane block compact:
- lane label
- lane status with elapsed time while running and after terminal completion/failure
- terminal step marker or current step when known
- last lifecycle message
- In append-only output, parent-run
execandemail_meoutput is emitted with the originating action label. - Child-agent steps stay minimal in the parent lane with start/completion or exit-summary lines instead of recursively inlining the child transcript.
These documented step kinds and helper fields are exhaustive for the current MVP.
exec- Required:
kind,program,args
- Required:
agent- Required:
kind,agent - Optional:
profile
- Required:
tool- Required:
kind,name - Optional:
params,output_variable - Use this for Cargo AI-managed project-local tools created with
cargo ai add tool <name> paramsvalues may be scalar literals or{ "var": "<name>" }references- Literal params are checked against the tool
describe.paramscontract during validation; variable params are checked after resolution at runtime - The tool
describe.resultschema must be a nullable string; ifoutput_variableis set, the actualinvokeresult must be a non-null string
- Required:
email_me- Required:
kind,subject,text
- Required:
generate_image- Required:
kind,prompt,path - Optional:
model,profile - First slice: direct OpenAI image transport, OpenAI account transport, and Ollama's experimental OpenAI-compatible image transport
- If
modelis omitted, Cargo AI falls back to the effective invocation model resolved from the current profile and any--modelCLI override. - If
profileis present, Cargo AI resolves that profile at step runtime and uses it for the image step's provider/url/token context. - With
generate_image.profile, explicitmodelstill wins, then the step-profile model, then the parent invocation model. generate_image.profilemay switch providers; for example, a parent may stay on OpenAI while one image step uses an Ollama profile.- If neither the step nor the invocation provides a model, the step fails clearly at runtime.
modelmay be:- a literal non-empty string
- a single variable reference such as
{ "var": "runtime.hero_image_model" } - a single top-level string output field such as
{ "var": "image_model" }
generate_image.modelmay not read capturedoutput_variable,status_variable, orerror_variablevalues- Use a tool-capable mainline model such as
gpt-5.2for OpenAI account transport - For a direct OpenAI API token and URL, prefer GPT Image models such as
gpt-image-1.5orgpt-image-1-mini - For Ollama's experimental OpenAI-compatible
/v1/images/generationsendpoint, use an Ollama image model on an Ollama profile such asx/flux2-klein:4b - The current Ollama compatibility slice uses Ollama's documented
b64_jsonresponse path, so Ollama-backedgenerate_imagesteps currently require a.pngoutput path - Current-at-ship-date note: official OpenAI docs list
gpt-image-1.5as the latest GPT Image model, and the image-generation guide listsgpt-image-1.5,gpt-image-1, andgpt-image-1-minifor direct image generation. Verified: 2026-03-28.
- Required:
when- JSON Logic object evaluated by the parent action runner.
failure_mode- Allowed values:
stop,continue,abort - Omitted means
stop.
- Allowed values:
platform- Allowed values:
macos,linux,windows - May be a string or array of strings in the executable JSON contract.
- If omitted, the step is eligible to run on any supported runtime platform.
- If the current platform does not match, the step is skipped.
- Allowed values:
status_variable- Stores
succeededorfailedwhen the step runs.
- Stores
error_variable- Stores a human-readable error string when the step fails.
output_variableexecandtoolonly- For
exec, stores captured stdout. - For
tool, stores the non-null string returned by the toolinvokeresponse.
- Steps stop the action by default when they fail.
failure_mode: "continue"allows later steps to run after failure.failure_mode: "abort"stops scheduling new work for the current invocation, lets already-running work settle in the first slice, and fails the run with an explicit abort summary.- A hard failure still stays local to that action's
runlist; later eligible top-level actions continue and the runtime aggregates top-level failures at the end. - Child-agent abort stays local to the child invocation first; the parent lane then handles that failed child exit according to the parent step's own
failure_mode. - If a step is skipped because
whenis false,status_variableanderror_variablestay unset in the MVP. - If a step is skipped because
platformdoes not match,status_variableanderror_variablestay unset in the MVP. - Matching steps still run in listed order.
- Top-level
agent_schemafields are the returned output of the agent. - Action steps are side effects or follow-up orchestration after that output exists.
output_variablecaptures step-local text fromexecor a non-null string result fromtool. It does not change the returned top-level output object.- If
agent_schema.propertiesis empty, Cargo AI skips the initial model call and starts directly at the action layer. - In that structural action-only shape, top-level
inputsare allowed only as named reusable parent-owned inputs. - In that structural action-only shape, anonymous runtime
--input-*flags remain invalid. - Use
--input-override NAME=VALUEto satisfy or replace declared named top-level inputs at invocation time.
- Captured names are flat. Dotted names are invalid.
output_variable,status_variable, anderror_variableshare one action-local namespace.runtimeandruntime.*are reserved for declared invocation-scoped runtime variables.- Captured names cannot collide with top-level
agent_schemaoutput field names. - Captured names cannot be reused within the same action.
- The same captured names may be reused in different top-level actions.
- Top-level action
logiccan read:- top-level model output fields
- declared
runtime.*values - for the structural action-only shape, only declared
runtime.*values are available at action start
whenand string-part substitutions can read:- top-level model output fields
- declared
runtime.*values - prior
output_variablevalues from earlier steps in the same action - prior
status_variablevalues from earlier steps in the same action - prior
error_variablevalues from earlier steps in the same action
- Later actions cannot read captured variables from earlier top-level actions.
- Child agents must use explicit same-level paths such as
./child_reporter. - Local file and image paths should stay relative.
- Parent-directory traversal such as
../is invalid. generate_imageoutput paths must use one of:.png,.jpg,.jpeg,.webp.- For the current Ollama-backed
generate_imagecompatibility path, use.png.
- Parent actions may pass child-agent
inputs, including dynamic string parts resolved from current action-local data. - Parent actions may also pass child-agent
run_varskeyed by the intended child runtime var. - Parent actions may also pass child-agent
input_overrideskeyed by the intended named child input. - If the target is another Cargo AI agent, prefer a native
kind: "agent"step instead of anexecwrapper that launches Python, shell, or another helper just to call the child. - Use wrapper programs only when the task truly needs extra non-Cargo-AI behavior around that child call.
- Child
inputsmay also reference declared named top-level inputs with the exact shape{ "input": "<name>" }. - Child
input_overridesmay also use{ "input": "<name>" }when the parent wants to bind one named parent input into one named child slot explicitly. - Named child-input reuse is explicit only; parent inputs are not auto-inherited.
- Child
run_varsvalues should stay CLI-shaped: string, number, boolean, or{ "var": "<name>" }. - Child
input_overridesvalues should stay CLI-shaped too: string,{ "var": "<name>" }, or{ "input": "<name>" }. - Child
inputsmay still resolve declaredruntime.*values alongside top-level model output fields and prior captured step variables. - Parent
agentsteps should preferinput_overrideswhen targeting declared named child inputs and use childinputsfor extra anonymous context. - Parent
agentsteps should use childrun_varsfor invocation-scoped operational settings that the child already declares in top-levelruntime_vars. - Parent
agentsteps may set childinput_modetoreplace,append, orprependwhen they also provide childinputs. - Parent
agentsteps may also set a step-levelprofileas a literal string or single variable reference; Cargo AI resolves it at step runtime and forwards--profile <name>to the child. - Child
input_modeapplies only to childinputs; it does not suppress or merge childinput_overrides. - Omitted child
input_modekeeps the current replace behavior for child inputs. - If a child wants to forward the same named input to its own child, it should declare that named top-level input locally first.
- Parent actions may capture child-agent success/failure with
status_variableanderror_variable. - Parent actions cannot directly capture the child agent's top-level returned output fields into the parent action-local namespace.
- Cargo AI prints one root
using:line at run start. In append-only output, it also emits another action-prefixedusing:line when a childagentorgenerate_imagestep changes the effectiveprofile,auth,server, ormodel. - Interactive live mode keeps the parent dashboard at the orchestration level and does not surface child or step-level
using:lines there. - Native child-agent steps preserve child input forwarding, failure handling, depth limits, and runtime observability without inventing an extra scripting layer.
- Top-level inputs may declare optional
name. - Prefer
namewhen an input is part of the workflow contract, reusable by child steps, or intentionally operator-overrideable. - For named input objects, prefer field order
name, thentype, then the value-bearing field. - For unnamed literal inputs, keep
typefirst and the value-bearing field second. - Keep one-off root-model context unnamed when it does not need child reuse or targeted override behavior.
- Unnamed top-level inputs must keep a baked value.
- Named top-level inputs may keep a baked value or act as required slots with no baked value.
- Repeatable
--input-override NAME=VALUEreplaces declared named bindings for the current run. - Anonymous runtime
--input-*flags still control only the root model input list for schema-backed agents; they do not bind named input identities.
- Edit one JSON definition at a time.
- Run
cargo ai hatch <agent-name> --config <config.json> --check. - Fix validation errors before building.
- Build only after
--checkpasses.