A machine agent has mode: machine in its agent.yml. It does not run an AI model loop. It runs a Machine: a procedure that the push compiles into a fixed program. The engine does the steps in order and writes each step to a log before it does the step. Each tool call goes through the same Run tools, grants, approvals and trace as the tool calls of other agents.
Use a machine agent for a process that must run the same way each time: invoice intake, vendor onboarding, a claim check. Use a zeroshot or a turns agent when the work needs a model to choose the next step.
For a step that needs judgment, the procedure asks a question. A ladder of answerers gives the answer: a decision model, an exception model, then a person. Put the person last, so that a person decides when a model cannot.
Start a machine agent
rakerun machine new ap/invoice-intakeThe command writes the agent folder. It refuses a folder that is an agent already.
| File | What |
|---|---|
AGENTS.md |
A description for people. The Machine does not read it. |
agent.yml |
mode: machine, the HTTP trigger, the machine: paths and the approvals. |
machine.json |
The procedure (bm-procedure/2). The starter has one ask step and no tool. |
machine.tools.json |
The contracts of the MCP and _code tools that the steps call. The starter has no tool. |
Then write the steps, push with rakerun deploy, and run the agent with rakerun run start ap/invoice-intake.
agent.yml
mode: machine
triggers:
http: true
machine:
procedure: machine.json # default machine.json. A .yaml or .yml file is accepted.
tools: machine.tools.json # default machine.tools.json
exception_model: default # default | off
connectors: [erp]
approvals: { require: [send, delete, call] }| Key | Type | Default | Rule |
|---|---|---|---|
mode |
machine |
zeroshot |
Leaf-only. |
machine |
object | the defaults below | Leaf-only. The paths are relative to the agent folder. Only an agent with mode: machine reads it. |
machine.procedure |
path | machine.json |
The procedure file. JSON, or YAML with the same structure. |
machine.tools |
path | machine.tools.json |
The tool file. The default file can be absent when no step calls an MCP tool. A file that you name must be there. |
machine.exception_model |
default, off |
default |
off turns the model rung off for every step of the Machine. The next rung then answers. |
timeout |
duration | 60m |
One turn. A machine turn counts the time that it waits for a model, a decision or a code step. |
idle_ttl |
duration | 7d |
A run that waits for a person, an approval or an input expires after this time. Then the Run engine cancels the Machine. |
These keys have no use in mode machine:
model,llmandlimits.max_steps. Amodelthat the leafagent.ymlsets gives the warningmachine_model_ignored. Amodelthat a parent sets gives no warning.output_schema. The result of a Machine is always{outcome, report}, so lint refuses the key withmachine_output_schema.- The prompt.
AGENTS.mddescribes the Machine for people. The engine does not read it.
input_schema, triggers, network, secrets, connectors, data, knowledge, approvals, retention, events and webhooks work as for other agents. Read the agent.yml reference.
The procedure
The procedure is a bm-procedure/2 document. The full language is in the Machines language reference. This example files a supplier invoice as a bill in an ERP:
{
"language": "bm-procedure/2",
"procedure": "invoice-intake",
"description": "File a supplier invoice as a bill in the ERP.",
"inputs": {
"user_message": { "type": "string", "description": "the request" },
"f1": { "type": "file", "description": "the invoice PDF" }
},
"steps": [
{
"id": "extract",
"tool": "file_extract",
"args": {
"file_id": "@input.f1.file_id",
"schema": {
"type": "object",
"properties": {
"vendor": { "type": "string" },
"invoice_number": { "type": "string" },
"total": { "type": "number" }
},
"required": ["vendor", "invoice_number", "total"]
}
}
},
{
"id": "totals",
"check": "extract.value.total > 0 && extract.value.total < 50000",
"message": "the total is between 0 and 50,000"
},
{
"id": "vendor",
"tool": "mcp_erp_find_vendor",
"args": { "name": "@extract.value.vendor" },
"on_error": {
"cases": [
{
"code": "not_found",
"then": { "hold": "The vendor {{@extract.value.vendor}} is not in the ERP." }
}
]
}
},
{
"id": "bill",
"tool": "mcp_erp_create_bill",
"args": {
"vendor_id": "@vendor.id",
"invoice_number": "@extract.value.invoice_number",
"amount": "@extract.value.total"
},
"limit": 1
}
],
"finish": { "status": "done", "report": "Bill {{@bill.bill_id}} is in the ERP." }
}The step kinds are tool, ask, code, check, when, foreach, await, hold and finish. The compiler checks each reference against the output schema of its tool. For example, @vendor.id must be a key of the output of mcp_erp_find_vendor.
Inputs
| Run input | Procedure input |
|---|---|
A string input |
user_message |
An object input |
One procedure input for each key, for example {"vendor": "Acme"} gives vendor. |
| The files of the first turn | f1, f2 and so on, in order. A file input has file_id, name, content_type and bytes. |
| The input of a later turn | The first input that an await step waits for. |
Tools
A tool step names a Run tool by the name that the model of a zeroshot agent sees. The agent can call only the tools that it has: its grants decide.
| Tool | Contract |
|---|---|
file_* (for example file_extract) |
Run gives it. The output of file_extract has the type of the schema that the step sends. |
data_* (for example data_query) |
Run gives it from the data: grants and the _schemas/ record types. |
knowledge_search, knowledge_read |
Run gives it from the knowledge: grants. |
An operationId of an _apis file |
Run gives it from the OpenAPI file. The step sends {params, body}: params holds the path and query parameters. The output is the body of a 2xx answer. |
A _code tool (the file stem) |
The input comes from the header of the file. Pin the tool in machine.tools.json to give it an output schema. |
An MCP tool (mcp_{server}_{tool}) |
Pin it in machine.tools.json. An MCP pin needs an outputSchema. |
An MCP tool name has at most 64 characters. When mcp_{server}_{tool} is longer, Run keeps its first 47 characters and adds _ and 16 hexadecimal characters of a hash of the server and tool names. Pin the name that Run gives, not a name cut at 64 characters. When a pinned MCP name is not a tool of the run, the run fails at start with connector_unavailable.
A Machine cannot call message, done, ask, list_files, read_file, delegate, message_agent, the door tools or the phone tools. A step that names one fails lint with machine_tool_unknown.
machine.tools.json
The tool file pins the contracts of the MCP and _code tools. It is a list, or {"tools": [...]}. Copy each MCP entry from the listing of the server, with the same inputSchema and outputSchema. A _code tool with no pin gets the input of its header and no output schema.
{
"tools": [
{
"name": "mcp_erp_find_vendor",
"description": "Find a vendor by name.",
"inputSchema": {
"type": "object",
"properties": { "name": { "type": "string" } },
"required": ["name"]
},
"outputSchema": {
"type": "object",
"properties": { "id": { "type": "string" }, "name": { "type": "string" } },
"required": ["id", "name"]
},
"annotations": { "readOnlyHint": true },
"x-errors": {
"not_found": {
"type": "object",
"properties": { "code": { "const": "not_found" }, "message": { "type": "string" } }
}
}
},
{
"name": "mcp_erp_create_bill",
"description": "Create a bill.",
"inputSchema": {
"type": "object",
"properties": {
"vendor_id": { "type": "string" },
"invoice_number": { "type": "string" },
"amount": { "type": "number" }
},
"required": ["vendor_id", "invoice_number", "amount"]
},
"outputSchema": {
"type": "object",
"properties": { "bill_id": { "type": "string" } },
"required": ["bill_id"]
},
"x-effect": "irreversible"
}
]
}| Key | Rule |
|---|---|
name |
The Run tool name. A tool appears once. A tool that Run gives (file_*, data_*, knowledge_*, _apis) is not pinned. |
inputSchema |
Required for an MCP tool. |
outputSchema |
Required for an MCP tool. A step that reads the output of a tool with no output schema does not compile. |
annotations.readOnlyHint |
true gives the effect read. |
annotations.destructiveHint |
true gives the effect irreversible. |
x-errors |
The error codes of the tool. An on_error case for a code that is not in the list does not compile. |
x-effect |
read, write or irreversible. It can raise the effect of the tool, not lower it. |
At the first turn of a run, Run compares each pinned MCP tool with the live listing of the server. The run fails before the first call when the input schema or the output schema changed, or when the live hints give a higher effect (machine_tools_changed). It also fails when the server does not list the tool now (connector_unavailable). Copy the new contract into the tool file and push again.
Effects and approvals
Each tool call has a Machine effect: read, write or irreversible. The Run effect of the tool is the floor:
| Run effect | Machine effect |
|---|---|
read |
read |
internal |
write |
external_write |
write |
delete |
irreversible |
send |
irreversible |
call |
irreversible |
A pin (x-effect) or a step (effect) can raise the effect. It cannot lower it: lint refuses that with machine_effect_lowered.
The approvals of agent.yml decide which calls wait for a person. The gate uses the stricter of the Run effect and the Machine effect. An irreversible step counts as call. So approvals: { require: [send, delete, call] }, the default of rakerun machine new, makes a person approve each irreversible step. In the example, mcp_erp_create_bill waits for an approval.
- A person approves or denies in the console or in the Inbox. Runs from the API and from triggers wait for that decision.
- A denied call does not run. The step gets the error
approval_denied, and the procedure decides: anon_errorcase or a hold. - An approval with changed arguments does not run the call. The step gets the error
approval_edited. The log keeps the arguments that ran. - In a conversation on web chat, email, Slack or Teams, no person can approve. A gated call gets the error
approval_unavailable. - A connector that needs a login gives the error
connect_required. The run does not wait for the login.
Questions, holds and inputs
| What happens | What Run does |
|---|---|
An ask step or a failed step reaches a person |
The run waits. Run sends a question event with the id mq_{seq} and opens an Inbox question item. The next turn answers it with that question id. |
An await step waits for a later input |
The run waits. The next turn with an input gives the value. |
A hold step, or an error that the procedure holds |
The run fails with machine_held. Run opens an Inbox item with the reason and the attached values. A person does the rest of the work. |
The procedure ends with done, refused or aborted |
The run completes. Run sends the report as a message. The result is {outcome, report, machine: {run_id, ir_hash}}. |
| The engine fails | The run fails with machine_error. |
In a conversation on web chat, email, Slack or Teams, the person of a mq_{seq} question is a team member, not the participant of the channel. The answer can be the corrected arguments of a write. So the channel refuses an answer from a participant, and a team member answers in the Inbox or the console.
A value that does not match the answer schema of the question does not end the wait. Run sends a message that names the problem, and the next turn can send another value.
refused and aborted are correct ends of a procedure, for example a refused claim. Read result.outcome to know which end the run took.
Safe calls
The engine logs each call before it makes it. When a run stops during a call and then continues, it does not run a write again:
- A
readcall runs again. - A
writeorirreversiblecall gets a timeout error. The engine then retries it only when the step isidempotent. Else the run holds withunknown_outcome, and a person checks the target system. - When the engine has the result of a call, the call never runs again.
For an _apis call, a 4xx or 5xx answer is an error. The code is the string code of the body when the operation declares it, else http_{status}. A 429 with no declared code is rate_limited, and the engine retries it. A 503 is unavailable for a read call. For a write or irreversible call it is http_503, because the origin can have done the work.
Where a machine agent cannot go
| Place | Lint |
|---|---|
A door with channels.phone |
machine_target |
agents.message of another agent |
machine_target |
agents.delegate of another agent |
machine_target |
agents.delegate: ['*'] or agents.message: ['*'] that includes a machine agent |
machine_target |
A console conversation does not list a machine agent as a chat target in this beta. Start a machine agent from the API, a trigger or rakerun run start. A door with web chat, email, Slack or Teams can name a machine agent. Each run of its conversations runs the Machine, not a model loop. The run keeps the agent timeout (at least 10m) and the longer of the agent idle_ttl and the door session.idle_ttl.
Push lint
The push lint compiles each procedure with the tool contracts of its agent. The deploy compiles it again. A procedure that does not compile fails the deploy of the whole tree, and the message names the agent and the first problem.
| Rule | Level | Check |
|---|---|---|
machine_procedure_missing |
error | The procedure file is absent, or it is not JSON or YAML. |
machine_compile |
error or warning | One finding for each problem of the compiler, with the code, the path in the procedure and the line. |
machine_tool_unknown |
error | A step or a pin names a tool that the agent cannot have. |
machine_effect_lowered |
error | A pin or a step lowers the effect of a tool. |
machine_model_ignored |
warning | The leaf agent.yml of a machine agent sets model. |
machine_output_schema |
error | A machine agent sets output_schema. |
machine_mcp_output_schema |
error | An MCP pin of the tool file has no outputSchema. |
machine_target |
error | A phone door, an agents.message or an agents.delegate names a machine agent. |
Billing
A machine agent pays the Run meter, as other agents do: 10 credits for each started minute of turn time. A wait for a person, an approval or an input stops the clock. The Run tools that the Machine calls bill as they do for other agents, for example a Paperwork extraction. Calls to the decision model and the exception model have no separate charge.
The model and decide rungs are not available in every environment. When a rung is not available, the next rung answers. End each rung list with person.
Run failure codes
| Code | Cause |
|---|---|
machine_held |
The procedure stopped with a hold. The Inbox item has the reason. |
machine_error |
The engine stopped with an error, or the Machine service was not available. |
machine_tools_changed |
A pinned MCP tool changed since the deploy. Copy the new contract and push again. |