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.

HTTP
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

Shell
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

workspace_id

string

Yes

The workspace where this task is located must be consistent with the workspace request header.

agent_id

string

Yes

The target agent ID returned by the agent list.

Query parameters

Parameter

Type

Required

Description

agent_workspace_id

string

No

The workspace to which the target agent belongs can only be the current workspace or system. When omitted, the current workspace is used.

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.

message/send

Submit user message and return Task. Can contain idempotent keys, models, and metadata.

Start the task and save the session.

message/stream

Submit the message, returning an SSE JSON-RPC frame.

Start the task and do not cancel it when disconnected.

tasks/get

Read tasks by id / taskId, id takes precedence.

A read may trigger interrupt recovery.

tasks/resubscribe

Resubscribe by task ID and afterSeq.

Resume event delivery.

tasks/cancel

After canceling, reread the task and return.

Cancellation may precede status submission.

matrixflow/input.submit

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

jsonrpc

string

Yes

Fixed to 2.0.

id

string or number

No

JSON-RPC request ID. The response echoes this value.

method

string

Yes

Supports sending, streaming, reading tasks, resubscribing, canceling and submitting pending input. See instructions below for each method.

params

object

Yes

The parameters of the corresponding method.

params.model

string

When sending a message it is

Available model names. Obtained from the model field of the available models list. tasks/get This field is not passed. If missing, HTTP 400 is returned, and the error reason is MODEL_REQUIRED.

params.metadata

object

No

Extended information such as session usage.

params.metadata.conversation_purpose

string

No

The workflow generates and fills in workflow.

params.message

object

When sending a message it is

A2A message.

params.message.kind

string

When sending a message it is

Fixed to message.

params.message.role

string

When sending a message it is

Users on this page need to fill in user.

params.message.messageId

string

When sending a message it is

The unique identifier of this message.

params.message.contextId

string

No

When revising in the same session, fill in the result.contextId of the previous task.

params.message.parts

array of object

When sending a message it is

Message segmentation.

params.message.parts[].kind

string

Yes

Fill in the text text in sections.

params.message.parts[].text

string

When text is segmented it is

Natural language requirements.

params.id

string

When querying tasks, it is

The real task ID used by tasks/get. Also supports params.taskId.

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

JSON
{
  "jsonrpc": "2.0",
  "id": "req_01",
  "result": {
    "kind": "task",
    "id": "task_01",
    "contextId": "ctx_01",
    "status": {
      "state": "submitted"
    }
  }
}
JSON
{
  "jsonrpc": "2.0",
  "id": "get-task-1",
  "method": "tasks/get",
  "params": {
    "id": "task_01"
  }
}

Field

Type

Description

jsonrpc

string

Fixed to 2.0.

id

string or number or null

Echo request ID.

result

object

method results.

result.kind

string

Task or message type.

result.id

string

The task ID in the task results.

result.contextId

string

Session context ID that can be used for the next revision message.

result.status

object

Task status.

result.status.state

string

submitted, working, input-required, auth-required, completed, failed, canceled or rejected.

result.artifacts

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.

JSON
{
  "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

-32602

params.model was not specified when sending the message.

Choose a model value from the available models list, set params.model, and resend the message.

500

ErrServer

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.

Last updated on