---
related_nodes: [relay_coding_agent, relay_status]
---

# On Coding Agent Event

Starts the workflow when a Relay coding-agent session reports an event.

- Tag: `on_coding_agent_event`
- Input: none
- Output: `output`

One workflow run per accepted event from the coding sessions of one Verdalia Relay connection,
whether OpenCode, Oh My Pi or Claude Code runs it in a mount, or the relay observes it in
Paseo. The session can be driven from the Coding Agents page, a `relay_coding_agent` node,
another workflow, an agent tool or, for a Paseo session, Paseo itself. Import a stored mount
session with `relay_coding_agent`'s `import_session` before listening for its events.
Paseo's top-level foreground agents are coding sessions as soon as the relay reports them.

This is the listening half of `relay_coding_agent`. `relay_coding_agent` opens sessions and sends
messages, and this trigger reacts when a turn finishes, the coding agent asks permission or a
question, or another selected event occurs.

Relay offers a mount provider only when it is enabled and its command is found on the user
PATH. `relay_list` shows the available providers and lists enabled providers with missing
commands under `unavailable`. See [Relay Coding Agent](/docs/nodes/relay_coding_agent#configuration)
for startup and import errors.

```
relay_coding_agent(send_prompt) ──▶ …                         the prompt
on_coding_agent_event ──▶ branch on output.envelope.event.type ──▶ Telegram Send
```

Match a sent message's events by the `message_id` the `send_prompt` op returned: `prompt_queued`,
`prompt_started`, `prompt_steered`, `prompt_recorded`, `cancel_requested`, `prompt_finished` and
`prompt_failed` carry it as `envelope.event.message_id`.

## Config

**connection**: the one Verdalia Relay connection whose sessions to listen to. A trigger holds one
relay's event stream from the moment it is installed and has no input, so a template is refused:
saving reports "Connection cannot be a template here" and installing fails with "takes one fixed
connection, not a template". Add one trigger per relay. Its output's `connection_id` is what a
downstream relay node templates on to answer the relay the event came from.

**session_id**: the coding session to follow, picked from the workspace's coding sessions; it is
stored as the session's Verdalia id, the one `relay_coding_agent` reports (`session.id` from
`start_session`, `open_session` or `read_session`, or `session_id` from
`find_session_by_provider_id`). Leave it unset (`null`, the default) to listen to every coding
session of the connection. Installation fails when no coding session has that id on the
connection.

**event_types**: which events start a workflow. Accepted values: `session_opened`,
`history_replay_started`, `history_replay_finished`, `prompt_queued`, `prompt_started`,
`prompt_steered`, `prompt_recorded`, `cancel_requested`, `prompt_finished`, `prompt_failed`, `agent_exited`,
`session_closed`, `user_message_chunk`, `agent_message_chunk`, `agent_thought_chunk`,
`tool_call`, `tool_call_update`, `plan`, `available_commands_update`, `current_mode_update`,
`config_option_update`, `session_info_update`, `usage_update`, `capabilities_update`,
`activity_update`, `permission_requested`, `permission_resolved`, `question_requested`,
`question_resolved`, `question_restated`, `notice`, `compaction`, `agent_message`, `history_reset`,
and `frame_undecodable`. An empty array accepts all of them.

The default is `["prompt_finished", "prompt_failed", "permission_requested",
"question_requested"]`. That covers both ways a prompt can end and the points where a session
waits for someone: to decide on a permission, or to answer its questions. Each prompt ends with
exactly one of `prompt_finished` or `prompt_failed`, except a prompt that joined a running turn
(`prompt_steered`), which ends with that turn. Chunks and tool traffic are available but not in
the default. A single prompt produces many of them, and each accepted event starts its own run.
`question_restated` is not in the default either: the question it restates ended before, and was
acted on then. Nor is `prompt_queued`: the message's own turn events follow it.
`prompt_recorded` is off by default. Select it to start a workflow when the Relay confirms that
the coding agent's own history holds the message, even if the turn has yet to finish.

```json
{
  "on_coding_agent_event": {
    "connection": "01JCONNECTION00000000000000",
    "session_id": null,
    "event_types": ["prompt_finished", "prompt_failed", "permission_requested", "question_requested"]
  }
}
```

