03 · AGENTS

Where agents run

An agent runs in Layrcake, on its schedule, or wherever you already work: Claude Code, Codex or n8n. Its key, rules and record are the same in every place.

1

In Layrcake or in your own runtime

Pick it under Where it runs on the plan, in the Runs in row.

In LayrcakeClaude Code, Codex, n8n
Starts a runIts schedule, or Run nowYou, or your workflow
ModelThe one you choose, paid in Layrcake creditsThe one you use there, billed by them
KeyNever shown; Layrcake runs itShown once at Go live; you put it where it runs
Per-run budgetAlways heldHeld when the run has an id (see below)
ApprovalsEvery launch waits for your yesEvery launch waits for your yes

Running agents in Layrcake is offered only where it is switched on for your workspace. Elsewhere the Runs in row shows it as COMING, and you pick where you run it.

The Agents page also shows Where your agents run: each place an agent's key reported it was used, labelled as reported.

2

Models

An agent that runs in Layrcake thinks with a model you choose, and its thinking is charged in Layrcake credits by default. The plan asks “Which model should your agent think with?”

ModelWhen to pick it
Claude Sonnet 5.5The default. Best balance of quality and cost.
Claude Opus 5.5Highest quality, about twice Sonnet's cost. Choosing it doubles the suggested run budget.
Claude Haiku 4.5Fastest and cheapest. It may struggle with complex jobs.
Your own OpenRouter key COMINGThinking costs go to your OpenRouter account instead.

Each choice shows about how many credits of thinking a typical run uses. Per-token prices are on Credits & pricing. An agent that runs in Claude Code, Codex or n8n uses the model you already use there; Layrcake charges only for the tools it calls.

3

Schedules and Run now

An agent that runs in Layrcake runs on its schedule. Set it under Where it runs: the days, the time, the time zone, and what happens if a run is missed (skip it, or run it once if under 30 minutes late). The plan says it back in words. Go live shows the next run as its first run.

  • A run never starts while the last one is still going.
  • In a clock change, a missing hour is skipped and a repeated one runs once.
  • Pause, resume, change or remove the schedule from the same place.

Run now runs a live agent once, straight away. It is on the agent's card and in the builder. The confirm says the budget: “Runs once now, up to N credits; nothing is sent without your approval.” One run at a time: while one is queued or running, Run now says so and waits.

A run in Layrcake stops at the launch preview. The launch comes to Approvals for your yes. Choose Runs on an agent's card to see what it did: when each run started, what kind it was, how it stands, the credits it used of its budget and the launch it asked you to approve. A run's detail shows each step. Layrcake keeps what each step did, never the model's own words, for 90 days.

4

Claude Code and Codex

Open in Claude Code on an agent's card gives the steps, each with a line to copy. The key is never in them: the command reads it from your shell.

  1. Put the agent's key (shown once at Go live) in your shell.
  2. Add Layrcake to Claude Code.
  3. Download Export, unzip it, and copy the agent's skill folder into your project's .claude/skills/ folder (or ~/.claude/skills/ for every project).
  4. Start Claude Code and ask it to run the agent.
shell
export LAYRCAKE_API_KEY="<your key>"
claude mcp add --transport http layrcake https://mcp.layrcake.dev/mcp --header "Authorization: Bearer ${LAYRCAKE_API_KEY}"

Export

Export downloads a zip for Claude Code, Codex or any agent that reads skills or AGENTS.md:

FileWhat it is
skills/<agent>/SKILL.mdThe agent as a skill for Claude Code
AGENTS.mdThe same instructions for Codex and other agents
.mcp.jsonThe Layrcake MCP server for Claude Code, reading the key from LAYRCAKE_API_KEY
codex-config.tomlThe same server for Codex: add it to ~/.codex/config.toml
agent.jsonThe plan itself, for Create from export
README.mdHow to set it up

The key is never in the export. Anything in the plan's words that looks like a Layrcake key is removed.

Create from export

Create from export on the Agents page takes the zip, or just its agent.json, and makes a copy as a new draft. It never makes a live agent or changes an existing one: test the copy, then put it live. A file that was edited so it no longer matches its plan, or that would break a rule every agent keeps (like weakening approvals), is refused and nothing is created.

5

What an agent's key tells its client

When an MCP client connects with an agent's own key, Layrcake sends it the agent's instructions: its name and job, its plan and Also lines, and the rules that always hold. They are the same words as the export's SKILL.md and AGENTS.md, written from the version the agent runs.

The rules that always hold:

  • Spend at most the run's budget. Preview a paid step first and stop before going over.
  • Never send on its own. Build the campaign as a draft, ask with launch_campaign, show the approval link and stop.
  • Call get_me first, to see what the key may do today.
  • Never ask for, print or store the key.
  • When a tool refuses, say why in one line and stop that step. Don't look for a way around it.

For an agent outside Layrcake they also say how to start and end a run, below. The instructions are built from the plan alone: no person, key or run result is in them.

6

Runs outside Layrcake

An agent in Claude Code, Codex, n8n or a script keeps to its per-run budget by starting a run with its own key and sending the run's id on each call.

curl
curl -X POST https://api.layrcake.dev/v1/agent/runs \
  -H "Authorization: Bearer $LAYRCAKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

{ "run": { "run_id": "…", "agent_id": "…", "version": 3, "kind": "live", "state": "running",
           "budget": "150", "actual": null, "started_at": "…", "ended_at": null, … },
  "header": "X-Layrcake-Run" }
  1. Start a run: POST /v1/agent/runs with the body {}. The run uses the version the agent runs and its budget.
  2. Send X-Layrcake-Run: <run_id> on every Layrcake call of the run, over REST or MCP.
  3. End it when the work is done: POST /v1/agent/runs/<run_id>/end with the body {}.

The exported .mcp.json and Codex config already send the header from the LAYRCAKE_RUN_ID environment variable. Set it before you start a session and every call in it counts against that run. Without it, the agent's instructions tell it to start its own run. Several runs can be open at once, one per session.

AnswerWhat it means
run_budget_exceededThis call would take the run over its budget. The run stops. Stop too, and say how far you got.
run_unavailableThe run has ended, or it isn't this agent's.
run_requiredThis key spends only inside a run. Start one first.
invalid_request, reason not_an_agent_keyOnly an agent's own key starts or ends its runs.
invalid_request, reason hostedThis agent runs in Layrcake. Its runs start on its schedule or with Run now.
invalid_request, reason agent_not_onThe agent isn't on. A person can resume it on the Agents page.

A call with no run header works as any key's call does. To require a run for every paid call, tighten the key with autonomous_action_limits.require_run: true through PATCH /v1/keys/:id (a control:manage key; see Restrict). Turning it off again is a loosening, so only an owner can.