Skip to main content

Overview

This template demonstrates how to use fake() from aixyz/model to build and test an agent with zero API calls and no API key. The fake model’s transform function deterministically maps each user message to a response, making every test fast, repeatable, and CI-safe. The example agent checks whether the user’s input is a palindrome, or reverses it if not — using both the lastMessage and the full prompt history from the transform signature.

Project Structure

The Fake Model

Import fake from aixyz/model and pass a transform function:
app/agent.ts
The transform receives:
  • lastMessage — the text content of the last user turn
  • prompt — the full conversation history, useful for tracking turn count or extracting prior context

Test Pattern

Because the fake model is deterministic, every test runs without an API key:
app/agent.test.ts

Key Features

  • No API keyfake() never makes network requests
  • Fully deterministic — same input always produces the same output
  • CI-safe — all tests run in any environment
  • Full prompt context — the transform’s second argument exposes the entire conversation history

Running Tests

Running the Agent

Endpoints available at http://localhost:3000: