Files

更新时间:
复制 MD 格式

Files are independently managed resources that can be mounted to multiple sessions with a lifecycle decoupled from sessions. Upload and manage files from the Files menu in the console.

Quotas and Limits

  • Maximum single file size: 10 MB.

  • Total file storage per workspace: 100 GB.

  • File retention period: 30 days. Files may be automatically cleaned up after expiration. Re-upload periodically for long-term retention.

Upload

On the Files page, click Upload File and select a local file to upload. After uploading, the file enters security review (checking). Once the review passes, it becomes available and can be mounted to sessions. If the review fails, the file is marked as rejected or type_rejected.

To upload a file via API, submit it as multipart/form-data. For complete parameters and response fields, see Upload File.

curl -X POST "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/files" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -F "file=@./sales_2025.csv"
file = client.files.upload("sales_2025.csv")
print(file.id)
AgentStudioFile file = client.files().upload(Paths.get("sales_2025.csv"), "text/csv");
System.out.println(file.getId());

Session Isolation

When a file is mounted to a session, the server creates an internal copy and mounts it into the session sandbox. The original file is not affected by modifications within the session. You can view the actual copy of mounted files in the session details.

Mount to Session

Mount During Session Creation

In the New Session drawer, click Add File in the Mount Resources section, select an uploaded file, and specify the mount path, for example /uploads/workspace/data.csv. The path must start with /uploads/.

Path Prefix

The specified mount path is prefixed with /mnt/session. The path must start with /uploads/. For example:

Specified Path

Actual Path (seen by the agent)

/uploads/workspace/data.csv

/mnt/session/uploads/workspace/data.csv

/uploads/data/sales.xlsx

/mnt/session/uploads/data/sales.xlsx

The agent should use the actual path when accessing files in tool calls. You can specify the full path directly in the system prompt, for example: The data file is located at /mnt/session/uploads/workspace/data.csv.

To mount files via API, use the resources field when creating a session. For complete parameters and response fields, see Create Session.

curl -X POST "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sessions" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "agent_xxx",
    "environment_id": "env_xxx",
    "resources": [
      {"type": "file", "file_id": "file_xxx", "mount_path": "/uploads/workspace/data.csv"}
    ]
  }'
session = client.sessions.create(
    agent="agent_xxx",
    environment_id="env_xxx",
    resources=[
        {"type": "file", "file_id": "file_xxx", "mount_path": "/uploads/workspace/data.csv"},
    ],
)
Session session = client.sessions().create(SessionCreateParam.builder()
    .agentId("agent_xxx")
    .environmentId("env_xxx")
    .resources(List.of(SessionResource.builder()
        .type("file")
        .fileId("file_xxx")
        .mountPath("/uploads/workspace/data.csv")
        .build()))
    .build());

Delete

Files can only be deleted, not archived. Click Delete on the corresponding file row on the Files page. The file is permanently deleted and cannot be recovered. Copies already mounted to sessions are not affected.

To delete a file via API (irreversible). For complete parameters and response fields, see Delete File.

curl -X DELETE "https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/files/file_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
client.files.delete("file_xxx")
client.files().delete("file_xxx");