Hear what Paseo agents report beyond their turns, such as notices and messages from other agents:

```json
{
  "on_coding_agent_event": {
    "connection": "01JCONNECTION00000000000000",
    "session_id": null,
    "event_types": ["notice", "agent_message", "prompt_finished"]
  }
}
```

## Output

The output is `{connection_id, session_id, provider, envelope}`:

```json
{
  "connection_id": "01JCONNECTION00000000000000",
  "session_id": "01JSESSION0000000000000000",
  "provider": "opencode",
  "envelope": {
    "at": "2026-09-26T12:00:00Z",
    "event": { "type": "prompt_finished", "message_id": "01JMESSAGE0000000000000000", "stop_reason": "end_turn" }
  }
}
```

`session_id` is the coding session's Verdalia id, the same one `relay_coding_agent` takes.
`provider` is `opencode`, `omp`, `claude`, or `paseo`. Use `relay_coding_agent`'s `read_session`
to get the provider's own id (`session.provider_session_id`) or the session's location. For a
mount session, `session.location` has `kind: "mount"` and `directory`; change workflow filters
on `location.kind` from `"acp"` to `"mount"`. The trigger itself returns no `location`.
`envelope.at` is when the event happened, in RFC 3339 format: Paseo's own time for an event from
a Paseo session's timeline (or, for the replayed turns of a reopened Claude Code session, the time
Claude Code's transcript records), otherwise the time the Relay recorded it. An event from a Paseo
session's timeline also carries `envelope.place` `{epoch, seq, turn}`: the timeline's epoch, the
sequence number Paseo gave it, and the turn it belongs to when Paseo names one. Branch on
`envelope.event.type` to handle event types differently.

Most events belong to an item of the session: a message, a thought, a tool call, a plan, a
permission request, a question, a notice, a compaction, or another agent's message. They carry
the item's `item_id`, which stays the same for every event of that item. A user message's
`item_id` is the `message_id` its prompt events carry.

- `session_opened`: `session_id`, `mode` (`new` for a started session, `load` for an opened one),
  optional `agent` `{name, title, version}`, `capabilities`, `config_options`, optional `modes`.
  `capabilities` says what the session supports, each a `true`/`false`: `load`, `list`, `close`,
  `images` (prompts may carry images), `reload` (the agent can be reloaded in its coding agent),
  `rewind_conversation` (the conversation can be rewound to a user message), `rewind_files` (the
  files the agent changed can be put back as they were before a user message), `rewind_both`
  (conversation and files together), `fork` (a new coding session can start with this one's
  conversation up to a turn), `interrupt` (a message can stop the running turn and start the
  next one), `attachments` (a message can carry files other than images, issues and pull
  requests, and diff comments), and `find` (the session's history can be searched and its
  prompts listed). OpenCode, Oh My Pi and Claude Code report the last eight as `false`.
- `history_replay_started` / `history_replay_finished`: bracket the history that a `load` replays.
- `prompt_queued`: `message_id`, `sender`. The relay holds the user message `message_id` until
  the agent takes it. `sender` is who sent it through Verdalia: `person`, `agent`, `workflow`
  or `mcp_client`, or `null` for a session start's first prompt.
- `prompt_started`: `message_id`, `text`. The user message `message_id` was delivered and
  started a turn. A Paseo turn someone else started has a `message_id` of its own and may have
  an empty `text`.
- `prompt_steered`: `message_id`, `text`. A message sent to Claude Code or Paseo joined a
  running turn. That turn ends once, under the `message_id` that started it.
- `prompt_recorded`: `message_id`. The Relay has evidence that the coding agent's history holds
  this user message. Use it to confirm recording; use `prompt_finished` for turn completion.
- `cancel_requested`: `message_id`, the message whose turn is being stopped.
- `prompt_finished`: `message_id`, `stop_reason` (`end_turn`, `max_tokens`, `max_turn_requests`,
  `refusal` or `cancelled`).
- `prompt_failed`: `message_id`, `error`. `error.kind` is `rpc` (with `code` and `message`),
  `undecodable` (with `error`), `agent_exited`, `dropped` (the turn was stopped before this
  prompt was delivered), or `provider` (with `message` and optional `code`, the provider's own
  failure).
