Versions and how to go back
Check which agent version is published and compare it with the draft before publishing changes. To recover earlier settings, restore them into the draft or return to a previous publication with rollback.
Each saved change to versioned configuration creates a fixed version. Versions aren't changed or deleted from the history.
An agent tracks two versions:
- The draft is the version you edit. Every change you save creates a new version and moves the draft to it. Your customers don't see it.
- The published version is the version that answers your customers. It only changes when you publish or roll back.
| What you do | What changes |
|---|---|
| Edit the draft | The draft. The published version stays the same |
| Restore a version | The draft. The published version stays the same |
| Publish | The published version |
| Roll back | The published version. The draft stays the same |
An agent's version 1 is published when you create it. The name, photo, status, owners and file and tool connections apply immediately and aren't part of versions.
Before you start
You need an agent with its id in AGENT_ID.
To use the platform, see Drafts and versions and History and publishing.
Check the draft and published version
curl https://api.platic.ai/v1/agents/$AGENT_ID \ -H "Authorization: Bearer $PLATIC_API_KEY"import { Platic } from "platic-sdk"; const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! }); const agentId = process.env.AGENT_ID!; const agent = await platic.agents.get(agentId);Which version of Sales is published and which one is the draft on?
Tool:
get_agent.draft.versionIdis the draft andpublication.versionIdis the published version.hasUnpublishedChangesistruewhen the draft has something your customers don't see yet.See the versions and compare two
The list goes from newest to oldest, each with its number, who made it (
createdBy), where from (source) and its note. (List versions)curl https://api.platic.ai/v1/agents/$AGENT_ID/versions \ -H "Authorization: Bearer $PLATIC_API_KEY"for await (const version of platic.agents.versions.iterate(agentId)) { console.log(version.versionId, version.createdBy, version.note); }Show me the version history of Sales.
Tool:
list_agent_versions.The list doesn't include each version's configuration. To see it in full, use Get a version.
The comparison returns changed sections with their previous (
before) and new (after) content. Before publishing, compare the published version with the draft. (Compare versions)curl "https://api.platic.ai/v1/agents/$AGENT_ID/versions/v3/compare?with=v5" \ -H "Authorization: Bearer $PLATIC_API_KEY"const diff = await platic.agents.versions.compare(agentId, "v3", "v5");What changed between the published version of Sales and its draft?
Tool:
compare_agent_versions.The first version is the before and the one in
withis the after. Use theversionIdof the published version and of the draft.Validate before publishing
Validate changes against the draft without saving them. The response tells you whether they can be saved and published, and lists any problems. (Validate the draft)
curl https://api.platic.ai/v1/agents/$AGENT_ID/draft/validate \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "instructions": "You are the sales assistant for Acme. Answer in under 50 words and offer free shipping." }'const check = await platic.agents.draft.validate(agentId, { instructions: "You are the sales assistant for Acme. Answer in under 50 words and offer free shipping.", });Without saving anything, check whether Sales could be published with these instructions: answer in under 50 words and offer free shipping.
Tool:
validate_agent_draft.validsays whether it could be saved andpublishable, whether it could then be published. Each problem comes inissues, with its path and its explanation. To also know whether the agent answers better, test it.Publish a specific version
If you omit
versionId, you publish the draft. If you include it, you publish that version. (Publish)curl https://api.platic.ai/v1/agents/$AGENT_ID/publication \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "versionId": "v5", "note": "Shorter answers" }'await platic.agents.publish(agentId, { versionId: "v5", note: "Shorter answers" });Publish version 5 of Sales.
Tool:
publish_agent_version.From the next message on, the agent answers with that version. The note is optional and stays in the publication history.
Restore a version into the draft
Bring an old version back to keep editing from there. It creates a new version with its content and moves the draft to it. The published version doesn't change. (Restore the draft)
curl https://api.platic.ai/v1/agents/$AGENT_ID/draft/restore \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "versionId": "v3" }'await platic.agents.draft.restore(agentId, { versionId: "v3" });Restore version 3 into the Sales draft.
Tool:
restore_agent_version.History is not rewritten: the new version says which one it was copied from in
restoredFromVersionId. When you have reviewed it, publish it.Go back to a previous publication
Roll back to return to a version that was previously published. This changes the version the agent uses and keeps the draft unchanged. (List publications, Roll back)
curl https://api.platic.ai/v1/agents/$AGENT_ID/publications \ -H "Authorization: Bearer $PLATIC_API_KEY" curl https://api.platic.ai/v1/agents/$AGENT_ID/publication/rollback \ -H "Authorization: Bearer $PLATIC_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "versionId": "v3" }'const { data: history } = await platic.agents.publications.list(agentId); await platic.agents.rollback(agentId, { versionId: "v3" });The new version of Sales is answering badly. Go back to the one that was published before.
Tool:
list_agent_publicationsandrollback_agent_publication.In the history, each entry has the version that was published (
versionId) and the one that was before (previousVersionId). Rolling back only accepts a version that was already published; for any other, publish it instead.Use rollback to return to an earlier publication. To edit from an earlier version, restore it into the draft and publish it when it's ready.
Check it worked
Get the agent again: publication.versionId is the version you published or rolled back to, draft.versionId is where you left the draft, and hasUnpublishedChanges tells you whether they differ.
Next steps
- Test it before you publish: run your scenarios against the draft and the published version.
- Add a chat to your site: the web chat is also changed in a draft and published.
- Reference: draft, versions and publication.