CreateAgent

Updated at:
Copy as MD

Creates an agent.

Operation description

  • Name is the unique identifier of the agent within the current tenant. It can contain only letters, digits, underscores, and hyphens, and must be 1 to 128 characters in length. It cannot be modified after creation.

  • Each agent can be bound to only one knowledge base.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ada:CreateAgent

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

Name

string

Yes

The name of the agent, which is also the unique identifier that cannot be modified after creation.

code-review-agent

DisplayName

string

No

The display name of the agent.

Code review agent

Description

string

No

The description of the agent.

Analyze code changes and generate code review comments

SystemPrompt

string

No

The system prompt.

Check the correctness, security, and maintainability of code changes in the code review, and provide review comments based on severity

Tools

any

No

The list of references to MCP server and connector names. The same array supports both types of entries. Specify only one type of reference for each entry. For MCP, omitting items indicates all public tools, and historically specified items retain their original values.

[{"mcpServerName":"code-repository-mcp"},{"connectorName":"code-review-data"}]

Skills

any

No

The list of skill references. For specific fields, refer to the supplementary description of request parameters.

[{"name":"code-review"}]

KnowledgeBases

any

No

The list of knowledge base references, which can contain at most one element.

[{"name":"code-review-guidelines"}]

Visibility

string

No

The visibility scope of the agent. Valid values: user and tenant. Default value: user.

Valid values:

  • user
  • tenant

user

Tools (MCP server and connector)

NameTypeDescriptionExample
mcpServerNamestringThe name of the registered MCP server.code-repository-mcp
connectorNamestringThe name of the connector that is visible, not deleted, and available to the current identity.code-review-data

A single Tools array can contain both types of entries. For a single name entry, specify only one of mcpServerName or connectorName. The request fails and partial configurations are not saved if the name is empty, does not exist, is invisible, is unavailable, contains unknown fields, or is a duplicate reference.

Skills

NameTypeDescriptionExample
namestringThe name of the skill. The current available version is used at runtime.code-review

KnowledgeBases

NameTypeDescriptionExample
namestringThe name of the existing knowledge base that is accessible to the current identity.code-review-guidelines

Request example

{
  "Name": "code-review-agent",
  "DisplayName": "CR 代码评审 Agent",
  "Description": "分析代码变更并生成 CR 评审意见",
  "SystemPrompt": "请检查 CR 中代码变更的正确性、安全性和可维护性,并按严重程度给出评审意见。",
  "Tools": [
    {
      "mcpServerName": "code-repository-mcp"
    },
    {
      "connectorName": "code-review-data"
    }
  ],
  "Skills": [
    {
      "name": "code-review"
    }
  ],
  "KnowledgeBases": [
    {
      "name": "code-review-guidelines"
    }
  ],
  "Visibility": "user"
}

Response elements

Element

Type

Description

Example

object

The agent creation result.

AgentId

string

The agent ID generated by the service.

agent_00000000000000000000000000000001

Name

string

The name of the created agent.

code-review-agent

UpdatedAt

integer

The last update time, which is a UNIX timestamp in milliseconds.

1788332400000

Success

boolean

Indicates whether the agent was created successfully. A success response always returns true. An error response is returned upon failure.

true

RequestId

string

The request ID, which is used for Tracing Analysis and troubleshooting.

0A1B2C3D-4E5F-6789-ABCD-EF0123456789

Success response example

{
  "AgentId": "agent_00000000000000000000000000000001",
  "Name": "code-review-agent",
  "UpdatedAt": 1788332400000,
  "Success": true,
  "RequestId": "0A1B2C3D-4E5F-6789-ABCD-EF0123456789"
}

Examples

Success response

JSON format

{
  "AgentId": "agent_00000000000000000000000000000001",
  "Name": "code-review-agent",
  "UpdatedAt": 1788332400000,
  "Success": true,
  "RequestId": "0A1B2C3D-4E5F-6789-ABCD-EF0123456789"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter The specified parameter is invalid.
401 Unauthenticated Authentication required.
500 InternalError Internal server error.
503 ServiceUnavailable The service is not ready or temporarily unavailable.
504 ServiceTimeout A required service timed out.
504 Agent.OperationResultUnknown The Agent operation result is unknown.
409 Agent.AlreadyExists An Agent with the specified name already exists.

See Error CodesError Codes for a complete list.

Release notes

See Release NotesRelease Notes for a complete list.