---
title: Evals, 30 Fail-Closed Graders, Session Protocol, and Recipes
description: Grade agent outputs offline with @caveman-ai/evals (30 fail-closed graders), inspect Session Protocol v1 schemas in @caveman-ai/protocol, and run the 5 starter recipes.
canonical: https://docs.caveman.so/agent/evals-and-protocol
product: Caveman Agent SDK
group: Agent SDK & Harness v4
---

# Evals, 30 Fail-Closed Graders, Session Protocol, and Recipes

> Grade agent outputs offline with @caveman-ai/evals (30 fail-closed graders), inspect Session Protocol v1 schemas in @caveman-ai/protocol, and run the 5 starter recipes.

`@caveman-ai/evals` (MIT) and `@caveman-ai/protocol` (MIT) ship open-source contracts and graders that run identically offline in CI and on Caveman Cloud.

## 30 fail-closed graders (`@caveman-ai/evals`)

Install the TypeScript grader package (or `caveman-evals` for Python parity):

```bash
npm install @caveman-ai/evals
```

Every grader fails closed on missing fields, schema mismatches, or invalid targets. Categories include:

- **Deterministic text & JSON checks**: `exact_match`, `contains`, `regex`, `json_schema`, `json_path`, forbidden substring checks.
- **Agent tool-call checks**: `tool_called`, ordered tool assertions, argument validation, `cost_threshold`, latency and token bounds.
- **Metric & retrieval graders**: BLEU, ROUGE, localization F1.
- **Webhook & rubric judges**: SSRF-pinned webhook graders and bias-guarded LLM rubric judges.

## Session Protocol v1 (`@caveman-ai/protocol`)

`@caveman-ai/protocol` exports the canonical types and JSON Schemas shared across Harness v4, Caveman Code, and Caveman Cloud:

- `SessionEvent` and `UserEvent` wire envelopes
- Headless exit codes `0..6`
- `agent-build.schema.json` (deterministic `AGENT.md` -> `agent.json` manifest)
- `eval-file.schema.json` (one-file `*.eval.json` CI suites)
- `grader-registry.json` (canonical grader option schemas)

## React hooks & external framework adapters

- **`@caveman-ai/react`**: React hooks for streaming `SessionEvent` timelines and interactive Caveman Gate approval dialogs.
- **`@caveman-ai/adapter-kit`**: Interfaces for adapting external agent runtimes onto the Caveman Session Protocol.

## Five verified starter recipes

Every recipe under `examples/basics/` in `caveman-ai/agent-sdk` is a standalone 30 to 65 line TypeScript file verified offline in CI:

| # | Recipe | What it teaches |
| --- | --- | --- |
| `01` | `01-hello-agent.ts` | `defineAgent()`, `tool()`, and `runInProcess()` with zero boilerplate |
| `02` | `02-tools-and-gates.ts` | Fail-closed Caveman Gate approval policies (`approve` vs `deny`) on sensitive tools |
| `03` | `03-harness-v4-session.ts` | Direct Harness v4 (`HarnessSession`, `appLoadoutFor`, `LocalEnv`, `toHarnessTool`, `beforeCall` hooks) |
| `04` | `04-deterministic-build.ts` | Compiling an agent definition into a byte-stable `AGENT.md` + SHA-256 manifest |
| `05` | `05-evals-and-graders.ts` | Grading agent runs locally with `@caveman-ai/evals` (`contains`, `tool_called`, `cost_threshold`) |

Next: gate pull requests on Caveman Cloud with [Evals & CI Gates](/guides/evals).