- `agent_exited`: `expected` (`true` when the session was closed), `exit`. `exit.kind` is
  `process` (with `code`, `signal`, `stderr_tail`) or `disconnected` (with `reason`: the relay lost
  its connection to Paseo).
- `session_closed`: the session was closed. It sends no further events.
- `user_message_chunk` / `agent_message_chunk` / `agent_thought_chunk`: `item_id`, `offset`,
  optional `message_id`, and `content`: one piece appended to a message or thought. `offset` is
  how long the item was before it, in UTF-16 code units of its text plus one per other part.
  `message_id` is the agent's own id for the message. `content.type` is `text` (with `text`),
  `resource_link`, `resource`, `image`, `audio`, or `unsupported`.
- `tool_call`: `tool_call_id`, `title`, optional `name`, `kind`, `status`, `content`, `locations`,
  optional `raw_input`, and optional `detail`.
- `tool_call_update`: `tool_call_id` and only the fields that changed.
- `plan`: `entries`, each `{content, priority, status}`.
- `available_commands_update`: `commands`, each `{name, description, input_hint}`.
- `current_mode_update`: `mode_id`.
- `config_option_update`: `config_options`.
- `session_info_update`: `title` and `updated_at`. A missing field did not change, and `null` means
  it was cleared.
- `usage_update`: `used`, `size`, optional `cost` `{amount, currency}`, optional `input`, `cached`
  and `output` token counts, and optional `token_span` and `cost_span` (`last_turn` or `session`).
  The Relay reports each span for a Paseo session when it knows what the Paseo provider reports,
  and omits the span when unknown. A Paseo session sends an update whenever Paseo reports new
  usage, including during a turn. When a report leaves out the cost or a token count, the session
  repeats the last one it sent. It sends no cost while Paseo reports none.
- `capabilities_update`: `capabilities`, the whole new set in `session_opened`'s shape, sent only
  when it changes. A Paseo session's `rewind_conversation`, `rewind_files` and `rewind_both` are
  `false` while Paseo has stopped its agent's process, and follow what the agent reports once it
  starts again. Not in the default.
- `activity_update`: `delegates` (the subagents) and `background`, both whole lists, sent when either
  changes; Paseo sessions only. Each subagent is `{id, title, description, status}`, `status` one of
  `running`, `completed`, `failed` or `canceled`; each item of background work is `{id, kind,
  description, command, started_at, can_stop}`, `kind` one of `shell`, `monitor` or `other`. A
  missing `title`, `description` or `command` was not given. Not in the default.
- `permission_requested`: `request_id`, `tool_call`, and `options`, each `{option_id, name, kind}`.
  Answer the request with `relay_coding_agent`'s `answer_permission_request`, passing `session_id`,
  `request_id` and the chosen `option_id`.
- `permission_resolved`: `request_id`, `resolution`. `resolution.outcome` is `selected` (with
  `option_id`), `cancelled`, `withdrawn`, `agent_exited`, or `unknown`: Paseo stopped waiting on
  the request without saying how it ended.
- `question_requested`: `request_id`, optional `title`, `description` and `intro`, and
  `questions`, each `{question, header, options, multi_select, allow_other, allow_empty,
  placeholder, dismiss_label, detail, link}` with `options` each `{label, description, preview}`.
  `header`, `placeholder`, `dismiss_label`, `detail`, `link` and an option's `description`
  and `preview` are optional. Paseo uses `title` and `description` for its notification preview.
  `intro` appears before the questions and `detail` appears below its question. A question
  accepts the user's own words when it has no options or `allow_other` is set, multiple options
  when `multi_select` is set, and an empty answer when `allow_empty` is set. Claude Code emits
  this event for `AskUserQuestion` and MCP server requests (elicitations). An MCP form has one
  question per field and an `intro` such as `<server> asks: <message>`. A URL request has an
  HTTP(S) `link`; the card shows the full URL and **Open link** opens it in a new tab without
  answering the question. An unsupported form or a non-HTTP(S) URL is cancelled with a
  `notice` naming the server. Use `relay_coding_agent`'s `answer_question` or `decline_question`
  to respond. An invalid form answer fails with `invalid_question_answer`, naming the question
  and what it needs, and leaves it open.
