Agents
Restore an agent revision
Restore an earlier revision’s spec as a new revision.
POST
/
api
/
v2
/
agents
/
{agent_name}
/
revisions
/
{number}
/
restore
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"5"')
print(agent.instructions)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.restoreAgentRevision({ agentName: "my-research-bot", number: 2, ifMatch: '"5"' });
console.log(agent.instructions);
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot/revisions/2/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "5"'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Cite a source for every claim.",
"subagents": null,
"skills": null,
"answer_format": null,
"tools": null
}
Behavior
History is never rewritten: the spec of revisionnumber becomes the agent’s next revision, with the message Restored from vN and restored_from set to N. Later sessions run it, except those pinned to another revision with name:N. Restoring a spec equal to the current one changes nothing.
The restored spec is checked like an update: the environments, skills, and subagents it names must still exist and be visible to you.
Headers
string
The
ETag of the revision you based this rollback on, for example "5". If the agent has moved past it, the restore fails with 412. Omit it, or send *, to restore regardless.Path parameters
string
required
The agent’s
name, for example my-research-bot or myorg/web-helper.integer
required
The revision to restore, from List revisions.
Response
200 with the restored agent object, with its new revision in the ETag header.
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"5"')
print(agent.instructions)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.restoreAgentRevision({ agentName: "my-research-bot", number: 2, ifMatch: '"5"' });
console.log(agent.instructions);
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot/revisions/2/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "5"'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Cite a source for every claim.",
"subagents": null,
"skills": null,
"answer_format": null,
"tools": null
}
Errors
| Status | Cause |
|---|---|
400 | If-Match is not a single revision tag. |
403 | The agent is reserved (h/) and read-only. |
404 | Not found, or not in your organization. Also sent for an unknown revision, or when an environment the revision names was deleted. |
410 | The revision’s stored spec fails current validation. |
412 | If-Match names a revision that isn’t the current one. The ETag header has the current one. |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
agent = client.agents.restore_agent_revision(agent_name="my-research-bot", number=2, if_match='"5"')
print(agent.instructions)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.restoreAgentRevision({ agentName: "my-research-bot", number: 2, ifMatch: '"5"' });
console.log(agent.instructions);
curl -X POST https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot/revisions/2/restore \
-H "Authorization: Bearer $HAI_API_KEY" \
-H 'If-Match: "5"'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Cite a source for every claim.",
"subagents": null,
"skills": null,
"answer_format": null,
"tools": null
}