Versioning and rollback

Edits to a Saaya agent are not in-place. Every change, prompt, voice, tool, KB, model, mints a new version. Versions stay drafts until you publish them, can run side-by-side via A/B routing, and can be reverted with a single API call.

Drafts vs published

When you call `agents.update` you create a draft. Drafts are testable in the dashboard playground and via the SDK with `versionId` overrides, but no live traffic touches them. Calling `agents.publish` flips a draft to "published" and routes new sessions to it.

publish.ts
// 1. Edit the prompt, this creates a draft version.
const draft = await saaya.agents.update(agent.id, {
  prompt: "…the revised prompt…",
});

// 2. Smoke-test the draft (test calls, scripted sessions).
await saaya.sessions.testCall({
  agentId:   agent.id,
  versionId: draft.versionId,
  toNumber:  "+919876543210",
});

// 3. Promote when you're happy.
await saaya.agents.publish(agent.id, { versionId: draft.versionId });

A/B routing

Two published versions can run simultaneously. Set a routing rule, usually a percentage split, and Saaya will steer sessions accordingly. Both legs are tagged on the session so analytics can compare conversion, sentiment, and cost.

ab.ts
await saaya.agents.routing(agent.id, {
  rules: [
    { versionId: "v_2025_04_27_a", weight: 0.8 },
    { versionId: "v_2025_04_27_b", weight: 0.2 },
  ],
});

Rollback

If a release misbehaves, roll it back. `agents.rollback` flips routing to the previous published version instantly, no redeploy, no DNS, no cache flush. The bad version stays in history so you can diff it later.

Roll back in production

Rollback is safe to call from a webhook handler. Wire it to your alerting platform: when error-rate or sentiment crosses a threshold, the platform itself can revert the agent.
Was this page helpful?