> ## Documentation Index
> Fetch the complete documentation index at: https://agent.minimax.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Events (hooks)

> Register hooks with on() to draw on the status band and in panels, respond to slash commands the user runs, and react when sessions, turns, and tool calls happen.

In these docs, a hook means a handler you register in extension code with `on(...)`. The `hooks.json` feature that runs commands on events is called command hooks and is outside the scope of these docs. MCode calls your hook when the matching event happens. This page covers how to register hooks, the static rules registration must follow, when each event fires and what `e` contains, and what happens when a hook fails or times out.

Extensions have three kinds of events:

* `ui.render`: MCode calls it when it needs to draw a site, and you return the elements to show. See [Interface](https://agent.minimax.io/docs/extension/interface.md#render-chain).
* Observe events: a session starts, a turn starts or ends, a tool call starts or ends, context usage changes, or the user closes a panel. Observe events notify your hook after the event happens, and a slow or failing hook never slows the conversation down.
* `command.run`: the user ran a slash command (`/` command) your plugin registered. See [command.run](#command-run).

There are three sites. The **status band** is the strip above the message box, inside its border. All plugins share one band, and each draws a line or two in it. Its site name in code is `above-prompt`. A **panel** is a tab in the conversation's side panel on the right, next to tabs such as Files and Browser. Its site name in code is `pane`. The **backdrop** is the backdrop behind the conversation in the main window, a layer under all the panels. It replaces the wallpaper while a plugin theme is active. Its site name in code is `backdrop`.

> [!NOTE]
>
> The type files are the source of truth for fields. If `.minimax-plugin/types/` in your development folder disagrees with this page, trust the type files.

## Register hooks

The extension module `hooks/register.tsx` exports a `register` function. MCode calls it once when it loads the module and passes in `on`. Call `on()` in the function body to register all your hooks.

```tsx hooks/register.tsx theme={null}
import type { Register } from '@minimax/mcode-plugin-extension';

export const register: Register = (on) => {
  // No matcher: called at the end of every turn
  on('turn.complete', async (ctx, e) => {
    // ...
  });

  // With a matcher: called only when the read tool is called
  on('tool.call', { tool: 'read' }, async (ctx, e) => {
    // ...
  });
};
```

`on` has two forms:

| Form | Use for |
| - | - |
| `on(event, handler)` | Observe events that have no matcher, or when you want every occurrence of an event |
| `on(event, matcher, handler)` | `ui.render` and `command.run` (matcher required), plus `tool.call`, `tool.result`, and `ui.close` |

Handler parameters:

| Hook | Parameters | Return value |
| - | - | - |
| Observe events | `(ctx, e)` | None needed |
| `command.run` | `(ctx, e)` | `{ text }`, or nothing. See [command.run](#command-run) |
| `ui.render` | `(ctx, e, next)` | The element tree to show. `await next()` is what the plugins after you drew |

`ctx` is the [Extension API](https://agent.minimax.io/docs/extension/api.md) for this Activation. All hooks in the same Activation share one `ctx`. `e` is the event payload and is read-only.

Only hooks receive `ctx`. Callbacks such as `<Button onPress>`, `<Input onSubmit>`, `ctx.clock`, and `ctx.store.onDidChange` receive only their own values (for example `onPress={() => …}`, `onSubmit={(value) => …}`). When you need `ctx` there, use the `ctx` of the enclosing hook. Declaring your own `ctx` parameter in a callback doesn't raise an error, but that parameter holds nothing, and the code fails at run time.

> [!WARNING]
>
> Variables at the top level of the module are shared by all sessions. Keep per-session data in [`ctx.state`](https://agent.minimax.io/docs/extension/api#state).

### matcher

A matcher narrows what a hook receives. Only the events below have matchers. All fields are optional (except `site` for `ui.render` and `command` for `command.run`). Names must match exactly, except `command`, which is compared without regard to case:

| Event | Matcher fields | Notes |
| - | - | - |
| `ui.render` | `site` (required), `id` | `site` is `'above-prompt'`, `'pane'`, or `'backdrop'`, plus [`'above-prompt-list'`](https://agent.minimax.io/docs/extension/interface#above-prompt-list) Coming soon. `id` applies only to `pane` and names a panel id. Leave it out to match all panels |
| `tool.call`, `tool.result` | `tool`, `server` | `tool` is the tool name the Agent sees, such as `read` or `mcp__server__get_item`. `server` is the MCP server an MCP tool belongs to |
| `ui.close` | `id` | Receive only closes of the panel with this id |
| `command.run` | `command` (required) | A command name this module registered with `ctx.command.register`, without the `/` |

`session.start`, `session.measure`, `turn.start`, and `turn.complete` have no matcher.

```tsx theme={null}
// Watch only tool results from the notes server
on('tool.result', { server: 'notes' }, async (ctx, e) => {
  if (e.status !== 'ok') await ctx.ui.toast(`${e.toolName} failed`, { tone: 'danger' });
});
```

## Static rules

Preview and `test` first scan your source statically. That's how MCode learns which hooks you register and which `ctx` methods you call. So there are a few hard rules on how you write code. Breaking one reports the diagnostic below, and the extension doesn't load. Type checking can't catch these problems, so watch for them yourself.

| Rule | Diagnostic when broken |
| - | - |
| Call `on()` only at the top level of the `register` function body. Not inside `if`, loops, or callbacks, and not after an `await` | [`EXTENSION_REGISTER_SHAPE_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| The hook passed to `on()` must be an inline function or a function declared at the top level of this module | [`EXTENSION_REGISTER_SHAPE_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| A matcher must be an object literal with string literal values, using only the fields and sites in the table above | [`EXTENSION_MATCHER_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| `command.run` must have a matcher, and `command` must be a name this module registered with `ctx.command.register` (case can differ) | [`EXTENSION_MATCHER_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| The event name must be `ui.render`, `command.run`, or one of the observe events listed below | [`EXTENSION_EVENT_UNSUPPORTED`](https://agent.minimax.io/docs/extension/errors) |
| Each site can have only one `ui.render` (for `pane`, one per `id`, and only one without an `id`) | [`EXTENSION_DUPLICATE_ENTRY`](https://agent.minimax.io/docs/extension/errors) |
| Write `ctx` out in full, such as `ctx.state.set(…)`. Don't destructure it, alias it, access it dynamically with `ctx[name]`, or pass `ctx` to another function | [`EXTENSION_CALL_SHAPE_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| The first argument of `ctx.mcp.call` (the server name) must be a string literal | [`EXTENSION_CALL_SHAPE_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| The argument of `ctx.command.register` must be a plain object literal with only the keys `name`, `description`, and `argumentHint`, and `name` must be a string literal. No spreads, computed keys, getters, setters, or methods | [`EXTENSION_CALL_SHAPE_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| The `name` in `ctx.command.register` must match `^[A-Za-z0-9_-]{1,64}$` and must not be the name of a built-in command | [`EXTENSION_COMMAND_NAME_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| The module must export a `register` function | [`HOOK_MODULE_EXPORT_INVALID`](https://agent.minimax.io/docs/extension/errors) |
| A `ui.render` drawing must use `next`, or it covers the plugins after it (a warning, doesn't block preview). Coming soon Once the status band is drawn in two steps, `above-prompt` draws only your plugin's own row and no longer warns without `next`; chained sites such as `above-prompt-list`, `pane`, and `backdrop` still must use `next` | [`EXTENSION_SHADOWING`](https://agent.minimax.io/docs/extension/errors) |
| A drawing can't call `ctx.state.set` / `ctx.state.update` | [`EXTENSION_RENDER_SIDE_EFFECT`](https://agent.minimax.io/docs/extension/errors) |

Loading also runs two run-time checks. If `register` throws, MCode reports [`EXTENSION_REGISTER_FAILED`](https://agent.minimax.io/docs/extension/errors). If the `on()` calls that actually run don't match the static scan, it reports [`EXTENSION_ENTRY_MISMATCH`](https://agent.minimax.io/docs/extension/errors).

Here are some common mistakes:

```tsx theme={null}
// Wrong: on() inside an if
if (enabled) on('turn.complete', handler);

// Wrong: the matcher value isn't a literal
const tool = 'read';
on('tool.call', { tool }, handler);

// Wrong: destructuring ctx
on('turn.complete', async ({ state }, e) => { /* ... */ });

// Wrong: the server name is a variable
const server = 'notes';
await ctx.mcp.call(server, 'sync');
```

## Observe events

Observe events call your hook **after** the event happens. Each firing is a new Invocation that still uses the same `ctx` from this Activation. In the hook you can write `ctx.state` and `ctx.store`, call MCP, show a toast, ask for a redraw, fill text into the message box, call a model, or start a background subagent.

A few rules apply to all of them:

* **They don't slow the conversation down.** If a hook is slow or fails, the conversation goes on as usual.
* **They can see conversation content.** Events include your prompt and the input and output of tool calls, as is, without truncation or redaction. Thinking never appears. The Agent's reply appears only as the `answer` field in the `turn.complete` of a subagent your plugin started.
* **Nothing is read if nobody listens.** MCode reads an event's content only when an activated plugin in the session registered that event.
* **Only the Agent's own tool calls count.** Your extension's own `ctx.mcp.call` doesn't produce `tool.call` / `tool.result`, so calling MCP from an observe event can't cause a loop.
* **Subagents fire them too.** `turn.start`, `turn.complete`, `tool.call`, and `tool.result` carry `agentId`. The main Agent has no such field. For a subagent, or a task it started, it's the child session id. To watch only the main Agent, check `e.agentId === undefined` first.

| Event | When it fires | matcher |
| - | - | - |
| [`session.start`](#session-start) | When the plugin activates in a session | None |
| [`session.measure`](#session-measure) | After a main Agent turn, when context usage changed | None |
| [`turn.start`](#turn-events) | A turn starts | None |
| [`turn.complete`](#turn-events) | A turn ends | None |
| [`tool.call`](#tool-events) | The Agent calls a tool | `tool`, `server` |
| [`tool.result`](#tool-events) | A tool call ends | `tool`, `server` |
| [`ui.close`](#ui-close) | The user closed one of your pane tabs | `id` |

### session.start

Fires when the plugin becomes active in a session, once per Activation. All of these create a new Activation: previewing or installing partway through a session, reloading after a change, and a Runtime restart. A reloaded version also gets its own `session.start`.

| Field | Type | Notes |
| - | - | - |
| `cwd` | `string` | The session's working directory, same as `ctx.session.cwd` |

`session.start` has no `sessionId`, `turnId`, or `agentId`, and it runs before any other event in the Activation. Use it to prepare initial data, or to open a panel that should be there from the start, with a fixed `id` and no `focus`. The same session can receive it more than once, so write initialization that is safe to run repeatedly.

```tsx theme={null}
on('session.start', async (ctx, e) => {
  // Panels don't come back after a Runtime restart, so reopen it here without taking focus
  await ctx.ui.open({ id: 'board', title: 'Board' });
});
```

### session.measure

After each main Agent turn, MCode measures context usage. It sends this event only when the result differs from the last one it sent. Subagent and task turns aren't measured.

| Field | Type | Notes |
| - | - | - |
| `sessionId` | `string` | This session's id |
| `context` | `{ window, tokens?, percent?, breakdown? }` | Same meaning as `context` in [`ctx.session.usage()`](https://agent.minimax.io/docs/extension/api#session) |
| `rateLimits` | `never[]` | Always an empty array for now |
| `changed` | `'context'[]` | What changed. A change in window, token count, or percentage counts, including a window change caused only by switching models |

The first `session.measure` after the plugin loads always lists `'context'`. Measurements don't pile up: while one is still being delivered, the results of later turns are merged into the next one. After a hook fails, the same change isn't sent again.

```tsx theme={null}
// Context usage changed, so redraw the status band; the drawing reads the latest numbers with ctx.session.usage()
on('session.measure', (ctx, e) => ctx.ui.invalidate());
```

### turn.start and turn.complete

Fire when a turn starts and ends. Both events have `sessionId` (this session's id) and `turnId`. Subagent turns also have `agentId`.

`turn.start`:

| Field | Type | Notes |
| - | - | - |
| `startedAt` | `number` | Start time, Unix ms |
| `prompt` | `{ text, attachments? }`, may be absent | `text` is the message the user sent. `attachments` lists only `{ kind, name? }` for each attachment (`kind` is something like `image` or `file`), without content or paths. The field is absent when there are no attachments |

`turn.complete`:

| Field | Type | Notes |
| - | - | - |
| `status` | `'completed'` / `'aborted'` / `'error'` | How the turn ended |
| `durationMs` | `number` | Duration in ms |
| `usage` | `{ inputTokens, outputTokens }`, may be absent | Token usage for the turn |
| `answer` | `string`, may be absent | The subagent's final reply, up to 32 KB |
| `answerTruncated` | `true`, may be absent | Present when `answer` was truncated |
| `reason` | `'answer'` / `'aborted'` / `'refusal'` / `'error'`, may be absent | Why the subagent ended |

`answer`, `answerTruncated`, and `reason` go only to **the plugin that started this subagent** (including its reloaded versions). Other plugins get the same event without these three fields. This event can arrive up to 10 seconds after the subagent ends. See [Background subagents](https://agent.minimax.io/docs/extension/api.md#agent-spawn) for usage.

`prompt` is missing only when MCode can't read it, for example when the turn has already ended by the time the event arrives. The event itself still comes.

### tool.call and tool.result

`tool.call` fires when the Agent calls a tool, and `tool.result` fires when the call ends. Both built-in tools and MCP tools fire them. Use the matcher's `tool` or `server` to receive only some tools. Both events have `sessionId` and `turnId`. Subagent calls also have `agentId`.

`tool.call`:

| Field | Type | Notes |
| - | - | - |
| `toolCallId` | `string` | The id of this call, same as in the matching `tool.result` |
| `toolName` | `string` | Tool name |
| `server` | `string`, may be absent | The server an MCP tool belongs to |
| `startedAt` | `number` | Start time, Unix ms |
| `input` | JSON, may be absent | The arguments the Agent passed to the tool, as is, not truncated |

`tool.result`:

| Field | Type | Notes |
| - | - | - |
| `toolCallId` | `string` | The id of the matching `tool.call` |
| `toolName` | `string` | Tool name |
| `status` | `'ok'` / `'error'` / `'denied'` | Succeeded, failed, or denied by permissions |
| `durationMs` | `number` | Duration in ms |
| `output` | `{ text?, result? }`, may be absent | The result returned to the Agent. `text` is all text blocks joined with newlines. `result` is present only when the result contains non-text blocks such as images. It's the full list of content blocks, including inline base64. Both can be large |

`input` and `output` are missing only when MCode can't read them, for example when the turn has already ended by the time the call ends.

### ui.close

Fires when the user closes a pane tab your plugin opened. Only the plugin that opened it receives the event. Calling `ctx.ui.close(id)` yourself doesn't fire it.

| Field | Type | Notes |
| - | - | - |
| `sessionId` | `string` | This session's id |
| `id` | `string` | The id of the closed panel |

There's no `turnId` or `agentId`. For opening and closing panels, see [Interface](https://agent.minimax.io/docs/extension/interface.md).

```tsx theme={null}
on('ui.close', { id: 'board' }, async (ctx, e) => {
  await ctx.store.set('boardClosedAt', ctx.clock.now());
});
```

## command.run

Coming soon

Fires when the user runs a slash command your plugin registered in the message box: by picking it in the `/` menu, or by typing `/<command name> arguments` and pressing Enter. For how to register a command and how it shows in the menu, see [Add slash commands](https://agent.minimax.io/docs/extension/api.md#command).

```tsx theme={null}
on('command.run', { command: 'note' }, async (ctx, e) => {
  await ctx.state.update('notes', (notes) => [...notes, e.args]);
  return { text: 'Noted' };
});
```

The matcher `{ command }` is required. Write a command name this module registered, without the `/`. It's compared without regard to case. The messages below all use this `/note` command as the example.

| Field | Type | Notes |
| - | - | - |
| `sessionId` | `string` | This session's id |
| `command` | `string` | The command name as you wrote it when registering, without the `/` |
| `args` | `string` | The text the user typed after the command name, with leading and trailing whitespace removed and the rest as is. An empty string when the user picked the command straight from the `/` menu with no arguments. At most 4096 characters. Beyond that the command doesn't run, and the user sees "The arguments of /note are too long" |

There's no `turnId` or `agentId`. Only the plugin that registered a command receives its `command.run`.

> [!WARNING]
>
> `args` is exactly what the user typed. Treat it as untrusted input before you pass it to a model (`ctx.model.complete`, `ctx.agent.spawn`) or an MCP tool (`ctx.mcp.call`).

### What to return

| Return | Result |
| - | - |
| `{ text }` | MCode shows `text` as a toast to the user who ran the command. At most 500 characters. The rest is cut off, and MCode records a `COMMAND_TEXT_TRUNCATED` |
| Nothing, or `{}` | Nothing is shown |
| Any other value, such as an object with keys other than `text`, or a `text` that isn't a string | Nothing is shown, and MCode records a `COMMAND_ANSWER_INVALID` |

`text` is only for the user. The model never sees it, and it doesn't enter the conversation. It isn't a `ctx.ui.toast` call and doesn't count toward the toast rate limit. A short sentence is enough.

### When it runs

A command is a user action, the same as a button action:

* **It runs right away.** A command doesn't wait for the current turn to end, or for this plugin's observe events. So one of this plugin's observe event hooks may be running at the same time. If the command changes something the current turn depends on, handling the consequences is up to you.
* **It shares a queue with button actions.** This plugin's commands and button actions in this session run one at a time in arrival order. See [Queue limits](#queue).
* **It times out after 15 seconds without a result.** MCode reports `COMMAND_TIMEOUT`, and the user sees "/note timed out and may have run already". A command still waiting in the queue won't run. A hook that's already running keeps going until it finishes (including any permission card it's waiting on), but its result is discarded, and it holds its place in the queue until it finishes. A timed-out command may have run already, so a command that changes things should be safe to run twice, or should check its own `ctx.state` first.

Keep command hooks and button callbacks short.

### When it fails

In the cases below, the command gives no result and the user sees a message. For the ones marked "diagnostic", `inspect` also records the same code:

| Code | When | The user sees |
| - | - | - |
| `COMMAND_UNHANDLED` (diagnostic) | No `command.run` hook handles this command, meaning `on('command.run', { command }, …)` is missing | /note didn't respond |
| `COMMAND_FAILED` (diagnostic) | The hook threw, ran past its 10-second own-time limit, or the runtime environment crashed. The hook's own diagnostic is recorded too | /note failed |
| `COMMAND_PAUSED` (diagnostic) | This hook failed repeatedly and is paused in this session | /note is unavailable: the plugin is paused |
| `COMMAND_RETIRED` (diagnostic) | The plugin is being withdrawn or reloaded | /note is unavailable: the plugin is reloading or disabled |
| `COMMAND_TIMEOUT` (diagnostic) | No result within 15 seconds | /note timed out and may have run already |
| `COMMAND_BUSY` | This plugin's action queue is full, and the hook didn't run | /note did not run: the plugin is busy, try again |

## ui.render

`on('ui.render', { site, id? }, async (ctx, e, next) => …)` is called when MCode needs to draw a site. MCode decides `e`: `{ site: 'above-prompt' }` for the status band above the message box, `{ site: 'pane', id }` for a panel, and `{ site: 'backdrop', props }` for the backdrop. Coming soon `above-prompt-list`, which arranges the status band's rows, gets `{ site: 'above-prompt-list', props: { rows } }`. See [Status band row arrangement](https://agent.minimax.io/docs/extension/interface.md#above-prompt-list). For the backdrop, `e.props` tells you which theme from which plugin is active. See [Interface: backdrop](https://agent.minimax.io/docs/extension/interface.md#backdrop). All matching plugins draw a site in layers, and every layer's drawing must keep `await next()`.

For the render chain, when redraws happen, and what a drawing can do, see [Interface: render chain](https://agent.minimax.io/docs/extension/interface.md#render-chain).

## Example: count tool calls

This extension shows, on the status band, how many times the main Agent called a tool in this session and the name of the most recent tool. When a turn ends with an error, it shows a toast.

```ts hooks/state.ts theme={null}
import { defineState } from '@minimax/mcode-plugin-extension';

export const state = defineState({
  calls: { default: 0 },
  lastTool: { default: '' },
});

// Tell the editor which keys ctx.state has and what type each value is
declare module '@minimax/mcode-plugin-extension' {
  interface ExtensionStateRegistry {
    readonly spec: typeof state.spec;
  }
}
```

```tsx hooks/register.tsx theme={null}
import type { Register } from '@minimax/mcode-plugin-extension';
import { Box, Button, Text } from '@minimax/mcode-plugin-extension/ui';

export { state } from './state';

export const register: Register = (on) => {
  // Count each tool call by the main Agent. Subagent calls carry agentId, so skip them
  on('tool.call', async (ctx, e) => {
    if (e.agentId !== undefined) return;
    await ctx.state.update('calls', (n) => n + 1);
    // The drawing reads both keys, so the status band redraws itself after these writes
    await ctx.state.set('lastTool', e.toolName);
  });

  // Show a toast when a turn ends with an error
  on('turn.complete', async (ctx, e) => {
    if (e.agentId === undefined && e.status === 'error') {
      await ctx.ui.toast('The last turn ended with an error', { tone: 'warning' });
    }
  });

  on('ui.render', { site: 'above-prompt' }, async (ctx, e, next) => {
    const last = ctx.state.get('lastTool');
    return (
      <Box direction="column" gap="1">
        <Box direction="row" gap="2" align="center">
          <Text size="sm" tone="secondary">
            {`${ctx.state.get('calls')} tool calls this session${last ? `, last: ${last}` : ''}`}
          </Text>
          <Button
            key="reset"
            label="Reset"
            icon="refresh"
            variant="plain"
            onPress={async () => {
              await ctx.state.set('calls', 0);
            }}
          />
        </Box>
        {/* What other plugins drew on the status band */}
        {await next()}
      </Box>
    );
  });
};
```

`ctx.state` belongs only to the current session. After a write, drawings that read it redraw automatically, so the hooks don't need to call `ctx.ui.invalidate()`.

## Failures and pausing

When an extension fails, only that extension is affected, never the conversation. The rules are below.

### Time limits

| Limit | When exceeded |
| - | - |
| An Invocation (one observe event, one button action, one command, one drawing) can spend at most 10 seconds of its own time | Reports `EXTENSION_HOOK_EXPIRED` and aborts the Invocation |
| A single stretch of synchronous code can run at most 2 seconds without a break | Reports `timeout` |
| One draw (the whole render chain) can take at most 30 seconds from start to finish, including time spent waiting on `ctx` requests | Reports `EXTENSION_RENDER_DEADLINE`. The whole render chain is discarded, the site falls back to the host's default view, and every plugin's content disappears at once |

"Its own time" counts only time when your code is running. Time spent waiting on `ctx` requests (waiting for an MCP server, for the user to handle a permission card, or for a model reply) doesn't count.

An error thrown by a hook reports `thrown`, and the message includes the error.

### Paused after repeated failures

If the same hook fails or times out **3 times in a row** in the same session, it's paused in that session and MCode reports `EXTENSION_DISABLED`. One success in between resets the count.

* Pausing affects only the current session. The same extension keeps running in other sessions.
* A paused layer is skipped on the status band or panel, and other plugins still show. Only when every layer at a location is paused does MCode show "Paused · this session" and "Failed or timed out 3 times in a row; paused in this session", with a "Retry" button.
* Clicking "Retry" clears this plugin's paused state in this session. A reloaded version with fixed code also starts counting from zero.
* A drawing cut off by its deadline while waiting on a `ctx` request doesn't count toward pausing. Only a drawing still running its own code when the deadline hits counts.

### Runtime crashes

Extension code runs in a separate runtime environment that MCode sets up for it. An infinite loop or ever-growing memory crashes and restarts that environment, MCode reports `EXTENSION_WORKER_CRASHED`, and every Invocation in progress fails. If MCode can tell which version of which extension caused it, it pauses that version and shows "The plugin hung, crashed or failed to load; paused in this session", again with "Retry". A load failure shows the same thing.

### Queue limits

In each session, each plugin has two standing queues, and each runs its hooks one at a time in arrival order: one for user actions, shared by button actions and slash commands, and one for observe events. While an earlier hook is still running, later ones in the same queue wait behind it. The most common case is a permission card raised by `ctx.mcp.call` that the user hasn't handled yet, so the hook keeps waiting.

| What queues | Limit (including the one running) | When exceeded |
| - | - | - |
| Button actions and commands | 10 combined | The newest is rejected. For a button action, MCode reports `GESTURE_QUEUE_FULL`, and the user sees "Too many actions. Try again later". For a command, MCode reports `COMMAND_BUSY`, and the user sees "/note did not run: the plugin is busy, try again" |
| Observe events | 32 | The newest is dropped, and `inspect.runtime.diagnostics` records a `GESTURE_QUEUE_FULL` |

Time a command spends waiting in the queue counts toward its 15-second timeout. A timeout reports `COMMAND_TIMEOUT`. See [command.run](#command-run).

For what each diagnostic code means and how to fix it, see [Diagnostic codes](https://agent.minimax.io/docs/extension/errors.md).

## Next steps

> [card] [Extension API](https://agent.minimax.io/docs/extension/api.md)
>
> Save state, call MCP, fill the message box, call models, and add slash commands from hooks.

> [card] [Interface: sites and elements](https://agent.minimax.io/docs/extension/interface.md)
>
> The status band, panels, the render chain, and elements.

> [card] [Test and troubleshoot](https://agent.minimax.io/docs/extension/testing.md)
>
> Write tests and use inspect to view diagnostics.

> [card] [Diagnostic codes](https://agent.minimax.io/docs/extension/errors.md)
>
> What each diagnostic code means and how to fix it.
