Example: agent-preflight
Location: examples/typescript/src/agent-preflight.ts
Run:
export MISTRAL_API_KEY=sk-...cd examples/typescriptnpm run agentEnvironment variables:
| Variable | Required | Notes |
|---|---|---|
MISTRAL_API_KEY | Yes | Mistral API key for mistral-large-latest |
CKB_RPC_URL | No | Defaults to https://testnet.ckb.dev |
What it demonstrates
Section titled “What it demonstrates”A Mistral mistral-large-latest agent (via the Vercel AI SDK) is given a proposePayment tool. The tool:
- Receives a recipient lock args and an amount from the agent’s reasoning
- Fetches the live registry
- Runs
preflightCheckagainst the recipient - Throws if the recipient is blacklisted
- Returns a payment proposal if the recipient is clean
The firewall check is inside the tool implementation — not in the agent’s system prompt, not in the agent’s reasoning, not optional. If the agent is manipulated into proposing a blacklisted recipient, the tool throws before any payment proposal is produced.
This models the correct way to gate an agent’s financial actions: enforce the constraint in the tool, where it cannot be bypassed by prompt injection or adversarial instructions.