Update agent
Update an agent configuration; omitted top-level fields keep their values, and supplied objects or arrays replace the whole field.
Endpoint
Returns 200 and the complete updated Agent object. Update uses top-level replacement: omitted fields keep their current values, supplied objects or arrays replace the whole field, and null clears nullable fields. Update is not a recursive JSON Merge Patch; metadata:{"a":"new"} removes old keys that are not in the new object.
model can be omitted, but an explicit null returns 400. On conflict, the service rereads and merges the latest value, up to 3 attempts, then returns 500. No public version or ETag conditional-update field is provided. {} does not change business fields and does not guarantee that updated_at changes.
/agents/{agent_id}Path parameters
agent_idstringRequiredAgent ID, format agent_<ULID>
Request body
modelstringOptionalModel ID, omitted keeps the current value; explicit null returns 400; after a change the model must be available in the current workspace, or the API returns 404 model_not_found. For available models, see Available models.
namestring / nullOptionalDisplay name, up to 128 characters; null clears it
instructionsstring / nullOptionalCustom instructions, up to 1,048,576 characters; null clears them
metadataobject / nullOptionalMetadata, string key-value pairs; replaced as a whole, null clears, {} replaces with an empty object
reasoningobject / nullOptionalReasoning configuration, replaced as a whole; null clears.
Properties
effortstring / nullOptionalReasoning effort: none, minimal, low, medium, high, xhigh, max
summarystring / nullOptionalReasoning summary: concise, detailed, auto
textobject / nullOptionalText configuration, replaced as a whole; null clears. Only fixed text output is supported
toolsarray / nullOptionalTool list, replaced as a whole; null clears, [] replaces with an empty list.
Properties
function
namestringRequiredFunction name, must be unique within the agent
descriptionstring / nullRequiredFunction description, can be null
parametersobjectRequiredFunction input JSON Schema; must declare type: object
mcp
server_labelstringRequiredMCP server label, must be unique within the agent
transportobjectRequiredTransport configuration; see the branches below
Properties
typestringRequiredTransport type, http or stdio
server_urlstring / nullConditionalMCP server URL
headersobject<string,string> / nullOptionalAdditional HTTP headers; do not put secrets here
commandstringConditionalCommand to start the server
cwdstringConditionalWorking directory; must be an absolute path whose segments are not . or ..
argsarray<string> / nullOptionalCommand arguments
allowed_toolsarray<string> / nullOptionalAllowed tool names; null means no filter
requiredbooleanOptionalWhether MCP initialization must succeed
connection_originstring / nullOptionalConnection origin, service or environment, defaults to service
web_search
typestringRequiredTool type, fixed as web_search
multi_agentobject / nullOptionalMulti-agent configuration, replaced as a whole; null clears, default concurrency is not filled in
Tool fields: each tool must provide a type. The current supported types are function, mcp, and web_search. Update only saves the configuration; it does not mean the tool can execute.
Unknown top-level fields do not produce an error and may be filtered out and recorded; do not assume a field is applied just because the request succeeds.
Update validates the patch before looking up the resource. If the patch is invalid and the resource does not exist at the same time, the API can return 400 first.
Request example
curl -sS -X POST "$BASE_URL/agents/agent_xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "OpenAI-Beta: agents=v1" \
-H "Content-Type: application/json" \
-d '{
"name": "example-agent",
"metadata": {"purpose": "qa"},
"reasoning": {"effort": "medium", "summary": "auto"},
"tools": [{"type": "web_search"}]
}'
agent = client.beta.agents.update(
"agent_xxx",
name="example-agent",
metadata={"purpose": "qa"},
reasoning={"effort": "medium", "summary": "auto"},
tools=[{"type": "web_search"}],
)
print(agent.updated_at)
Response fields
Returns the complete updated agent object. Optional fields that were never set can be null.
idstringAgent ID. Treat it as an opaque string
objectstringAgent object type, fixed as agent
created_atintegerCreation time as a Unix timestamp in seconds
updated_atintegerLast modification time as a Unix timestamp in seconds; not a version number
namestring / nullDisplay name
metadataobject / nullMetadata, stored string key-value pairs
modelstringStored model ID
reasoningobject / nullReasoning configuration. Either subfield can be null.
Properties
effortstring / nullReasoning effort: none, minimal, low, medium, high, xhigh, max
summarystring / nullReasoning summary: concise, detailed, auto
textobject / nullText output configuration.
Properties
formatobjectOutput format.
Properties
typestring / nullOutput format type, fixed as text
verbositystring / nullOutput verbosity, low, medium, high
instructionsstring / nullStored custom instructions
toolsarray / nullStored tool configuration; each branch returns only its own fields
Properties
functionobjectFunction tool configuration; returns name, description, and parameters
mcpobjectMCP tool configuration; returns server_label, transport, allowed_tools, required, and connection_origin; transport is http or stdio
web_searchobjectWeb search tool configuration; returns type and the saved configuration
multi_agentobject / nullSubagent configuration.
Properties
enabledbooleanWhether subagent tools are enabled
max_concurrent_subagentsinteger / nullMaximum number of concurrent subagents; no default is applied
Response example
{
"id": "agent_xxx",
"object": "agent",
"created_at": 1794117521,
"updated_at": 1794117600,
"name": "example-agent",
"metadata": {"purpose": "qa"},
"model": "qwen3.8-max",
"reasoning": {"effort": "medium", "summary": "auto"},
"text": null,
"instructions": "Answer briefly and include steps when necessary.",
"tools": [
{
"type": "web_search"
}
],
"multi_agent": null
}
Error codes
Business errors return an error object with type, code, message, and param. Common errors:
| HTTP status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error | Fix field types, enums, lengths, and cross-field constraints as described; omit model instead of sending null |
400 | invalid_request_error / string_above_max_length | Shorten instructions to 1,048,576 characters or fewer |
401 | authentication_error / invalid_api_key | Send a valid Authorization: Bearer $DASHSCOPE_API_KEY header |
404 | invalid_request_error / model_not_found | Use a model ID that is available in the current workspace |
404 | not_found_error / not_found_error | Use an agent ID that exists and has not been deleted in the current workspace |
500 | server_error / server_error | Retry later. If it keeps failing, submit a ticket with x-request-id |