When a Sandbox is running, call the append mount operation to add an AgenticFS mount without recreating the Sandbox.
How it works
When a Sandbox is in the running state, an AgenticFS mount can be added without recreating the Sandbox. When you append a mount, specify the AgenticFS mount configuration directly, or reference an existing AgenticFS volume by name.
This topic describes how to append an AgenticFS mount to a running Sandbox. To specify the mount configuration when you create a Sandbox, see Mount AgenticFS dynamically.
Prerequisites
-
The Sandbox is in the running state. If the Sandbox is paused, resume it first.
-
The API key used in the request belongs to the same team as the target Sandbox.
-
You have prepared an AgenticSpace Access Point for which Resource Access Management (RAM) authentication is enabled and that is in the
activestate. In this topic, the AgenticSpace Access Point is referred to as an Access Point. -
The Sandbox is configured with a RAM role and the complete Virtual Private Cloud (VPC) information required to access the target Access Point. The role must have the permissions to mount the target AgenticFS and to read and write data in the AgenticFS.
-
If you reference an existing volume, create the volume in the same team as described in Create an AgenticFS Volume, and obtain the name of an available volume.
The complete VPC configuration includes vpcId, securityGroupId, and a non-empty vSwitchIds. An append mount uses the current RAM role and VPC configuration of the Sandbox. The append mount operation does not set or replace these configurations. If you reference an existing volume, the mountConfig of the volume does not replace the current configurations either.
For information about how to configure the role, see Configure a RAM role. To specify the mount configuration when you create a Sandbox, see Mount AgenticFS dynamically. To reference a volume by name, see Mount an AgenticFS Volume, which also describes the image requirements of the second-generation runtime.
When you mount AgenticFS, Agent Sandbox obtains Security Token Service (STS) temporary credentials through the RAM role. The effective permissions cannot exceed the authorization scope of the RAM role. The permission boundary of AgenticFS is determined by the Access Point. A remote subdirectory under the Access Point only specifies the mount location and cannot replace the permission isolation that the Access Point provides.
API operation and parameters
POST /sandboxes/{sandboxID}/fc-volume-mounts
The request headers must include X-API-Key and Content-Type: application/json. If the call succeeds, the API returns 204 No Content, with an empty response body.
The request body supports a direct mount configuration, references to existing volumes, or both in a single request:
|
Field |
Type |
Required |
Description |
|
|
Object |
Provide at least one of this field and |
Specifies the AgenticFS mount configuration directly. For the fields, see the following table. |
|
|
Object array |
Provide at least one of this field and |
References existing volumes by name. |
|
|
String |
Required if you reference a volume. |
The name of a volume in the same team. Volume IDs are not supported. |
|
|
String |
Required if you reference a volume. |
The local mount directory in the Sandbox. |
The request must contain at least one valid mount point. The mount configuration in an append request is a JSON object, instead of the metadata parameter or a JSON string used when you create a Sandbox. Note the letter case: The metadata key used at creation is fc.sandbox.storage.agenticfs, but the field in an append request is agenticFS.
AgenticFS mount parameters
The following fields are in inlineVolumeMounts.agenticFS. If you specify the configuration directly, configure the fields as described in the following table:
|
Field |
Type |
Required |
Description |
|
|
Integer |
No |
The valid values range from |
|
|
Integer |
No |
The valid values range from |
|
|
Object array |
Yes |
The list of AgenticFS mount points in this request. The list contains 1 to 5 mount points. The total number of existing and new AgenticFS mount points cannot exceed 5. |
|
|
String |
Yes |
The address of the Access Point, which can be up to 128 characters in length. A remote subdirectory under the Access Point can be specified after |
|
|
String |
Yes |
The local mount directory in the Sandbox, which can be up to 128 characters in length. The directory must meet the requirements described in Limits. |
Local mount directory
mountDir and namedVolumeMounts[].path both specify the local mount directory in the Sandbox. Configure them separately from the remote directory in the Access Point address. Use a subdirectory of /home, /mnt, /tmp, or /data. For information about the directory limits, see Limits.
Install the SDK
The example uses httpx to call the append mount operation. After the call succeeds, the example uses the E2B SDK to connect to the existing Sandbox and verify file read and write operations.
pip install e2b==2.31.0 httpx
Environment variables
|
Environment variable |
Purpose |
Source or value |
|
|
The API key used to call the Agent Sandbox API operations. |
Obtain the key in the Agent Sandbox console and use the API key of the target team. |
|
|
The endpoint of the Agent Sandbox E2B API. |
|
|
|
The domain that the SDK uses to access the Sandbox. |
|
|
|
The ID of the Sandbox that receives the append mount request. |
Obtain the ID from the Sandbox creation response or from the Sandbox list. |
|
|
The address of the Access Point and the remote directory that you want to mount. |
Obtain the address of the Access Point in the NAS console and specify a directory under the Access Point after |
AGENTICFS_SERVER_ADDR is specific to the storage type and is used only when you specify the mount configuration directly. If you reference an existing volume, you do not need to set this variable.
Append mount examples
Set the connection information in your local terminal and replace the placeholders with actual values:
export E2B_API_KEY="<YOUR-E2B-API-KEY>"
export E2B_API_URL="https://api.<REGION>.sandbox.aliyuncs.com"
export E2B_DOMAIN="<REGION>.sandbox.aliyuncs.com"
export SANDBOX_ID="<SANDBOX-ID>"
The following code runs on your local machine and accesses files in the Sandbox through the SDK. The example creates a separate test file with a random identifier, writes data to the file, reads the file for verification, deletes the file, and retains the Sandbox. Use a mount configuration that provides read and write permissions. If the mount allows only read operations, modify the verification code as described in Verify the mount.
Sandbox.connect() updates the timeout of the Sandbox. The example uses timeout=300 to set the timeout to 300 seconds after the connection is established. Adjust the value based on your task.
Select one of the following methods, or combine both methods in a single request:
-
Specify the mount configuration directly: provide the AgenticFS mount parameters in
inlineVolumeMounts.agenticFSof the request body. -
Reference an existing volume: reference a volume in the same team by name in
namedVolumeMountsof the request body.
Specify the mount configuration directly
The following example appends the directory specified in the Access Point address to /mnt/agenticfs and verifies read and write operations. Make sure that the RAM role and the directory permissions allow read and write operations.
export AGENTICFS_SERVER_ADDR="ap-<ACCESS-POINT-ID>.<FILE-SYSTEM-ID>-<SUFFIX>.<REGION>.nas.aliyuncs.com:/"
Save the following code as append_agenticfs.py. Before you run the code, make sure that mount_dir is not used by an existing mount:
import os
from uuid import uuid4
import httpx
from e2b import Sandbox
def require_env(name: str) -> str:
value = os.environ.get(name, "").strip()
if not value:
raise RuntimeError(f"Missing environment variable: {name}")
return value
def verify_read_write(sandbox: Sandbox, mount_dir: str) -> None:
marker_path = f"{mount_dir}/mount-check-{uuid4().hex}.txt"
expected = f"append mount check {uuid4().hex}\n"
sandbox.files.write(marker_path, expected)
try:
content = sandbox.files.read(marker_path)
if content != expected:
raise RuntimeError(f"File content verification failed: {marker_path}")
finally:
sandbox.files.remove(marker_path)
print(f"Read/write verification passed. Test file deleted: {mount_dir}")
api_key = require_env("E2B_API_KEY")
api_url = require_env("E2B_API_URL").rstrip("/")
domain = require_env("E2B_DOMAIN")
sandbox_id = require_env("SANDBOX_ID")
mount_dir = "/mnt/agenticfs"
payload = {
"inlineVolumeMounts": {
"agenticFS": {
"mountPoints": [{
"serverAddr": require_env("AGENTICFS_SERVER_ADDR"),
"mountDir": mount_dir,
}],
},
},
}
response = httpx.post(
f"{api_url}/sandboxes/{sandbox_id}/fc-volume-mounts",
headers={"X-API-Key": api_key},
json=payload,
timeout=120.0,
)
if response.status_code != 204:
raise RuntimeError(f"Append mount failed: HTTP {response.status_code}, {response.text}")
sandbox = Sandbox.connect(
sandbox_id,
timeout=300,
api_key=api_key,
api_url=api_url,
domain=domain,
)
verify_read_write(sandbox, mount_dir)
Run the example:
python append_agenticfs.py
The example does not set userID or groupID. The UID or GID of a new mount cannot conflict with the existing configuration of the current Sandbox. This requirement also applies to an append mount that references a volume by name. For information about how to configure a remote subdirectory, see Mount AgenticFS dynamically.
Reference an existing volume
If an AgenticFS volume already exists, replace the payload definition in the preceding script with the following content before the first run, and keep the rest of the code unchanged. Replace name with the name of a volume in the same team. The volume must allow read and write operations for the verification to pass.
payload = {
"namedVolumeMounts": [{
"name": "agenticfs-workspace",
"path": mount_dir,
}],
}
Select one of the two preceding methods for a single run. You cannot append to the same mount directory twice. If the mount succeeds but the verification fails, run only the connection and verification code again. Do not submit the append request again.
If you combine a direct configuration and a volume reference, put both configurations in the same request body and specify a different local mount directory for each mount point. For the complete procedure and the multi-volume examples that reference volumes by name, see Append a volume mount.
Verify the mount
The example connects to the Sandbox and verifies file read and write operations only after the API returns 204. The output "Read/write verification passed. Test file deleted" indicates that the write operation, the content comparison, and the deletion are complete.
If the mount allows only read operations, verify read operations only. Before the first run, replace verify_read_write(sandbox, mount_dir) at the end of the example with the following code. Then replace <EXISTING-FILE> with the relative path of a file that already exists in the mount directory.
file_path = f"{mount_dir}/<EXISTING-FILE>"
content = sandbox.files.read(file_path, format="bytes")
print(f"Read succeeded: {file_path}, {len(content)} bytes")
Mounts that reference a volume can also be queried through the SDK after the connection succeeds:
print(sandbox.get_info().volume_mounts)
In the SDK, the volume_mounts field corresponds to the GET /sandboxes/{sandboxID} response, where the field is named volumeMounts. Mounts that use a direct configuration do not appear in this field and must be verified through file access. The existence of a directory does not mean that data access works.
Behavior notes
Releasing a Sandbox does not delete the data in AgenticFS. Clean up test files and task data separately in the storage service or through the mount directory.
Limits
-
The local mount directory must be a normalized absolute Unix path. It cannot be
/, and it cannot contain leading or trailing spaces,.,.., or repeated path separators. -
The local mount directory cannot be a system directory or a subdirectory of one, such as
/bin,/opt,/var,/dev, and cannot contain a hidden directory such as.cache. To access data through a hidden directory, mount the storage to a directory that meets the requirements and then create a symbolic link that points to the mount directory. -
Local mount directories cannot be duplicated in the same Sandbox, including mount directories of different storage types.
-
The operation only adds mounts. It does not unmount or replace existing mounts. To remove an existing mount, release and recreate the Sandbox. Omitting an existing mount in a request does not delete it, and submitting the same mount again returns
400.WarningReleasing a Sandbox terminates it. Files that are not stored in AgenticFS and tasks that are running in the Sandbox are lost and cannot be recovered. The replacement Sandbox has a new ID, so
SANDBOX_IDand any related client configuration must be updated. The data in AgenticFS is not deleted, but it is not cleaned up automatically. For more information, see Behavior notes. -
The total number of existing and new AgenticFS mount points cannot exceed 5. Do not count only the mount points in this request.
-
Do not concurrently modify the mounts of the same Sandbox.
FAQ
Why is the request rejected by the API key policy?
If the error message is request is not allowed by API key policy, check whether the API key policy allows the mount method and the storage type of this request. For more information, see Manage API keys. This type of rejection occurs at the API authorization stage. Adjusting the RAM role of the storage does not resolve it.
Why does the system report that the volume cannot be found when I mount by name?
Check the volume name in the request, the team that owns the API key, and the region of the API endpoint. Make sure that you use the name of a volume in the same team instead of a volume ID. For more information, see Append a volume mount.
Why does the system report that the volume is unavailable when I mount by name?
Query the status and the status reason of the volume by using GetVolume. Mount the volume only after you confirm that it is available. If a failure reason exists, resolve it first. For more information, see Append a volume mount.
Why does the append mount report that the Sandbox is not running?
If the error message is sandbox must be running, confirm that the target Sandbox is in the running state. If the Sandbox is paused, resume it first. If the Sandbox is released, recreate it.
Why does the append mount report a missing RAM role?
If the error message contains FC Function execution Role is required, the current Sandbox is not configured with the required RAM role. The append mount operation uses the current role and does not set the role for the Sandbox from the mountConfig.role of the new volume.
Prepare a role that has the access permissions on the target storage, and configure the role when you recreate the Sandbox. For more information, see Configure a RAM role.
Why does the append mount report an incomplete VPC configuration for the Sandbox?
If the error message contains FC Function complete VPC configuration is required, the missing configuration belongs to the current Sandbox. The mountConfig.vpcConfig in the append request or of a new volume does not complete it.
When you recreate the Sandbox, you must provide a complete VPC configuration that includes vpcId, securityGroupId, and a non-empty vSwitchIds. When you create a Sandbox, provide these values by using metadata, or use the VPC configuration that the referenced volume stores.
Why does the append mount report a UID or GID conflict?
If the error message contains requested storage UID/GID conflicts with the active FC Session, the UID or GID specified for the new mount conflicts with the existing configuration of the current Sandbox.
If you specify the configuration directly, check inlineVolumeMounts.agenticFS.userID and groupID. If you reference a volume, check the UID and GID configuration of the volume. Use a configuration compatible with the current Sandbox. If you need a different identity configuration, create another Sandbox. For more information about the impact of releasing and recreating a Sandbox, see Limits.
Why does the append mount report a duplicate mount directory?
If the error message contains duplicate mount path or duplicate mount dir, check whether the local mount directories in this request are duplicated, and whether a directory is already used by another mount in the Sandbox. Different storage types cannot share the same local mount directory.
Do not submit existing mounts again. Use an unused directory for the new mount. The append mount operation cannot overwrite or replace existing mounts.
Why is the mount limit exceeded when I append only one mount point?
The number of mounts is calculated from the existing mounts of the Sandbox and the new mounts in this request. Both mounts that specify the configuration directly and mounts that reference volumes are counted. Do not check only the number of mounts in this request.
Check the number of mounts for the corresponding storage type as described in Limits of this topic. If the limit is reached, mount the new storage in another Sandbox. Changing the local mount directory does not reduce the number of existing mounts.
If the issue persists, or if the API reports that the service is temporarily unavailable, retain the complete error message and the request ID, and contact technical support.