Skip to main content
Session & Event

创建 Session

启动一个新会话

POST
/api/v1/agentstudio/sessions
cURL
curl --request POST \
  --url 'https://{workspace_id}.{region}.maas.aliyuncs.com/api/v1/agentstudio/sessions' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "agent": "agent_xxx",
  "environment_id": "env_xxx",
  "title": "Q3 销售数据分析",
  "resources": [
    {
      "type": "file",
      "file_id": "file_xxx",
      "mount_path": "/uploads/workspace/data.csv"
    }
  ],
  "vault_ids": [
    "vlt_xxx"
  ],
  "metadata": {
    "biz_ticket_id": "1234"
  },
  "environment_variables": {
    "API_BASE_URL": "https://api.example.com",
    "LOG_LEVEL": "info"
  }
}
'
{
  "id": "sesn_xxx",
  "type": "session",
  "status": "idle",
  "agent": {
    "id": "agent_xxx",
    "type": "agent",
    "version": 1,
    "name": "data-analyst",
    "description": null,
    "model": {
      "id": "qwen3-max"
    },
    "system": "你是数据分析专家,使用 pandas 处理 CSV 文件。",
    "tools": []
  },
  "environment_id": "env_xxx",
  "title": "Q3 销售数据分析",
  "resources": [
    {
      "id": "sesrsc_xxx",
      "type": "file",
      "file_id": "file_xxx",
      "mount_path": "/mnt/session/uploads/workspace/data.csv",
      "created_at": "2026-05-28T08:23:11Z",
      "updated_at": "2026-05-28T08:23:11Z"
    },
    {
      "id": "sesrsc_yyy",
      "type": "memory_store",
      "memory_store_id": "memstore_xxx",
      "name": "项目知识库",
      "description": "项目约定、决策记录与排查笔记",
      "access": "read_write",
      "instructions": "优先查询该库中的项目约定;新发现保存到相关笔记中。",
      "mount_path": "/mnt/memory/项目知识库",
      "created_at": "2026-09-17T08:00:00Z",
      "updated_at": "2026-09-17T08:00:00Z"
    }
  ],
  "metadata": {
    "biz_ticket_id": "1234"
  },
  "archived_at": null,
  "created_at": "2026-05-28T08:23:11Z",
  "updated_at": "2026-05-28T08:23:11Z",
  "request_id": "xxx",
  "environment_variables": {
    "API_BASE_URL": "https://api.example.com",
    "LOG_LEVEL": "info"
  }
}

Authorizations

string
header
required

DashScope API Key

Body

application/json
string
required

绑定的智能体 ID。会话锁定智能体当前最新版本的快照

string
required

绑定的运行环境 ID

string

会话标题,便于在列表中辨识

object[]

创建时挂载的资源列表。文件挂载后以副本形式进入会话沙箱;记忆库挂载后由服务端生成挂载路径,智能体通过文件工具读写。同一记忆库不能重复挂载

文件挂载

  • Option 1
  • Option 2
string[]

Vault ID 列表。将指定 Vault 中的 Credential 注入会话运行环境,使智能体可访问对应密钥

object

业务自定义键值,不影响模型行为

object

会话运行时注入的环境变量,字符串键值对,沙箱代码中可直接按名读取

Response

200-application/json
string

会话 ID,格式 sesn_<ULID>

string

固定为 session

enum<string>

会话状态:idle / running / terminated。新建会话为 idle

idle,running,terminated
object

智能体配置完整快照(创建时锁定),含 id/version/name/model/system/tools 等

string

绑定的运行环境 ID

string

会话标题

object[]

挂载的资源列表。文件为副本挂载;记忆库由服务端生成 mount_path

文件挂载

  • Option 1
  • Option 2
object

业务自定义键值

string | null

归档时间,未归档时为 null

string

创建时间,ISO 8601

string

最近更新时间,ISO 8601

string

本次请求的唯一标识

object

会话运行时注入的环境变量

Sandbox API
Security API
记忆库 API
Flow Agent API
RAG API
Connector API
框架集成
  • 框架
Assistant API(下线中)
  • 概览