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.
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)
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." } } }'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." }, }, });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.
Tool:
create_eval_scenario.expect.outcomeis what must happen, in your own words. You can also require exact things, such as calling a tool: see the scenario format.Put it in a suite
A suite groups the scenarios you want to run together. (Create a suite)
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" }] }'const suite = await platic.evals.suites.create({ name: "Sales evals", agentId, members: [{ scenarioId: "price_no_invention" }], });Create a suite called Sales evals and add the prices scenario to it.
Tool:
create_eval_suite.The response has the
suiteId. Keep it inSUITE_ID.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)
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"] }'const estimate = await platic.agents.evals.runs.estimate(agentId, { suiteId: suite.suiteId, versions: ["draft", "published"], });How much would it cost to run the Sales suite against the draft and against what is published?
Tool:
estimate_agent_eval_run.draftis your draft andpublishedis what answers today.estimatedMaxMessagesis the most that would be charged.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)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 inLAUNCH_ID). Repeat the second every few seconds untilstatusiscompleted.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);Run the Sales suite against the draft and against what is published, and tell me which one passed.
Tool:
start_agent_eval_runandget_agent_eval_run.passedmeans every attempt passed;failedmeans 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
- Talk to your agent from your application, without connecting a channel.
- Put it on a channel so it answers your customers.
- Versions and how to go back, in case what is published doesn't work.
- Evals: when an attempt passes, default values and limits.