Test it before you publish

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 with draft changes and its id in AGENT_ID.

To run tests from the platform, see Evals.

  1. 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)

    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." },
      },
    });

    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.

  2. Put it in a suite

    A suite groups the scenarios you want to run together. (Create a suite)

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

    The response has the suiteId. Keep it in SUITE_ID.

  3. 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)

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

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

  4. 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, Get a run)

    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);

    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 to understand a failure.

Check it worked

Compare the outcome of both versions and review the attempts. If you're satisfied with the draft's results, publish it. 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.

Next steps