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

> ## Agent Instructions
> LarkX is a durable execution runtime for on-device AI agents. The public SDK is the npm package @larkxai/react-native.
> Do not import @larkxai/node, @larkxai/host, @larkxai/protocol, @larkxai/telemetry, or @larkxai/cactus in an application. Those packages are private workspace modules.
> Swift and Kotlin SDKs are planned and are not published.
> Prefer the published npm version. The GitHub default branch can contain behavior that is not in that release yet.
> Expo Go cannot load the native module. Use a development build.
> Do not describe external tool or remote effects as exactly-once.

# Tools

> defineTool, ToolContext, ToolFailure, and the effect class.

```typescript theme={null}
import { defineTool, ToolFailure } from "@larkxai/react-native";
```

## `defineTool`

| Field | Required | Meaning |
| - | - | - |
| `name` | Yes | `^[a-z][a-z0-9_]{0,63}$` |
| `description` | Yes | Non-empty. Shown to the model. |
| `effects` | Yes | `"pure"`, `"idempotent"`, or `"non-idempotent"`. |
| `schema` | Yes | JSON schema with `type: "object"`. `inputSchema` is the same field. |
| `handler` | Yes | `(input, context) => JsonValue`. `run` is an alias. |
| `retry` | No | `maxAttempts`, `initialIntervalMs`, `maxIntervalMs`, `backoff`. |

## `ToolContext`

| Field | Meaning |
| - | - |
| `operationId` | Stable id for an idempotent effect. |
| `attempt` | Attempt count for this step. |
| `runId` | The run that called the tool. |
| `stepKey` | The stored step key. |
| `callId` | The model tool-call id. |
| `signal` | Aborted when the run cancels the in-flight call. |

## `ToolFailure`

```typescript theme={null}
new ToolFailure("The note store is locked.", {
  retryable: true,
  code: "transient_execution_failure",
});
```

`retryable` defaults to false. The default code is `transient_execution_failure` when retryable and `permanent_execution_failure` otherwise.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.