Generate agent candidate solutions¶
Submit a complete candidate configuration of the agent, and the service will verify and save the candidate version.
POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-builder/candidates
Preparation before calling¶
First Query the available resources for intelligent agent construction to obtain the resource list. Prepare a personal access token and target workspace ID that has 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 through theX-Workspace-IDHeader and also asworkspace_idin the path.
candidate should include the agent identification, name, model, and referenced tools, skills, knowledge bases, or channels. The reference must be found in resources or within the resolvable scope of the workspace. When creating a candidate, use candidate.agent_id, not candidate.id.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-builder/candidates" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"mode": "create",
"conversation_id": "<CONVERSATION_ID>",
"raw_advice": "Create an agent that answers product questions.",
"resources": {
"models": [],
"tools": [],
"skills": [],
"knowledge_bases": []
},
"candidate": {
"agent_id": "<AGENT_ID>",
"name": "Product Assistant",
"description": "Answers product questions.",
"model_name": "<MODEL_NAME>",
"tool_names": [],
"skill_names": [],
"knowledge_base_names": [],
"catalog_files": [],
"channel_bindings": [],
"agent_md": "# Product Assistant",
"change_reason": "Initial creation"
}
}'
Path parameters¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Workspace ID. |
Request body¶
Parameters |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
Build mode; create new agents using |
|
string |
Yes |
The session ID to which this build belongs. |
|
string |
Yes |
The original request for this creation or modification. |
|
object |
Yes |
Resource collection returned by Query available resources for agent construction. |
|
object |
Yes |
Complete candidate agent configuration. |
|
string |
Yes |
New candidate agent ID. |
|
string |
Yes |
Agent name. |
|
string |
Yes |
Agent description. |
|
string |
Yes |
Available model name from |
|
string[] |
Yes |
Selected tool names; pass empty array if none. |
|
string[] |
Yes |
Selected skill names; pass empty array if none. |
|
string[] |
Yes |
Selected knowledge base names; pass empty array if none. |
|
array |
Yes |
Catalog files referenced by candidate; pass empty array if none. |
|
array |
Yes |
Candidate channel bindings; pass empty array if none. |
|
string |
Yes |
Editable agent Markdown body. |
|
string |
Yes |
Reason for candidate change. |
|
string |
No |
The associated task ID. |
|
string |
Required for revision mode |
Source agent ID. |
|
string |
No |
Source agent workspace. |
|
string |
Revision mode required |
Source version. |
Successful response¶
Returns 200 on success. Just because a candidate has been generated does not mean that it has become the current runnable version.
{
"code": 0,
"data": {
"render_type": "candidate",
"workspace_id": "ws_01",
"agent_id": "agent_01",
"candidate_version": "cand_01",
"load_version": "v1",
"source_digest": "sha256:<HEX_DIGEST>",
"mode": "create",
"status": "valid",
"display": {
"agent_name": "产品助手",
"agent_id": "agent_01"
},
"diagnostics": []
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
integer |
|
|
string |
The workspace and agent identification to which the candidate belongs. |
|
string |
The workspace and agent identification to which the candidate belongs. |
|
string |
Candidate version for subsequent regeneration, confirmation or cancellation. |
|
string |
Used to query the version of the loaded agent configuration after successful confirmation. |
|
string |
Current candidate content summary; subsequent write operations must return this value. |
|
string |
Build mode and candidate status. |
|
string |
Build mode and candidate status. |
|
object |
Presentation-oriented content candidates, validation diagnostics, and resolved resource references. |
|
array |
Presentation-oriented content candidates, validation diagnostics, and resolved resource references. |
|
object |
Presentation-oriented content candidates, validation diagnostics, and resolved resource references. |
|
object |
Summary of candidate package files; returned when available. |
Error response¶
{
"code": 2,
"message": "<错误信息>"
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The request contains unknown fields, required fields are missing, and the candidate configuration or resource reference is invalid. |
Based on error message and |
|
|
Lack of valid identity credentials. |
Check API Key. |
|
|
The current identity does not have permission to create or modify candidates. |
Check workspace and source agent authorizations. |
|
|
There are parallel authoring contexts or candidate conflicts for the same agent. |
Resubmit after reading the current candidate. |
|
|
|
Reduce the resource list and try again. |
|
|
Candidate build failed. |
Try again later; contact support if it continues to fail. |
|
|
Agent construction or authorization services are temporarily unavailable. |
Try again later. |
Follow-up operations¶
Use the version and summary from the response Confirm agent candidate solutions.