Update resource binding¶
Updates a tool, skill, knowledge base, or channel binding referenced by the agent. It is recommended to use binding_ops for single changes; binding can also be used to update by category.
PATCH https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agents/{agent_id}/bindings
Preparation before calling¶
First query the agent list to obtain the agent ID, and confirm the resource ID to be bound. Prepare the personal access token, target workspace ID, and agent ID that have access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$AGENT_ID: Agent ID to update.$TOOL_ID: Tool ID to add.
Request example¶
The following example adds a tool to the current binding:
curl -X PATCH "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/bindings" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"binding_ops": [
{
"op": "add",
"kind": "tool",
"ref": {
"id": "'"$TOOL_ID"'"
}
}
]
}'
Path parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
The current workspace ID. |
|
string |
Yes |
The agent ID to update. |
Query parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
No |
ID of the workspace to which the agent definition belongs. When provided at the same time as a field with the same name in the request body, the two must be consistent. |
Request body¶
The request body must be a JSON object. binding_ops cannot be used with a non-empty category replacement field in binding.
Field |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
No |
The ID of the workspace to which the agent definition belongs. If not provided, the current workspace is used. |
|
object |
No |
Update bindings by category. Omitting a category retains the category; explicitly passing an empty array clears the category. |
|
array |
No |
Resource references for tools, skills, and knowledge bases. Each uses at least the |
|
array |
No |
Resource references for tools, skills, and knowledge bases. Each uses at least the |
|
array |
No |
Resource references for tools, skills, and knowledge bases. Each uses at least the |
|
array |
No |
Channel binding; each contains |
|
array |
No |
List of changes by item. |
|
string |
Yes |
Operation type: |
|
string |
Condition required |
Specify the resource category and resource reference respectively for |
|
object |
Condition required |
Specify the resource category and resource reference respectively for |
|
string |
Condition required |
|
|
string |
Condition required |
|
|
string[] |
Condition required |
|
[] after a type denotes an array. [] in a field path denotes each item in an array.
Successful response¶
Returns 200 on success. The structure of data is the same as query resource binding], which represents a valid binding that has been saved and parsed.
{
"code": 0,
"data": {
"workspace_id": "ws_01",
"agent_workspace_id": "ws_01",
"agent_id": "agent_01",
"agent_version": 3,
"tools": [
{
"id": "tool_01",
"kind": "tool"
}
],
"skills": [],
"knowledge_bases": [],
"channel_bindings": [],
"warnings": []
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
Call the workspace and the workspace to which the agent definition belongs. |
|
string |
Call the workspace and the workspace to which the agent definition belongs. |
|
string |
Agent ID and updated resource version. |
|
integer |
Agent ID and updated resource version. |
|
array |
The saved and parsed binding. |
|
array |
The saved and parsed binding. |
|
array |
The saved and parsed binding. |
|
array |
The saved and parsed binding. |
|
string[] |
Unresolved reference description. |
[] after a type denotes an array. [] in a field path denotes each item in an array.
Error response¶
{
"code": 2,
"message": "<错误信息>"
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request body is invalid, |
Check JSON, resource references and workspace scopes. |
|
|
Lack of valid identity credentials. |
Check API Key. |
|
|
The current caller does not have permission to update the agent. |
Check the agent authorization in the workspace. |
|
|
Attempt to directly modify the system read-only agent in the current workspace. |
To configure a system agent, create an allowed binding override in the workspace. |
|
|
Agent or run provider configuration does not exist. |
Check the agent ID, belonging workspace and run target. |
|
|
The agent resource service or its authorized dependencies are temporarily unavailable. |
Try again later. |
Follow-up operations¶
Use the same resource identifier Query resource binding to confirm the update result.