添加会话资源
给会话挂载一份附加资源,供会话执行时使用。
先调用「上传文件」,用返回的文件 ID 替换示例文件 ID。 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
/agent/v1/sessions/{session_id}/resources◐ 部分支持请求参数
session_idstring必填path: Session id (sesn_...), as returned by sessions.create or sessions.list. The same id is also accepted as the session_id query parameter on resource and thread calls, where it must equal the path value.
typestring必填query: Resource type selector for the body; only file resources are supported. Normally you send type inside the JSON body and omit this parameter.
file_idstring必填ID of a previously uploaded file.
mount_pathstring可选Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.
返回
200
支持 file 类型资源的持久化、查询和解除关联,单会话最多 500 条。文件须属于当前租户且有效。默认路径为 /mnt/session/uploads/<file_id>,自定义路径归一到该目录,拒绝父目录遍历。不修改文件内容;本批尚不将资源同步到沙箱。
错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码
响应
HTTP 200
Successful response
application/json
| 名称 | 类型 | 说明 |
|---|---|---|
| id | string | Resource id, the resource_id of sessions.resources calls. |
| created_at | string | A timestamp in RFC 3339 format |
| file_id | string | Id of the uploaded file; it must exist and belong to your tenant. |
| mount_path | string | Path inside the machine where the file is mounted; defaults to /mnt/session/uploads/<file_id>, and custom paths are rooted there. |
| type | string | Always `file`. A file resource: an uploaded file mounted into the session's machine. |
| updated_at | string | A timestamp in RFC 3339 format |