Mock
A deterministic engine for testing. Replaces the inference step with a predictable local responder — the full agent loop still runs. Tool calls execute, threads accumulate context, stop conditions fire. Everything behaves as in production, just without a model call.
Configuration
import { Mock } from "@axon/engines"
export default defineAgent({
engine: Mock(),
})
With no argument, Mock() echoes the user's last message back as agent output.
Response patterns
Define fixed responses by pattern:
import { Mock, air } from "@axon/engines"
export default defineAgent({
engine: Mock({
"hello": air.text("Hi there!"),
"run code": air.typescript("math.add(1, 2)"),
}),
})
Patterns are matched against the user message. On no match, falls back to echo.
For full control, pass a function:
import { Mock, air } from "@axon/engines"
export default defineAgent({
engine: Mock(async (req) => {
const last = req.messages.at(-1)?.content ?? ""
return air.text(`You said: ${last}`)
}),
})
AIR helpers
Responses must be valid AIR blocks — not plain strings.
| Helper | Output |
|---|---|
air.text(content) | Renders as agent message |
air.typescript(code) | Executes in the capsule |
air.done | Terminates the loop with no output |
Streaming behaviour
Mock streams responses by chunking words with ~5ms delays, matching the feel of a real streaming engine. Tests can iterate the stream normally.