Call an agent from another agent¶
Send messages or query tasks to the target agent through A2A JSON-RPC. Generating tasks and executing workflow are two independent processes.
POST $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/agents/{agent_id}/a2a
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First query the agent call description to confirm the target capability. When calling the workflow assistant to generate or revise candidates, you also need to query the available model and select the model to be used for generation.
Prepare personal access token and target workspace ID that can access the target workspace.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/a2a?agent_workspace_id=$AGENT_WORKSPACE_ID" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
--data-binary "$(jq -n --arg REQUEST_ID "$REQUEST_ID" --arg MODEL "$MODEL" --arg MESSAGE_ID "$MESSAGE_ID" '
{
"jsonrpc": "2.0",
"id": $REQUEST_ID,
"method": "message/send",
"params": {
"model": $MODEL,
"metadata": {
"conversation_purpose": "workflow"
},
"message": {
"kind": "message",
"role": "user",
"messageId": $MESSAGE_ID,
"parts": [
{
"kind": "text",
"text": "生成一个手动运行的文本清洗工作流,接收必填字符串 text,使用已有清洗算子处理文本。请提交可部署候选,不要直接部署或运行。"
}
]
}
}
}
')"
$AGENT_ID and $AGENT_WORKSPACE_ID come from id and workspace_id of the same item in the agent list. $WORKSPACE_ID is the workspace where this call is located, and $CLOUDSIGMA_API_KEY is the calling credential. $MODEL is model in the available model list, not the model configuration ID. $REQUEST_ID and $MESSAGE_ID are the unique strings generated by the caller for this request and message.
params.model must be specified when sending message/send. Ordinary agent messages can be omitted conversation_purpose. When querying tasks/get, params.model is not transmitted.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The workspace where this task is located must be consistent with the workspace request header. |
|
string |
Yes |
The target agent ID returned by the agent list. |
Query parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
No |
The workspace to which the target agent belongs can only be the current workspace or |
The common entry POST /v5/agents/a2a places agent_id and optionally agent_workspace_id in the request body. Supported built-in code also works with agent_code. The workspace-level entry in this article places the selector in the path and query parameters, and only submits JSON-RPC in the request body.
Request body
The example uses jq to construct the JSON request body. Install jq first and set the required environment variables. Do not JSON encode the variable values again.
Task query first uses non-empty id, followed by taskId. The cursor of tasks/get is fixed to 0, and afterSeq is only used for resubscription. Various errors read by the current task may be mapped to 404 / -32001. It cannot be judged that the task does not exist based on 404 alone.
Metadata in the message and parameters are merged, and parameter metadata overwrites keys with the same name in the message. params.model participates in model selection, while the top-level model does not. Idempotent keys and run backend selection are handled according to corresponding parameters. Parameters and locale in both types of metadata are prohibited from being passed in.
The following six JSON-RPC methods are handled through the public entrance on this page. The inputs, results, and control actions for each method are listed separately.
method |
Parameters and results |
side effects. |
|---|---|---|
|
Submit user message and return Task. Can contain idempotent keys, models, and metadata. |
Start the task and save the session. |
|
Submit the message, returning an SSE JSON-RPC frame. |
Start the task and do not cancel it when disconnected. |
|
Read tasks by id / taskId, id takes precedence. |
A read may trigger interrupt recovery. |
|
Resubscribe by task ID and afterSeq. |
Resume event delivery. |
|
After canceling, reread the task and return. |
Cancellation may precede status submission. |
|
Submits the input the task is waiting for and returns the current Task. |
The executor may be restored before the snapshot is saved. |
params.message includes messageId, role=user, parts, optional taskId, contextId and metadata. Each part has kind, and by type use text, file, data, metadata. The file can contain uri, mimeType, name. Send parameters can also include idempotencyKey, model, llm_backend_id and metadata.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Fixed to |
|
string or number |
No |
JSON-RPC request ID. The response echoes this value. |
|
string |
Yes |
Supports sending, streaming, reading tasks, resubscribing, canceling and submitting pending input. See instructions below for each method. |
|
object |
Yes |
The parameters of the corresponding method. |
|
string |
When sending a message it is |
Available model names. Obtained from the |
|
object |
No |
Extended information such as session usage. |
|
string |
No |
The workflow generates and fills in |
|
object |
When sending a message it is |
A2A message. |
|
string |
When sending a message it is |
Fixed to |
|
string |
When sending a message it is |
Users on this page need to fill in |
|
string |
When sending a message it is |
The unique identifier of this message. |
|
string |
No |
When revising in the same session, fill in the |
|
array of object |
When sending a message it is |
Message segmentation. |
|
string |
Yes |
Fill in the text |
|
string |
When text is segmented it is |
Natural language requirements. |
|
string |
When querying tasks, it is |
The real task ID used by |
Streaming response¶
Streaming responses use event: message, data for JSON-RPC results or errors. When there is a positive sequence number, SSE id is its decimal text. HTTP 200 simply means the stream has been established. Disconnecting stops delivery but does not cancel the task.
Explicitly call cancel when execution needs to be stopped. Use the return serial number when renewal is required. The final frame that requires input or authorization only ends the current flow and does not indicate successful completion of the task.
Successful response¶
{
"jsonrpc": "2.0",
"id": "req_01",
"result": {
"kind": "task",
"id": "task_01",
"contextId": "ctx_01",
"status": {
"state": "submitted"
}
}
}
{
"jsonrpc": "2.0",
"id": "get-task-1",
"method": "tasks/get",
"params": {
"id": "task_01"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
Fixed to |
|
string or number or null |
Echo request ID. |
|
object |
method results. |
|
string |
Task or message type. |
|
string |
The task ID in the task results. |
|
string |
Session context ID that can be used for the next revision message. |
|
object |
Task status. |
|
string |
|
|
array of object |
Task product. When generating the workflow, you also need to check whether it contains valid candidates. |
Error response¶
When sending a message with missing model parameters, the workspace-level interface returns the following error excerpt.
{
"jsonrpc": "2.0",
"id": "req_01",
"error": {
"code": -32602,
"message": "请通过 params.model 指定模型。",
"data": {
"domain": "moi-core.agent_runtime",
"meta": {
"cause": "params.model is required"
},
"reason": "MODEL_REQUIRED"
}
}
}
Common HTTP errors¶
HTTP status |
Error code |
Common cause |
Recommended action |
|---|---|---|---|
400 |
|
|
Choose a |
500 |
|
General gateway forwarding or processing failed and returned the standard error envelope. |
Save the request timestamp and request/trace ID, verify the specific error via the workspace-scoped path, and query existing sessions and tasks before retrying generation. |
When available, error.data.trace_id is used for positioning requests. The universal portal’s error envelope is different from the runtime JSON-RPC errors described above, and all errors cannot be parsed in just one format.