Agents
Update an agent
Update an agent by replacing its whole configuration.
PUT
/
api
/
v2
/
agents
/
{agent_name}
from hai_agents import Client
client = Client()
agent = client.agents.update_agent(
agent_name="my-research-bot",
name="my-research-bot",
description="Researches a topic and returns a sourced summary.",
environments=["h/browser"],
instructions="Always cite the page you took each claim from.",
skills=["web-browse", "extract-data"],
)
print(agent.name)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.updateAgent({
agentName: "my-research-bot",
body: {
name: "my-research-bot",
description: "Researches a topic and returns a sourced summary.",
environments: ["h/browser"],
instructions: "Always cite the page you took each claim from.",
skills: ["web-browse", "extract-data"],
},
});
console.log(agent.name);
curl -X PUT https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"instructions": "Always cite the page you took each claim from.",
"skills": ["web-browse", "extract-data"]
}'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Always cite the page you took each claim from.",
"subagents": null,
"skills": ["web-browse", "extract-data"],
"answer_format": null,
"tools": null
}
Behavior
Each update is saved as a new revision. Sessions pinned to an earlier revision withname:N keep running that one. Sending the current spec changes nothing. The name can’t change. To change a few fields, patch the agent.
Headers
string
The
ETag of the revision you based this change on, for example "3". If the agent has moved past it, the write fails with 412. Omit it, or send *, to write regardless.Path parameters
string
required
The agent’s
name, for example my-research-bot or myorg/web-helper.Query parameters
string
A note stored on the new revision, such as why you made the change. Up to 500 characters. Shown by List revisions.
Request body
The full agent, with the same fields and rules as Create an agent. Thename must equal the URL identifier. Omitted fields reset to their defaults: leaving out instructions, model, skills, or answer_format clears them.
Response
200 with the updated agent object, with its new revision in the ETag header.
from hai_agents import Client
client = Client()
agent = client.agents.update_agent(
agent_name="my-research-bot",
name="my-research-bot",
description="Researches a topic and returns a sourced summary.",
environments=["h/browser"],
instructions="Always cite the page you took each claim from.",
skills=["web-browse", "extract-data"],
)
print(agent.name)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.updateAgent({
agentName: "my-research-bot",
body: {
name: "my-research-bot",
description: "Researches a topic and returns a sourced summary.",
environments: ["h/browser"],
instructions: "Always cite the page you took each claim from.",
skills: ["web-browse", "extract-data"],
},
});
console.log(agent.name);
curl -X PUT https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"instructions": "Always cite the page you took each claim from.",
"skills": ["web-browse", "extract-data"]
}'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Always cite the page you took each claim from.",
"subagents": null,
"skills": ["web-browse", "extract-data"],
"answer_format": null,
"tools": null
}
Errors
| Status | Cause |
|---|---|
400 | The name in the body does not match the URL identifier, or 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. |
412 | If-Match names a revision that isn’t the current one. The ETag header has the current one: read it, reapply your change, and retry. |
422 | Body failed validation. Common cases: environments empty on an agent with no subagents or tools, invalid name shape. |
Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
agent = client.agents.update_agent(
agent_name="my-research-bot",
name="my-research-bot",
description="Researches a topic and returns a sourced summary.",
environments=["h/browser"],
instructions="Always cite the page you took each claim from.",
skills=["web-browse", "extract-data"],
)
print(agent.name)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const agent = await client.agents.updateAgent({
agentName: "my-research-bot",
body: {
name: "my-research-bot",
description: "Researches a topic and returns a sourced summary.",
environments: ["h/browser"],
instructions: "Always cite the page you took each claim from.",
skills: ["web-browse", "extract-data"],
},
});
console.log(agent.name);
curl -X PUT https://agp.eu.hcompany.ai/api/v2/agents/my-research-bot \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"instructions": "Always cite the page you took each claim from.",
"skills": ["web-browse", "extract-data"]
}'
{
"name": "my-research-bot",
"description": "Researches a topic and returns a sourced summary.",
"environments": ["h/browser"],
"model": null,
"reasoning_effort": null,
"instructions": "Always cite the page you took each claim from.",
"subagents": null,
"skills": ["web-browse", "extract-data"],
"answer_format": null,
"tools": null
}