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

# ZapBot

> How the default DZap AI agent behaves in SDK, CLI, HTTP, and MCP surfaces.

ZapBot is the default runtime agent used by `DZapSDK`.

It is not a chatbot. It is a deterministic NLP pipeline wired to DeFi execution primitives.

## What the NLP Engine does

| Category | Examples                                           |
| -------- | -------------------------------------------------- |
| Read     | balances, prices, pools, docs retrieval, search    |
| Plan     | token resolution, route/calldata generation        |
| Execute  | session-gated zap execution and chain switching    |
| Track    | structured step logs and session history snapshots |

## NLP pipeline

```text theme={null}
User prompt
  → Tokenization & normalization
  → Intent classification
  → Entity extraction (tokens, amounts, chains, addresses)
  → Ambiguity resolution
  → Tool selection & orchestration
  → Structured result
```

## Supported intent types

| Intent            | Example prompt                                      |
| ----------------- | --------------------------------------------------- |
| Swap              | "Swap 100 USDC for WETH on Arbitrum"                |
| Bridge            | "Move 0.5 ETH from Base to Optimism"                |
| Balance check     | "What's my USDC balance across all chains?"         |
| Price lookup      | "What's the current price of stETH?"                |
| Route discovery   | "Find the best route to zap into the ETH/USDC pool" |
| Portfolio summary | "Show me my full portfolio breakdown"               |

## Entity extraction

The engine identifies and resolves the following entity types from natural language:

| Entity  | Examples                                                 |
| ------- | -------------------------------------------------------- |
| Token   | `USDC`, `wETH`, `stETH`, full names like "wrapped ether" |
| Amount  | `100`, `0.5`, `all`, `half`, `max`                       |
| Chain   | `Arbitrum`, `Base`, `chain ID 10`, `mainnet`             |
| Address | raw `0x...` addresses, ENS names                         |
| Action  | `swap`, `bridge`, `zap`, `check`, `move`, `send`         |

Ambiguous inputs (e.g. "ETH" could mean native or wrapped) are resolved using chain context and wallet metadata before tool dispatch.

## Ambiguity resolution

When the NLP Engine detects an ambiguous or underspecified prompt, it:

1. Infers the most likely intent from session context
2. Uses wallet metadata (connected chain, token holdings) to narrow choices
3. Asks a clarifying question if the ambiguity cannot be resolved safely

## Where it runs

* SDK (`DZapSDK.ask()`)
* CLI (`dzap`, `dzapai`, `DzapAI`)
* HTTP (`/ask_stream`)
* MCP (`/mcp`)

## Default behavior

| Setting        | Default       | Override                 |
| -------------- | ------------- | ------------------------ |
| Model          | `gpt-4o-mini` | `DZAP_OPENAI_MODEL=...`  |
| Max retries    | `2`           | `DZAP_MODEL_MAX_RETRIES` |
| Timeout        | `4500000 ms`  | `DZAP_MODEL_TIMEOUT_MS`  |
| Max tool steps | `25`          | code-level config        |

## Runtime guarantees

1. Metadata is required on each query (`metadata.accountInfo[]`).
2. Prompt text excludes private keys.
3. Interactive actions need explicit confirmation flow.
4. Tool calls are captured in structured session logs.

## Next

<CardGroup cols={2}>
  <Card title="How it works" icon="diagram-project" href="/ai/zapbot/how-it-works">
    Step-by-step request lifecycle.
  </Card>

  <Card title="Safety" icon="shield" href="/ai/zapbot/safety">
    Confirmation gates and execution boundaries.
  </Card>
</CardGroup>
