# Actions

Define actions, their CEL and schedule triggers, execution settings, publication, and policies.

## Action

| Field                                   | Type                           | Meaning                                                                                                                                                                      |
| --------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                                    | `ID!`                          | Global identifier for the `node(id)` query.                                                                                                                                  |
| `actionId`                              | `UUID!`                        | Identifier you supplied on create.                                                                                                                                           |
| `principal`                             | `String!`                      | Principal the handler runs as: `arn:twisp:database:::action/<actionId>`.                                                                                                     |
| `definition`                            | `ActionDefinition!`            | Name, triggers, tool block, tools, handler, config, policies, and execution settings, with defaults resolved.                                                                |
| `status`                                | `ActionStatus!`                | Published status governing matching now. See [Publication status](https://www.twisp.com/docs/reference/actions/actions.md#publication-status).                                                                                      |
| `pending`                               | `ActionStatus`                 | Status awaiting publication after a write. Null once published.                                                                                                              |
| `published`                             | `Timestamp`                    | When `status` took effect. Null while `UNPUBLISHED`.                                                                                                                         |
| `created`, `modified`                   | `Timestamp!`                   | When the action was first created, and the time of its last change.                                                                                                          |
| `version`                               | `Int!`                         | The current version number of this action. Previous versions are tracked in `history`. Advances on every definition write and every publication.                             |
| `_recordId`                             | `UUID!`                        | Internal Twisp record identifier.                                                                                                                                            |
| `history(first, after)`                 | `ActionConnection!`            | History of changes to this action, newest first.                                                                                                                             |
| `executions(where, sort, first, after)` | `ActionExecutionConnection!`   | The action's executions, every version, ordered by creation time. `where` takes the [execution filters](https://www.twisp.com/docs/reference/actions/executions.md#listing-and-filtering) but `actionId`. |
| `sessions(where, sort, first, after)`   | `ActionSessionConnection!`     | The action's [sessions](https://www.twisp.com/docs/reference/actions/sessions.md), newest first unless `sort: ASC`. `where` takes `status`, `createdAfter`, and `createdBefore`.                          |
| `session(id, version)`                  | `ActionSession`                | One of the action's sessions by session ID, or null.                                                                                                                         |
| `memories(sort, first, after)`          | `ActionAgentMemoryConnection!` | The agent's [memory records](https://www.twisp.com/docs/reference/actions/memory.md#agent-memory), newest first unless `sort: ASC`. Deleted and superseded records are omitted, except preview deletions. |
| `memory(id, version)`                   | `ActionAgentMemory`            | One of the agent's memory records, deleted or not, or null.                                                                                                                  |

## Listing actions

`actions(where: { status: ... })` narrows the list to one published status. The filter reads `status`, not `pending`, so an action whose disable or delete has not published yet is still listed under its current published status. Without a filter the list includes deleted actions.

`where: { tool: true }` lists only actions with a `tool` block, which callers can call as tools, and `tool: false` only those without one. `where: { native: true }` lists the [native tools](https://www.twisp.com/docs/reference/actions/tools.md#native-tools), with their well-known `actionId`s, in place of your own actions.

```graphql
query ActiveActions($after: String) {
  actions {
    actions(where: { status: ACTIVE }, first: 50, after: $after) {
      nodes {
        actionId
        definition {
          description
        }
      }
      pageInfo {
        endCursor
        hasNextPage
      }
    }
  }
}
```

## Definition

`ActionDefinitionInput` is used by `createAction` and `validateAction`. Omitted settings take the defaults below.

| Field         | Type                           | Default      | Meaning                                                                                                                                                                                                   |
| ------------- | ------------------------------ | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name`        | `String`                       | none         | Registry name, unique within the tenant among actions that are not deleted: 1 to 64 letters, digits, underscores, or hyphens. Other actions refer to tools and skills by this name. Required for a skill. |
| `description` | `String`                       | `""`         | Human readable description of this action.                                                                                                                                                                |
| `enabled`     | `Boolean`                      | `true`       | Whether the action runs for events and calls once published.                                                                                                                                              |
| `triggers`    | `[ActionTriggerInput!]`        | `[]`         | Up to 16 events or schedules that run the action. See [Triggers](https://www.twisp.com/docs/reference/actions/actions.md#triggers).                                                                                                                              |
| `tool`        | `ActionToolInput`              | none         | Makes the action callable as a tool. See [Tools](https://www.twisp.com/docs/reference/actions/tools.md).                                                                                                                               |
| `agent`       | `ActionAgentInput`             | none         | What an agent is told and returns. Required for kind `agent`, and allowed only on it. See [Agents](https://www.twisp.com/docs/reference/actions/agents.md).                                                                            |
| `skill`       | `ActionSkillInput`             | none         | What a skill supplies. Required for kind `skill`, and allowed only on it. See [Skills](https://www.twisp.com/docs/reference/actions/skills.md).                                                                                        |
| `tools`       | `[ActionToolReferenceInput!]`  | `[]`         | Tools the action may call. See [Tool references](https://www.twisp.com/docs/reference/actions/tools.md#tool-references).                                                                                                               |
| `skills`      | `[ActionSkillReferenceInput!]` | `[]`         | Skills the action may load. See [Skill references](https://www.twisp.com/docs/reference/actions/skills.md#skill-references).                                                                                                           |
| `session`     | `ActionSessionInput`           | none         | Gives the action sessions. See [Sessions](https://www.twisp.com/docs/reference/actions/sessions.md).                                                                                                                                   |
| `kind`        | `String!`                      | required     | Handler to run. See [Handlers](https://www.twisp.com/docs/reference/actions/actions.md#handlers).                                                                                                                                                                |
| `config`      | `JSON!`                        | required     | JSON object configuring the handler. Its schema depends on `kind`.                                                                                                                                        |
| `policies`    | `[PolicyInput!]`               | `[]`         | Policies granted to the action's `principal`.                                                                                                                                                             |
| `execution`   | `ActionExecutionSettingsInput` | all defaults | Timing and retry bounds. See [Execution settings](https://www.twisp.com/docs/reference/actions/actions.md#execution-settings).                                                                                                                                   |

```graphql
mutation CreateAction($id: UUID!) {
  actions {
    createAction(
      id: $id
      input: {
        description: "Echo large USD debits"
        triggers: [
          {
            event: """
            event.type == "balance.updated" &&
            event.data.currency == "USD" &&
            event.data.settled.dr_balance > money("1000", "USD")
            """
          }
        ]
        kind: "agent.echo"
        config: { agent_id: "large-debits", sleep_ms: 0 }
        execution: { responseTimeout: "30s", maxInvocations: 5 }
      }
    ) {
      actionId
      version
      status
      pending
    }
  }
}
```

Config must be a JSON object. Numeric tokens supplied through JSON variables are preserved by the server; inline GraphQL floating-point literals use floating-point parsing. Use strings for exact decimal values when your client cannot preserve their precision.

## Triggers

Each trigger has an `event` field: a boolean CEL expression over `event`, the typed [event](https://www.twisp.com/docs/reference/actions/executions.md#the-event). A trigger can instead have a `schedule`, which runs the action at set times; see [Schedule triggers](https://www.twisp.com/docs/reference/actions/actions.md#schedule-triggers). Each trigger has exactly one of `event` and `schedule`. A trigger can have a `name`: lowercase letters, digits, `_`, and `-`, starting with a letter, at most 64 bytes, and unique among the action's triggers. A session's [turns](https://www.twisp.com/docs/reference/actions/sessions.md#session-turns) refer to triggers by name, and an agent's turn shows it. An action with a `session` also gives each trigger a `session` role; see [Sessions](https://www.twisp.com/docs/reference/actions/sessions.md). An agent's trigger can also set a `view`: what the agent's turn shows of each event it admits; see [Input views](https://www.twisp.com/docs/reference/actions/agents.md#input-views). The expression must be non-empty and compile to a boolean. Use `&&` and `||` to combine conditions and `true` to match everything. `event.type` is the event type: the record's name in lower case and the change, such as `journal.updated` or `accountset.inserted`, or for an actions record its record type and the change, such as `action_session.updated` (see [Actions records](https://www.twisp.com/docs/reference/actions/executions.md#actions-records)). Other event keys and the record fields inside `event.data` are snake_case, for example `event.data.journal_id`. Record values keep their types, so compare identifiers with `uuid("...")`, money with `money("...", "USD")`, and decimals, dates, timestamps, and durations with their constructors. A typed field never equals a plain string, and a trigger that compares one with a string literal is rejected (see below).

An action has up to 16 triggers; a tool or skill can have none, and then never matches events. A committed change that matches any of them runs the action, and a change that matches several runs it only once: the action gets one execution per event and action version. That execution's `matchedTriggers` lists the position in `definition.triggers` of every trigger that matched, in ascending order. Each trigger is validated separately, and a validation error names the rejected trigger by position, for example `triggers[1]: CEL trigger must have boolean result type`. When one trigger fails to evaluate against an event, only that trigger does not match; the others are still evaluated.

Because a trigger that can never match would otherwise fail silently, `createAction`, `updateAction`, and `validateAction` check each trigger against the event's keys and against the fields of the records whose events it selects with `event.type` or `event.record_type`. In `event.type == "balance.updated" && event.data.settled.dr_balance > money("20", "USD")`, `event.data.settled.dr_balance` is checked against a balance record. These are rejected:

- A key the event does not have, such as `event.eventType` for `event.type`.
- A field the record does not have, such as `event.data.settled.normal_balance` (a balance layer has `dr_balance` and `cr_balance`) or `event.data.accountId` for `event.data.account_id`. Under `has()` or optional access (`.?`), which do not fail for a missing field, one is rejected only when the record has a field it was likely meant to be.
- An `event.type` that is close to a record's but is not one, such as `account_set.updated` for `accountset.updated`.
- A UUID, enum, money, decimal, timestamp, date, duration, number, or boolean field compared with a string literal, such as `event.data.account_id == "..."` for `event.data.account_id == uuid("...")`. Compare an enum with its number.

The error names the trigger and the fix, for example `triggers[1].event: event.data.settled.normal_balance: event.data.settled, a BalanceAmount, has no field "normal_balance"; did you mean "dr_balance" or "cr_balance"? Its fields are dr_balance, cr_balance, entry_id, and modified`. Any key is accepted beneath a JSON value, such as an account's `metadata`, a KV record's `value`, or a balance's `dimensions`. A trigger that does not select only record events this way, such as one that does not test `event.type`, can match records added later, so its keys and fields are checked less strictly: one is rejected only when it respells an event key or a record's field, such as `event.data.accountId` where records have `account_id`. `updateAction` checks only the triggers it changes, so an action whose triggers were written before a check existed can still be updated.

```graphql
mutation CreateAction($id: UUID!) {
  actions {
    createAction(
      id: $id
      input: {
        description: "Echo journal changes and large USD debits"
        triggers: [
          { event: "event.type == \"journal.updated\"" }
          {
            event: """
            event.type == "balance.updated" &&
            event.data.currency == "USD" &&
            event.data.settled.dr_balance > money("1000", "USD")
            """
          }
        ]
        kind: "agent.echo"
        config: { agent_id: "journals-and-debits", sleep_ms: 0 }
      }
    ) {
      actionId
      definition {
        triggers {
          event
        }
      }
    }
  }
}
```

### Schedule triggers

A trigger with a `schedule` in place of `event` is the action's own clock, for work that no record change starts, such as a nightly reconciliation. A schedule trigger requires a `name`.

| Schedule field | Type      | Meaning                                                                                                                                                                                                                                                                                                                                                                                |
| -------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cron`         | `String!` | A standard 5-field cron expression: minute, hour, day of month, month, and day of week, with lists, ranges, steps, and month and weekday names, such as `0 9 * * MON-FRI`. Day of week 0 and 7 are both Sunday. An expression may not restrict both day of month and day of week; restrict one and leave the other `*`. Macros such as `@daily` and a seconds field are not supported. |
| `timezone`     | `String`  | The IANA timezone the expression is evaluated in, such as `America/New_York`. Omitted is `UTC`.                                                                                                                                                                                                                                                                                        |

Across a daylight-saving change, a local time that the change skips does not fire, and a local time that it repeats fires once, at its first occurrence. A schedule fires within about a minute of its time.

Each firing is an event of type `schedule.fired` whose `data` is `{trigger, scheduled_at}`: the trigger's name and the scheduled time, which is also the event's `occurredAt`. A firing reaches only its own trigger in the action's current version; it is never matched against the action's other triggers or against other actions. Its identity is derived from the action, the trigger, and the scheduled time, so a firing delivered twice is one event. What a firing does depends on the trigger's [session role](https://www.twisp.com/docs/reference/actions/sessions.md#session-roles):

| Role              | A firing                                                                                                                                                                                                                     |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| None              | For an action without a `session`: runs the action once, one execution per firing.                                                                                                                                           |
| `start: {input}`  | Finds or creates a session. The mapping reads the firing, so `{ run: "string(event.data.scheduled_at)" }` starts a session per firing and a constant keys a single session. The session's `startedAt` is the scheduled time. |
| `resume: {id}`    | Is delivered to the open session that `id` names, such as a constant `"'reconciliation'"`.                                                                                                                                   |
| `resume: {input}` | Rejected: one firing would reach every session whose field matched.                                                                                                                                                          |

A schedule belongs to the action's current version: publishing a version starts, changes, or stops the schedules of its schedule triggers. A firing for a trigger the current version no longer has, or of an action that is disabled or deleted, is dropped.

```graphql
triggers: [
  {
    name: "nightly"
    schedule: { cron: "0 2 * * *", timezone: "America/New_York" }
  }
]
```

## Updating a definition

`ActionUpdateInput` has the same fields, all optional. Omitted fields keep their current values, including settings nested inside `execution`. Explicit `null` is rejected everywhere except on `tool`, `agent`, `skill`, and `session`, where it removes the block, and on a setting inside `execution`, where it restores that setting's default. A supplied `session` replaces the whole block. `policies: []` clears the policy list. A supplied `triggers` list replaces all of the current triggers. A supplied `tools` or `skills` list replaces the current one; omitting it keeps each reference and its `version`. A supplied `config` replaces the whole object; it is not merged with the existing config. Every update requests publication of the whole definition, so the action passes through `pending` again.

```graphql
mutation DisableAction($id: UUID!) {
  actions {
    updateAction(id: $id, input: { enabled: false }) {
      version
      status
      pending
    }
  }
}
```

## Execution settings

Each duration is a Go duration string such as `"90s"`, `"5m"`, or `"1h30m"`. Values are resolved and stored with the action version, so later changes to defaults never alter existing executions.

| Setting             | Default | Maximum | Bounds                                                                                                                                 |
| ------------------- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `timeout`           | `24h`   | `24h`   | The whole execution, from creation through every invocation, retry wait, and asynchronous wait. Produces the execution's `deadline`.   |
| `maxInvocations`    | `24`    | `24`    | Total invocations, including the first.                                                                                                |
| `retryDelay`        | `1m`    | `12h`   | Wait before the second invocation.                                                                                                     |
| `retryBackoff`      | `2`     | `60`    | Multiplier applied to the wait before each later invocation. `1` keeps the wait flat.                                                  |
| `maxRetryDelay`     | `1h`    | `12h`   | Ceiling on the backed-off wait.                                                                                                        |
| `responseTimeout`   | `1m`    | `10m`   | How long a `RUNNING` invocation has to succeed, fail, or accept. Produces the invocation's `responseDeadline`.                         |
| `completionTimeout` | `1h`    | `24h`   | How long an `ACCEPTED` invocation has to report its outcome, measured from acceptance. Produces the invocation's `completionDeadline`. |

The wait before invocation _n_ is `retryDelay × retryBackoff^(n−2)`, capped at `maxRetryDelay` and jittered by up to 10% so that executions failing together do not retry in lockstep. With the defaults the waits run 1m, 2m, 4m, 8m, 16m, 32m, then hourly.

Combinations that could never take effect are rejected: `responseTimeout` or `completionTimeout` longer than `timeout`, `retryDelay` longer than `maxRetryDelay`, or a `retryDelay` that leaves no room for a second invocation within `timeout`.

## Publication status

Definition writes take effect asynchronously. `status` is the published state that governs matching now; `pending` is the state the latest write is waiting to publish.

| `status`      | Meaning                                                                                       |
| ------------- | --------------------------------------------------------------------------------------------- |
| `UNPUBLISHED` | Nothing has been published yet. `pending` names the first state to publish.                   |
| `ACTIVE`      | The definition is published and matching events.                                              |
| `DISABLED`    | The definition is published but not matching.                                                 |
| `DELETED`     | The action is removed from matching. Its definition, history, and executions remain readable. |

A create reports `status: UNPUBLISHED` with `pending: ACTIVE`, or `pending: DISABLED` when created with `enabled: false`. Disabling an active action reports `status: ACTIVE` with `pending: DISABLED` until publication confirms. A delete reports `pending: DELETED`, after which the action can no longer be edited.

Publication writes a version of its own. It keeps the definition the write stored and changes only `status`, `pending`, and `published`, so a create returns version 1 and its publication becomes version 2, and an update that returns version N publishes as version N + 1, with the same definition.

An event is matched against the definition that was published when the event committed. Creating or enabling an action does not replay earlier events, and events that occurred while an action was active can still create executions after it is disabled or deleted.

## Principal and policies

Each action runs as the client principal `arn:twisp:database:::action/<actionId>`. Creating or updating the action sets that client's policies to `definition.policies`, plus grants scoped to its references: permission to read and invoke each tool in `definition.tools` and each skill in `definition.skills`, and, for a tool with a [session](https://www.twisp.com/docs/reference/actions/sessions.md#tool-sessions), permission to read and create that tool's sessions and session inputs. An agent's [memory](https://www.twisp.com/docs/reference/actions/memory.md#agent-memory) needs no grant: the agent uses it as its own record, outside the policy chain. A tool's own policies are never added to its callers' clients: they apply to the operations performed through the tool, as a layer of the [policy chain](https://www.twisp.com/docs/reference/actions/actions.md#policy-chain). Omit the list or pass `[]` for a handler that never calls the Twisp API. Disabling or deleting an action keeps its client so outstanding executions can finish.

A change to the client's policies, such as a read added to `definition.policies`, applies to the new version's executions at once: every invocation of the version an update creates runs under the policies that update set, or a later update's. So does every [rerun](https://www.twisp.com/docs/reference/actions/executions.md#manual-reruns) requested after the update, whatever `actionVersion` it pins. Any other invocation of an earlier version, such as a retry or an execution queued before the update, runs under the new policies at the latest 5 minutes after the update.

Read the client's effective policies with `auth { client(principal: ...) }`. The caller managing the action needs permission to write action records and to manage `system.Client` records.

## Policy chain

Every operation a tool or an agent performs is authorized against a chain of policy lists, one for each layer of the call stack, and must be allowed by every layer:

| Layer      | Policies                                                                                                                                                              |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Outermost  | The client that started the work: the caller of `invokeAction` or `startAction`, or the action's own client for an execution started by a trigger or a session.       |
| MCP server | The server version's `policies`, for a request to an [MCP server](https://www.twisp.com/docs/reference/actions/mcp.md). The outermost layer is then the principal the request's token resolves to. |
| Agent      | The agent version's `policies`, when an agent is on the call stack. A session agent's layer also lets it read its own session.                                        |
| Each tool  | The `policies` of the version of each tool on the call stack, from the first call down to the one performing the operation.                                           |

An explicit `DENY` in any layer denies the operation, and each layer's assertions apply. For an update, assertions on `context.document` are checked against the record as it was and as it becomes, and both must pass. Operations are attributed to the outermost client. Because every layer must allow an operation, a layer can only narrow what the layers above it allow:

- Declaring a tool never grants its caller anything, and a tool can do only what its callers can.
- An agent's `policies` bound everything it can reach, through any tool.
- A tool with no policies can perform no operation. List the access a tool's program needs in its `policies`; its callers need that access too.
- A [native tool](https://www.twisp.com/docs/reference/actions/tools.md#native-tools)'s policies are its layer, as any tool's are: `graphql` allows everything, so a `graphql` call can do exactly what the layers above it allow. [Agent tools](https://www.twisp.com/docs/reference/actions/agents.md#agent-tools) add no layer.
- A skill's policies gate only its load, which reads no business data.

A call uses the policies of the versions it runs: a pinned version's, or for a reference without a `version`, those of the latest version when the execution started (see [Versions](https://www.twisp.com/docs/reference/actions/tools.md#versions)). A tool's policies only narrow what its callers may do, so a new tool version never gives a caller more. A permission error names the denied operation and resource, and the layer and policy that denied it.

## Validation

`validateAction` resolves defaults, checks the triggers (including their record fields; see [Triggers](https://www.twisp.com/docs/reference/actions/actions.md#triggers)), session roles and expressions, handler kind, configuration, policies, and execution settings, resolves each `tools` and `skills` entry, and each of a skill's `tools`, as a create would, and evaluates the triggers against up to 100 `samples`. Each sample is a CEL map expression describing an event: a JSON object is a valid sample, and typed fields use the same constructors as triggers, such as `uuid("...")`, `money("9.99", "USD")`, `decimal("0.125")`, `date("2026-09-15")`, or `timestamp("2026-09-15T12:00:00Z")`. A sample that is not a map with string keys is rejected. Samples bind no session, so a resume trigger whose predicate reads `session` reports an evaluation error for a sample its other terms do not reject. The call returns the resolved definition and one result per sample, in order.

| Result field | Type       | Meaning                                                                                                                                                                                                                                           |
| ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `matched`    | `Boolean!` | Whether any trigger accepted the sample.                                                                                                                                                                                                          |
| `error`      | `String`   | CEL evaluation errors, each prefixed with the failing trigger's position such as `triggers[0]: `, or null. A sample can match while another trigger errors. A sample every trigger rejected without error has `matched: false` and `error: null`. |

```graphql
mutation Validate {
  actions {
    validateAction(
      input: {
        triggers: [
          {
            event: """
            event.type == "journal.updated" &&
            event.data.journal_id == uuid("e3a91846-cd8a-4b2c-9a73-e159498f0571")
            """
          }
        ]
        kind: "agent.echo"
        config: { agent_id: "check", sleep_ms: 0 }
      }
      samples: [
        """
        {"type": "journal.updated", "data": {"journal_id": uuid("e3a91846-cd8a-4b2c-9a73-e159498f0571")}}
        """
        """
        {"type": "journal.updated", "data": {"journal_id": "e3a91846-cd8a-4b2c-9a73-e159498f0571"}}
        """
      ]
    ) {
      samples {
        matched
        error
      }
      definition {
        execution {
          timeout
          maxInvocations
          retryDelay
        }
      }
    }
  }
}
```

The first sample returns `matched: true`. The second returns `matched: false` with an error prefixed `triggers[0]: `, because a UUID compared with a plain string is an evaluation error; live events always carry the typed identifier. An invalid definition or sample returns a GraphQL error instead of a result.

Schedules and a session's end are checked as a create would check them. A validation error names the rejected setting, such as `session.schedule[0] requires exactly one of cron and every`:

- A trigger has exactly one of `event` and `schedule`. A schedule trigger has a `name`, and a schedule trigger with a session role resumes by `id`, not by `input`.
- A `cron` expression has exactly 5 fields, uses no macro such as `@daily` and no seconds field, and does not restrict both day of month and day of week. A `timezone` is an IANA timezone name.
- `session.ends` compiles over `session.input` and `session.started_at` and evaluates to a timestamp.
- `session.schedule` has at most 8 entries. Each has a `name` under the trigger name rules, unique among the action's triggers and schedule entries, and exactly one of `cron` and `every`; `timezone` is allowed only with `cron`, and `every` is whole minutes, at least 1 minute.
- `turns.on` names existing triggers or schedule entries, and `turns.window` is at most 24 hours.
- A tool's session declares neither `ends` nor `schedule`.

## Handlers

`kind` selects the handler. Its `config` is a JSON object validated on create, update, and validation.

| Kind             | Handler                                                                                                                               |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `agent.echo`     | Returns the event it received. See below.                                                                                             |
| `tool`           | Runs a Starlark program. See [the `tool` handler](https://www.twisp.com/docs/reference/actions/tools.md#the-tool-handler).                                         |
| `graphql`, `cel` | Your own version of a [native tool](https://www.twisp.com/docs/reference/actions/tools.md#native-tools).                                                           |
| `skill`          | Returns guidance. See [the `skill` handler](https://www.twisp.com/docs/reference/actions/skills.md#the-skill-handler).                                             |
| `model`          | Asks a provider's model typed questions. Built in only: a write of kind `model` is rejected. See [Models](https://www.twisp.com/docs/reference/actions/models.md). |
| `agent`          | Runs a model in a loop. See [Agents](https://www.twisp.com/docs/reference/actions/agents.md).                                                                      |
| `mcp`            | Serves an MCP endpoint. See [the `mcp` handler](https://www.twisp.com/docs/reference/actions/mcp.md#the-mcp-handler).                                              |

### `agent.echo`

Waits, then returns the event it received as the invocation's `output`, with the same keys and typed values that `event` exposes to filters. Use it to observe matching, publication, retries, and history without an external system.

```json
{ "agent_id": "local-journal-echo", "sleep_ms": 1000 }
```

| Field      | Required | Meaning                                           |
| ---------- | -------- | ------------------------------------------------- |
| `agent_id` | yes      | Non-empty label for the handler instance.         |
| `sleep_ms` | no       | Delay in milliseconds, 0 to 600000. Default 1000. |

Unknown fields are rejected. A `sleep_ms` longer than `responseTimeout` makes every invocation time out, which the tutorial uses to demonstrate retries.