- `question_resolved`: `request_id`, `resolution`. `resolution.outcome` is `answered` (with
  `answers`, one per question in order: the answer as text, including typed MCP form values
  rendered as text, `""` or `null` for an empty answer, or `null` when Paseo did not report it;
  and `given`, the original picks and text as `{"selected": [labels], "custom": "text"}`,
  `null` for one left empty or not reported), `declined`, `withdrawn`,
  `agent_exited`, or `unknown`: Paseo stopped waiting on the request without saying how it ended.
- `question_restated`: `request` (as `question_requested` carries it) and `resolution` (as
  `question_resolved` carries it). A question the session asked and saw end before its history
  was replayed (after a `history_reset`, a Relay restart, or the session being opened again),
  restated right after the `tool_call` it was asked in, or at the end of the replayed history
  when that call is not known. It is not a new question and has nothing to answer.
- `notice`: `level` (`info`, `warning`, or `error`) and `message`: something the agent wants seen
  that belongs to no message. For a Paseo session, a failure Paseo records outside a prompt the
  relay follows (a failed command, a turn failure no prompt took, a failure in replayed history)
  is a `notice` with level `error`. The agent's message chunks are only what it said. A Paseo
  session also gets an `info` notice "Idle. Your next message starts it." when Paseo stops its
  agent's process, and "Started" when it starts it again.
- `compaction`: `status` (`loading` or `completed`), optional `trigger` (`auto` or `manual`), and
  optional `pre_tokens`: the agent is compacting its context, or has.
- `agent_message`: `tool_call_id`, `event` (`message`, `finished`, `errored`,
  `permission_required`, or `closed`), `sender` `{id, title}`, and `text`: another agent spoke to
  this one through that tool call.
- `history_reset`: the session's history was replaced; every earlier event no longer applies.
  Read the session again with `relay_coding_agent`'s `read_session`.
- `frame_undecodable`: `frame`, `error`. The Relay received a message from the agent that it could
  not read.

A tool call's `detail`, when reported by Claude Code or Paseo, is tagged by `type`:

- `shell`: `command`, optional `cwd`, `output`, `exit_code`.
- `read`: `path`, optional `content`, `offset`, `limit`.
- `edit`: `path`, optional `old_text`, `new_text`, `unified_diff`.
- `write`: `path`, optional `content`.
- `search`: `query`, optional `tool` (`search`, `grep`, `glob`, or `web_search`), `content`,
  `paths`, optional `matches`.
- `fetch`: `url`, optional `result`, `status`.
- `worktree_setup`: `path`, `branch`, `log`, `commands`.

File paths in tool content, locations and details are `{scope: "mount", path}` relative to the
session's mount root, or `{scope: "host", path}` when the path is outside every mount (always for a
Paseo session).

## Delivery behavior

- Only events sent while the trigger is installed start a workflow; a session's earlier events are
  never replayed into it. `relay_coding_agent`'s `read_session` returns the events of a running
  session.
- A session that is already running when the workflow is installed is picked up from its next event.
- Each matching event starts one run, in the order the Relay sent them, including events that
  arrive while earlier runs are still going.
- For a static Relay, the backend asks the Relay to post events here while the trigger is installed,
  and keeps renewing that request. The Relay machine must be able to reach the backend's app URL,
  or no events arrive. A dynamic Relay sends its events over its existing link.
- Events sent while the Relay is disconnected are lost.
- Changes to the Relay's Paseo projects and agents start no workflow: only session events do.
- If the workflow is run without a staged event, this trigger's outgoing branch is skipped. Other
  roots in the same workflow still run as usual.

## Failure behavior

- Installation fails when the connection is missing, is not a Verdalia Relay connection, or has not
  been paired, when `session_id` names no coding session of the connection, and when the Relay
  answers but needs updating: a `verdalia-relay` older than coding
  sessions sends events that do not name their coding agent. The failure appears as a workflow
  install diagnostic. A Relay that is offline does not fail installation: its events start
  arriving once it is back.
- A run Verdalia cannot queue is retried.
