Skip to content
中文

Manage agent versions

Every real change to an agent’s configuration is saved as a new immutable version. Saving and applying are two separate actions: save a draft to try it, apply it once you are sure so that new sessions use it, and go back to an older version in one step if something goes wrong.

You need Bun or Node.js with native fetch and an API Key for your organization. Set PRAXIS_API_KEY in the server process.

What a version holds

A version holds the whole configuration: system, model, tools, mcp_servers, skills, multiagent, bindings, and for service agents environment_id, vault_ids, avatar and subagent_model. Changing a resource binding, attaching a skill, switching the default environment, the vault list or the avatar is therefore saving a new version, exactly like changing the instructions, and it can be held back from taking effect.

FieldMeaning
versionThe version of the returned configuration; updates and reads without a version return the currently active version
latest_versionThe newest saved version number, which may be an unapplied draft; grows by 1 for each real configuration change
active_versionThe version new sessions and newly issued grant codes use when none is specified
noteThe change note written with version_note (up to 280 characters) when the version was saved. Immutable; null if none was sent
created_byWho saved the version: { "type": "user" or "api_key", "id": "…" }. Filled in by the server, never sent in a request

Save, trial, apply

POST /agent/v1/agents/{agent_id} updates:

  • Send the newest saved version number as version for optimistic concurrency: use latest_version from the read response when present, otherwise version. A stale version returns 409; read again before retrying.
  • An update that changes nothing creates no version. Omitted fields keep their value.
  • apply defaults to true: the new version becomes active_version immediately. With apply: false it is saved only and active_version does not move.
  • version_note is written only when the call actually creates a version; sending it alone with unchanged configuration saves nothing.

POST /agent/v1/agents/{agent_id}/versions/{version}/apply makes a saved version take effect. It only moves active_version: no new version, repeated calls give the same result, and existing sessions and tokens are untouched.

Rollback is apply on an older version. The version you roll back from stays in the history and can be applied again. GET /agent/v1/agents/{agent_id}/versions lists every version as a full definition, so you can compare them.

To read one version: GET /agent/v1/agents/{agent_id} without a version returns the currently active configuration, with latest_version identifying the newest saved version. Add ?version=N for a specific version, or ?version=active for the active version. Update responses also return the active configuration, so after apply: false, their version and note still belong to the old active version. Inspect the draft configuration and note through the version list or an explicit version read.

Which version a session pins

agent on session creation has two forms:

FormPinned version
"agent_…", or { "type": "agent", "id": "…" } without versionThe active_version at the moment of creation, not necessarily the newest saved one
{ "type": "agent", "id": "…", "version": 3 }That version

After pinning, instructions, model, tools, attached skills, default environment and vaults all follow that version. Saving or applying a newer version later does not change the session. A customer sign-in works the same way and pins a version when its grant code is issued. agent.version in the session response is the pinned version number.

The exception for bindings: a newer version can narrow running sessions

Resource bindings (bindings) decide what a service agent’s codemode can reach. A session is authorized by the version it pinned, but a version applied later can narrow that authorization:

  • Newly added bindings apply to new sessions only; running sessions do not get them.
  • Applying a version that removes, disables or downgrades a binding (read-write to read-only) revokes that access immediately in sessions still running an older version.
  • A draft saved with apply: false is neither pinned nor active, so it changes no access. A session pinned to such a draft runs on the draft’s own bindings.

This applies to bindings only. Instructions, model, tools and skills of a running session do not change when a later version is applied.

End-to-end example

The script creates an agent, saves a draft that is not applied, and shows that a new session still uses version 1. After applying the draft a new session uses version 2, and then the script rolls back to version 1. Save it as versions-demo.mjs and run node versions-demo.mjs.

import assert from "node:assert/strict";
const { PRAXIS_API_KEY } = process.env;
assert(PRAXIS_API_KEY, "Set PRAXIS_API_KEY in the server process");
const base = "https://api.deepraxis.com/agent/v1";
async function request(path, body) {
const response = await fetch(`${base}${path}`, {
method: body === undefined ? "GET" : "POST",
headers: { Authorization: `Bearer ${PRAXIS_API_KEY}`, "Content-Type": "application/json" },
...(body === undefined ? {} : { body: JSON.stringify(body) }),
signal: AbortSignal.timeout(30_000),
});
const result = await response.json();
if (!response.ok) {
throw new Error(`HTTP ${response.status}; request=${response.headers.get("X-Request-Id")}; ${result.error?.message ?? ""}`);
}
return result;
}
// 1. Creating an agent saves version 1 and applies it.
const v1 = await request("/agents", {
name: "Versioned agent", kind: "service", model: "deepseek-flash",
system: "Answer in one sentence.", tools: [],
});
assert.equal(v1.version, 1);
assert.equal(v1.active_version, 1);
// 2. Save a draft: a new version that new sessions do not use yet.
const draft = await request(`/agents/${v1.id}`, {
version: v1.version,
system: "Answer in one sentence and end with the word DRAFT.",
apply: false,
version_note: "Trial of the new closing line",
});
assert.equal(draft.latest_version, 2);
assert.equal(draft.active_version, 1);
assert.equal(draft.version, 1, "the response describes the active configuration");
assert.equal(draft.note, null, "the active version has no note");
const savedVersions = await request(`/agents/${v1.id}/versions`);
const savedDraft = savedVersions.data.find(({ version }) => version === 2);
assert(savedDraft, "Expected saved version 2");
assert.equal(savedDraft.note, "Trial of the new closing line");
const effective = await request(`/agents/${v1.id}`);
assert.equal(effective.version, 1);
assert.equal(effective.latest_version, 2);
// 3. A session opened now still pins the active version 1.
const before = await request("/sessions", { agent: v1.id });
assert.equal(before.agent.version, 1);
// 4. Apply the draft: no new version, active_version moves.
const applied = await request(`/agents/${v1.id}/versions/2/apply`, {});
assert.equal(applied.active_version, 2);
const after = await request("/sessions", { agent: v1.id });
assert.equal(after.agent.version, 2);
assert.equal(before.agent.version, 1, "the earlier session keeps its version");
// 5. Roll back by applying version 1 again. Version 2 stays in the history.
const rolledBack = await request(`/agents/${v1.id}/versions/1/apply`, {});
assert.equal(rolledBack.active_version, 1);
const versions = await request(`/agents/${v1.id}/versions`);
console.log(versions.data.map(({ version, note, created_by }) => ({ version, note, created_by: created_by?.type })));
console.log({ agent: v1.id, latest: rolledBack.latest_version, active: rolledBack.active_version, verified: true });

Expected: two versions are printed (version 2 with its note), and the last line reads latest: 2, active: 1, verified: true. latest is the most recently saved version and active is the one in effect; they can differ.

Common questions

SymptomExplanation
Update returns 409Your version is stale because someone saved first; read again and redo the change
New sessions still behave the old way after a saveThe save used apply: false, or the session pinned an older version. Read active_version and apply the new version if needed
Update through /anthropic/v1/agents returns 409The agent has a draft that is not applied. The compatible face does not apply it for you; deal with the draft on the native face first
Archived agentIt cannot be updated, applied or used to create sessions. Call POST /agent/v1/agents/{agent_id}/unarchive first; this creates no version

Customer grant codes use the active version at issuance when no version is supplied; an explicit version pins that version. See Configure your agent. For every parameter see the Agent API. Next: Use skills · Runtime environments