Agentry is an end-to-end testing framework for testing AI agent infrastructure, with a design philosophy analogous to Playwright's testing of browsers: Playwright drives a real browser and asserts on the DOM, while Agentry drives a real AI agent CLI and asserts on what the agent "did"—which tools it called, which files it created, and how many tokens it consumed.
Purpose
Agentry primarily targets testing of the ecosystem around AI agents, including skills, MCP gateways, plugins, and more. These components tend to break when model behavior changes but the prompts do not, and Agentry is designed to help developers catch such issues.
Key Capabilities
- Drives real agent CLIs: Supports four drivers—Claude Code, Codex, Gemini, and Antigravity—all running in headless mode, receiving prompts and a sandbox workspace.
- Standardized event stream: Uniformly converts the output of different drivers into an AgentEvent stream, including assistant turns, tool calls, MCP requests, filesystem side effects, token usage, and more.
- Structured assertions: Provides
toHaveToolCall、toHaveFile、toFinishWithinand other matchers to make precise assertions about agent behavior, avoiding fragile string matching against free-text output. - Deterministic replay: By recording transcripts, replay in CI is fast (<2 seconds), free, and requires no agent. Record once, replay forever.
- Sandbox isolation: Each scenario runs in a fresh temporary directory, with file side effects detected via content-hash snapshots.
- Budget control: Supports setting a dollar budget cap per test, enforced after the run in the MVP, while also passing
--max-budget-usdto the Claude CLI as a native fallback. - LLM interception proxy: Provides
LlmProxy(viaANTHROPIC_BASE_URL), supporting byte-level wire recording, budget proxy gating, secret redaction, and more. - Mock MCP server: Provides a JSON-RPC core and a stdio shim, as well as
toExposeTools、toHaveReceivedand other MCP matchers. - CLI tool: Provides
agentry test、record、init、doctorand other commands, supports model pinning and budget cap configuration, and the console reporter can display costs.
Usage
There is currently no published npm package; it must be run directly from the monorepo. Prerequisites: Node >= 20, pnpm >= 10, and the CLI for the driver you use on PATH (claude requires ANTHROPIC_API_KEY、codex、gemini or agy, each authenticated per the vendor's requirements). Replay-only runs do not require these. All TypeScript is executed directly via tsx, so no build step is needed for development.
Basic workflow:
- In
agentry.config.ts, configureuse.agentto select a driver (defaultclaude),use.modelrequires a snapshot ID pinned for that agent. - Write a TypeScript test file (e.g.,
tests/todo.agentry.ts); tests receive named fixtures via destructured parameters. - Run
agentry testto replay (using committed transcripts, no API key needed), or runagentry recordto record (requires a real CLI and API key). Recorded transcripts are written to the__agentry__/<test-file-name>/directory next to the test file and should be committed to the repository for hermetic replay in CI. - You can use
agentry initScaffold a new project.
When running the agent, the following optional parameters are supported:allowedTools、disallowedTools、permissionMode、mcpConfig、appendSystemPrompt. All matchers support .not, which can apply to expect(agent)(RunView) or expect(workspace)(Sandbox).
Use cases
- Test the end-to-end behavior of AI agent CLIs.
- Verify the integration of MCP servers, skills, and plugins.
- Implement fast, deterministic regression testing of agent behavior in CI.
- Monitor the impact of model behavior changes on the agent ecosystem.
Limitations
- Currently an early MVP; features are not yet complete, and some capabilities on the roadmap (such as wire-level cassette replay) are not yet implemented.
- Not yet published as an npm package; must be run from the monorepo.
- Replay is currently transcript replay (replaying a normalized event stream), not wire-level replay.
- Antigravity-driven sandbox filesystem diff detection is best-effort, since it uses its own temporary directory.
- Budget caps are enforced after the run in the MVP.
The project is licensed under the Apache License 2.0, copyright Francis Eytan Dortort.