---
docId: doc_b354e31f0da74a00b90c846d7f99faba
title: Test it before you publish
description: "Compare your agent's draft and published version with test scenarios."
---

<script>
  import { Steps, Ways } from '$lib/components';
</script>

# Test it before you publish

<span id="what-youll-build"></span>

Test how your agent replies before publishing changes. Evals simulate conversations and compare the draft with the published version. Write a scenario and group it in a suite to run it.

## Before you start

You need an [agent](/guides/create-an-agent) with draft changes and its id in `AGENT_ID`.

To run tests from the platform, see [Evals](/help/agents/evals).

<Steps>
<Steps.Step>

**Write a scenario**

Describe what the contact needs and what you expect the agent to do. Platica simulates that conversation several times. ([Create a scenario](/api-reference/evals/scenarios/create))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/evals/scenarios \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scenario": {
      "scenarioId": "price_no_invention",
      "title": "Asks about prices",
      "type": "persona",
      "user": { "goal": "Find out how much it costs and whether there are extra fees." },
      "expect": { "outcome": "Gives only the prices in its information and never makes up figures." }
    }
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });
const agentId = process.env.AGENT_ID!;

await platic.evals.scenarios.create({
  scenario: {
    scenarioId: "price_no_invention",
    title: "Asks about prices",
    type: "persona",
    user: { goal: "Find out how much it costs and whether there are extra fees." },
    expect: { outcome: "Gives only the prices in its information and never makes up figures." },
  },
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Write a scenario: a customer wants to know how much it costs and whether there are extra fees. The agent must give only the prices in its information, without making up figures.

</Ways.Say>

Tool: [`create_eval_scenario`](/mcp/tools#create_eval_scenario).

</Ways.Way>
</Ways>

`expect.outcome` is what must happen, in your own words. You can also require exact things, such as calling a tool: see the [scenario format](/api-reference/evals/scenarios/format).

</Steps.Step>
<Steps.Step>

**Put it in a suite**

A suite groups the scenarios you want to run together. ([Create a suite](/api-reference/evals/suites/create))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/evals/suites \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sales evals",
    "agentId": "'$AGENT_ID'",
    "members": [{ "scenarioId": "price_no_invention" }]
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const suite = await platic.evals.suites.create({
  name: "Sales evals",
  agentId,
  members: [{ scenarioId: "price_no_invention" }],
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Create a suite called Sales evals and add the prices scenario to it.

</Ways.Say>

Tool: [`create_eval_suite`](/mcp/tools#create_eval_suite).

</Ways.Way>
</Ways>

The response has the `suiteId`. Keep it in `SUITE_ID`.

</Steps.Step>
<Steps.Step>

**Estimate the cost**

Check the estimated cost before running the suite. The estimate runs no conversations and incurs no charges.

A run uses the agent's real tools. If a tool changes another system, the test may do so too. Each agent turn is billed as an internal message. ([Estimate a run](/api-reference/evals/runs/estimate))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/evals/runs/estimate \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "suiteId": "'$SUITE_ID'", "versions": ["draft", "published"] }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const estimate = await platic.agents.evals.runs.estimate(agentId, {
  suiteId: suite.suiteId,
  versions: ["draft", "published"],
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

How much would it cost to run the Sales suite against the draft and against what is published?

</Ways.Say>

Tool: [`estimate_agent_eval_run`](/mcp/tools#estimate_agent_eval_run).

</Ways.Way>
</Ways>

`draft` is your draft and `published` is what answers today. `estimatedMaxMessages` is the most that would be charged.

</Steps.Step>
<Steps.Step>

**Run it and read the result**

The evals run in the background. There is one run per version and each ends with its `outcome`. ([Start a run](/api-reference/evals/runs/start), [Get a run](/api-reference/evals/runs/get))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/evals/runs \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "suiteId": "'$SUITE_ID'", "versions": ["draft", "published"] }'

curl https://api.platic.ai/v1/agents/$AGENT_ID/evals/runs/$LAUNCH_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

The first call returns the `launchId` (keep it in `LAUNCH_ID`). Repeat the second every few seconds until `status` is `completed`.

</Ways.Way>
<Ways.Way name="sdk">

```ts
const launch = await platic.agents.evals.runs.start(agentId, {
  suiteId: suite.suiteId,
  versions: ["draft", "published"],
});
const result = await platic.agents.evals.runs.wait(agentId, launch.launchId);

for (const run of result.runs) console.log(run.requested, run.outcome);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Run the Sales suite against the draft and against what is published, and tell me which one passed.

</Ways.Say>

Tool: [`start_agent_eval_run`](/mcp/tools#start_agent_eval_run) and [`get_agent_eval_run`](/mcp/tools#get_agent_eval_run).

</Ways.Way>
</Ways>

`passed` means every attempt passed; `failed` means at least one failed. If the draft passes and the published version fails, the draft performed better in this scenario. Read the conversation with [Get an attempt](/api-reference/evals/runs/get-attempt) to understand a failure.

</Steps.Step>
</Steps>

## Check it worked

Compare the `outcome` of both versions and review the attempts. If you're satisfied with the draft's results, [publish it](/api-reference/agents/publications/publish). If a test fails, adjust the agent and run it again.

Evals don't block publication; you decide when to publish.

Once the suite is reliable, make it run by itself on every publication with [Choose the suites on publish](/api-reference/evals/on-publish/set).

## Next steps

- [Talk to your agent](/guides/chat-api) from your application, without connecting a channel.
- [Put it on a channel](/guides/connect-a-channel) so it answers your customers.
- [Versions and how to go back](/guides/versions), in case what is published doesn't work.
- [Evals](/api-reference/evals): when an attempt passes, default values and limits.
