# Evaluations and attack simulator

Source: https://docs.autessa.com/docs/features/evaluations

> Grade AI agent transcripts for task success, groundedness, and efficiency, and attack your agent with a simulated attacker to get a block-rate scorecard.

# Evaluations and attack simulator

Evaluations grade what your agent did in a conversation. The attack simulator tries to trick your agent, then scores how much got through.

## When to use it

- You changed a prompt or model and want to know if the agent still does its job.
- You want a pass or fail check on every pull request. See [GitHub Actions](/docs/integrations/github-actions.md).
- You want proof that your agent resists prompt injection and social engineering before release.

## Quickstart

1. [Get a free API key](https://builder.autessa.com/get-api-key). New accounts get $100 of free credits for your first month, no card needed. This developer key works for this feature; see [Keys](/docs/start/keys.md).
2. Send a transcript and the agent's instructions to `POST /clients/evaluations/grade`.
3. Read `passed` and the scores.

**curl:**

```bash
curl -X POST https://api.autessa.com/clients/evaluations/grade \
  -H "Authorization: $AUTESSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentInstructions": "You help customers check order status. Look up the order before answering.",
    "expectedOutcome": "The agent looks up order 1042 and gives its delivery date.",
    "turns": [
      {"role": "USER", "content": "Where is order 1042?"},
      {"role": "TOOL_CALL", "toolName": "get_order", "arguments": {"orderId": "1042"}},
      {"role": "TOOL_RESULT", "toolName": "get_order", "result": "{\"status\":\"shipped\",\"eta\":\"2026-11-07\"}"},
      {"role": "ASSISTANT", "content": "Order 1042 has shipped and should arrive November 7."}
    ]
  }'
```

**Python:**

```python
import os
import requests

res = requests.post(
    "https://api.autessa.com/clients/evaluations/grade",
    headers={"Authorization": os.environ["AUTESSA_API_KEY"]},
    json={
        "agentInstructions": "You help customers check order status.",
        "expectedOutcome": "The agent gives the delivery date for order 1042.",
        "turns": [
            {"role": "USER", "content": "Where is order 1042?"},
            {"role": "ASSISTANT", "content": "Order 1042 should arrive November 7."},
        ],
    },
    timeout=120,
)
grade = res.json()
print(grade["passed"], grade["evaluation"]["status"])
```

**TypeScript:**

```typescript
const res = await fetch("https://api.autessa.com/clients/evaluations/grade", {
  method: "POST",
  headers: { Authorization: process.env.AUTESSA_API_KEY!, "Content-Type": "application/json" },
  body: JSON.stringify({
    agentInstructions: "You help customers check order status.",
    expectedOutcome: "The agent gives the delivery date for order 1042.",
    turns: [
      { role: "USER", content: "Where is order 1042?" },
      { role: "ASSISTANT", content: "Order 1042 should arrive November 7." },
    ],
  }),
});
const grade = await res.json();
console.log(grade.passed, grade.evaluation.status);
```

**Java:**

```java
var body = """
    {"agentInstructions": "You help customers check order status.",
     "expectedOutcome": "The agent gives the delivery date for order 1042.",
     "turns": [{"role": "USER", "content": "Where is order 1042?"},
               {"role": "ASSISTANT", "content": "Order 1042 should arrive November 7."}]}
    """;
var req = java.net.http.HttpRequest.newBuilder(java.net.URI.create("https://api.autessa.com/clients/evaluations/grade"))
    .header("Authorization", System.getenv("AUTESSA_API_KEY"))
    .header("Content-Type", "application/json")
    .POST(java.net.http.HttpRequest.BodyPublishers.ofString(body))
    .build();
System.out.println(java.net.http.HttpClient.newHttpClient()
    .send(req, java.net.http.HttpResponse.BodyHandlers.ofString()).body());
```

## How grading works

The grader reads the instructions and the whole transcript, including tool calls and results. It returns:

| Field | What it tells you |
| --- | --- |
| `evaluation.status` | `SUCCESSFUL`, `SUCCESSFUL_NOT_EFFICIENT`, `SUCCESSFUL_NOT_ALL_STEPS`, or `UNSUCCESSFUL`, with notes. |
| `evaluation.groundednessScore` | Whether the answers are backed by what tools returned. |
| `evaluation.faithfulnessArgScore` | Whether each tool argument could be derived from the conversation. |
| `evaluation.efficiencyScore` | Whether the agent took a reasonable number of steps. |
| `evaluation.taskCompletenessScore` | Whether the agent finished every part of the task. |
| `expectedOutcomeVerdict.rating` | `MET`, `PARTIALLY_MET`, or `NOT_MET`, with a `justification`, when you send `expectedOutcome`. |
| `passed` | One boolean you can gate on. With `expectedOutcome`, it is true when the rating is `MET`. Without it, true when the status is `SUCCESSFUL` or `SUCCESSFUL_NOT_EFFICIENT`. |

Each turn has a `role` of `USER`, `ASSISTANT`, `TOOL_CALL`, or `TOOL_RESULT`. `USER` and `ASSISTANT` turns need `content`. `TOOL_CALL` turns take `toolName` and `arguments`, and `TOOL_RESULT` turns take `toolName` and `result`.

For many transcripts, use `POST /clients/evaluations/jobs` (Preview) and get a webhook when the job finishes.

## Attack simulator

The simulator runs packs of attacks and scores the result.

```bash
curl -X POST https://api.autessa.com/clients/aaf/simulations \
  -H "Authorization: $AUTESSA_API_KEY" -H "Content-Type: application/json" \
  -d '{"categories": ["PROMPT_INJECTION", "SOCIAL_ENGINEERING", "DISCLOSURE_PROBING"]}'
```

You get a `simulationId`. Poll `GET /clients/aaf/simulations/{simulationId}` until `status` is `COMPLETED` or `FAILED` (`errorMessage` says why). The `scorecard` has one row per category with `attempts`, `blocked`, `flagged`, and `passed` (attacks that got through, so lower is better). A row with `available: false` could not run.

**Categories:** `PROMPT_INJECTION`, `SOCIAL_ENGINEERING`, `PASSPHRASE_GUESSING`, `WORD_OF_DAY_REPLAY`, `ANOMALY`, `DISCLOSURE_PROBING`, `CLONED_VOICE`. Leave out `categories` to run them all.

**Targets:** an Autessa agent (`agentId`, with tools dry-run), a named firewall policy (`policyName`), or your company's default policy.

### Attack your own agent

Point the simulator at any agent with an HTTPS endpoint. It sends each attack to your endpoint and judges the reply with the same scorers.

```json
{
  "categories": ["PROMPT_INJECTION"],
  "target": {
    "url": "https://agent.example.com/chat",
    "method": "POST",
    "headers": { "X-Api-Key": "my-agent-key-secret" },
    "requestTemplate": { "message": "{{message}}", "session": "{{sessionId}}" },
    "responsePath": "$.reply",
    "multiTurn": true
  }
}
```

`headers` maps a header name to the name of an Autessa [Secret](/docs/guide/agentic/secrets.md) that holds its value, so the key never sits in the request. In `requestTemplate`, `"{{message}}"` and `"{{sessionId}}"` are filled in for each attack. `responsePath` is a JSONPath to the reply text in your response.

### Languages and multi-turn attacks

Add `"languages": ["en", "es"]` to run attacks in English and Spanish, and `"multiTurn": true` to run each attack as a multi-turn conversation.

## Libraries

| Language | Package | Grade | Attack-test |
| --- | --- | --- | --- |
| Python | `autessa-evals` | `Evals().grade(agent_instructions=..., turns=[...], expected_outcome=...)` | `simulate(agent_id=... or target=..., categories=[...])` waits for the scorecard; `start_simulation(...)`, `wait_for_simulation(id)` |
| TypeScript | `@autessa/evals` | `new Evals().grade({ agentInstructions, turns, expectedOutcome })` | `simulate({ target, categories })` waits for the scorecard; `waitForSimulation(id)`, `summarizeScorecard(sim)` |
| Java | `com.autessa:autessa-evals` | `Evals.fromEnv().grade(instructions, turns, expectedOutcome)` | `simulateAndWait(target, categories)` returns a `Scorecard`; `simulate(...)` returns the id, then `waitForSimulation(id)` |

For your own endpoint, build the target with `external_target(...)` in Python or `SimulationTarget.external(...)` in Java. In TypeScript, pass `target: { url, requestTemplate, responsePath }`.

```python
from autessa.evals import Evals, turn

evals = Evals()
result = evals.grade(
    agent_instructions="You help customers check order status.",
    turns=[turn("USER", "Where is order 1042?"), turn("ASSISTANT", "Order 1042 should arrive November 7.")],
    expected_outcome="The agent gives the delivery date for order 1042.",
)
print(result.passed, result.expected_outcome_verdict.rating)
```

The libraries are in private preview and not yet on PyPI, npm, or Maven Central. Install from GitHub as each library's README describes. The HTTP API works today.

## Limits

- Grading reads the whole transcript in one call. Send long batches as a job.
- A company with no firewall policy can still run the simulator. Attacks are flagged, not blocked, so the block rate stays at 0 until you run against a policy in `ENFORCE` mode. In CI, set `policy-name`.
- A simulation run costs a flat 25 firewall points by default; the inspections inside it are not billed separately. See [firewall billing](/docs/api/ai-application-firewall.md#billing).

## API reference

- [Evaluations API](/docs/reference/evaluations.md)
- [Attack simulator endpoints](/docs/reference/firewall.md)

## Benchmarks

[AI Firewall Bench](/docs/benchmarks/ai-firewall-bench.md) is the open benchmark behind the attack categories.

## Example

[Eval before release (CI)](https://github.com/Autessa-Inc/autessa-examples/tree/main/examples/ci-eval-before-release): attack-test an agent on every pull request and fail the check when too much gets through.

## Related

- [GitHub Actions: eval on every pull request](/docs/integrations/github-actions.md)
- [AI Application Firewall](/docs/features/ai-application-firewall.md)
- [Synthetic data](/docs/features/synthetic-data.md) for test conversations
- [Start here](/docs/start.md)

