> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RPC

> rpc and rpcSurface — opting methods onto the remote surface, and introspecting what an agent exposes.

The remote surface is opt-in: only methods decorated with `@rpc()` are
callable by connected clients, and `rpcSurface()` reports what a class
exposes. Both are standalone functions imported from `@telnyx/edge-runtime`,
not `Agent` members.

These functions are the server half of the remote-call story. `@rpc()` marks what may
be called; [AgentSocketServer](/docs/agent-sdk/api-reference/agent-socket-server)
enforces the opt-in on the wire (an undecorated method answers `method_private`); and
on the far end, [AgentClient](/docs/agent-sdk/api-reference/agent-client)'s `stub` is
how callers reach what you exposed — `agent.stub.humanReply("…")` dispatches to the
`@rpc()`-decorated `humanReply` on your class.

## rpc()

> **rpc**(`options?`): \{(`value`, `context`): `void`; \<`V`>(`value`, `context`): (`initial`) => `V`; }

Mark a method (or a function-valued class field) as remote-callable.

Only decorated members dispatch over the agent socket; reserved lifecycle
hooks (`constructor`/`alarm`/`fetch`/`webSocket`) and `_`-prefixed names
remain non-dispatchable even if decorated, and an undecorated override of a
decorated base method is not dispatchable.

The optional metadata is introspectable via [rpcSurface](/docs/agent-sdk/api-reference/agent/rpc#rpcsurface), so a caller
can discover what an agent exposes remotely.

**Parameters**

| Parameter | Type                                                               |
| --------- | ------------------------------------------------------------------ |
| `options` | [`RpcOptions`](/docs/agent-sdk/api-reference/agent/rpc#rpcoptions) |

**Returns**

\{(`value`, `context`): `void`; \<`V`>(`value`, `context`): (`initial`) => `V`; }

**Example**

```ts theme={null}
class Support extends Agent {
  @rpc({ description: "Human takes over the thread" })
  async humanReply(text: string): Promise<void> {
    await this.messages.add("assistant", text);
  }

  async recalc(): Promise<void> {} // in-process only, not remote-callable
}
```

## rpcSurface()

> **rpcSurface**(`instance`): `ReadonlyMap`\<`string`, [`RpcOptions`](/docs/agent-sdk/api-reference/agent/rpc#rpcoptions)>

The effective remote surface of a constructed agent instance: method name →
the `RpcOptions` it was decorated with, for exactly the names a remote
`call` frame could dispatch. Names the dispatcher would reject are excluded
even if decorated: reserved hooks, `_`-prefixed names, and names whose
resolved callable is not the decorated function (e.g. an undecorated
subclass override).

Returns a fresh snapshot on every call — mutating it has no effect on
dispatch.

**Parameters**

| Parameter  | Type     |
| ---------- | -------- |
| `instance` | `object` |

**Returns**

`ReadonlyMap`\<`string`, [`RpcOptions`](/docs/agent-sdk/api-reference/agent/rpc#rpcoptions)>

## RpcOptions

Metadata attached to a remote-callable method via `@rpc()`.

**Properties**

**description?**

> `readonly` `optional` **description?**: `string`

Human-readable summary of what the method does.
