Skip to content
DocsAll docs
Console

Agentic workflows – Volumes

Let an AI agent take snapshots, clone and restore workspaces and environments, and delete snapshots and volumes.

Last updated

On this page

Description and operation

General

An agent saves and recovers work with the snapshot, clone and restore tools. The platform chapter Volumes explains the volume, its lineage and its snapshots. This page gives the tool call for each task.

Four rules are specific to an agent:

  • The history, refs and delete tools take the id of a volume, never its name. Read the id from volume_list, or from the volume field of the workspace or the environment.
  • The first push of a volume must give volume, its name. Each later push is a version. Restore and clone take snapshot_id as a reference: name, name@N or a snapshot id. See Names and versions.
  • A push, a clone and a restore return 202 at once. The agent polls the phase in the history, or the state of the new workspace or environment.
  • When env_restore answers 409 with lost, the agent names the services in discard only after the developer accepts the loss.

An agent clones to try a change on a copy, and deletes the copy when it is done.

Tasks

Take a snapshot of a workspace

Reason for the task: Save the state of a workspace in a snapshot.

Job set-up

Procedure

  1. Push a snapshot with a note in message. Add the volume name in volume for the first push.

    AI agent
    {"tool": "workspace_snapshot", "arguments": {"workspace": "ws-0a1b2c3d4e5f6a7b", "message": "before the refactor", "volume": "backend-base"}}

Close-out

  1. Show the history, as in task 003. Wait until the first row shows your note and the phase ready.

The same task with the SDK or CLI: Snapshots task 001.

Take a snapshot of an environment

Reason for the task: Save the services and the data of an environment in a snapshot.

Job set-up

Procedure

  1. Push a snapshot with a note in message. Add the volume name in volume for the first push.

    AI agent
    {"tool": "env_snapshot", "arguments": {"env": "env-1f2e3d4c5b6a7988", "message": "before the schema change", "volume": "dev-data"}}

Close-out

  1. Show the history, as in task 003. Wait until the first row shows your note and the phase ready.

The same task with the SDK or CLI: Snapshots task 002.

Show the snapshot history

Reason for the task: Find the snapshots of a workspace or an environment and their ids.

Job set-up

Procedure

  1. Show the lineage, tip first.

    AI agent
    {"tool": "volume_history", "arguments": {"volume": "ws-0a1b2c3d4e5f6a7b"}}
  2. Show the tip, main. A clone or a restore uses it by default.

    AI agent
    {"tool": "volume_refs", "arguments": {"volume": "ws-0a1b2c3d4e5f6a7b"}}

Close-out

  1. Write down the id of the snapshot for a restore, a clone or a delete.

The same task with the SDK or CLI: Lineage task 001.

Delete a snapshot

Reason for the task: Remove a snapshot that you do not need.

Job set-up

WARNING

The deletion is immediate and final. If it is the last snapshot of a volume that nothing uses, the volume and its data are deleted too.

Procedure

  1. Delete the snapshot. Use the id from the history for snapshot.

    AI agent
    {"tool": "snapshot_delete", "arguments": {"volume": "ws-0a1b2c3d4e5f6a7b", "snapshot": "ws-0a1b2c3d4e5f6a7b-8a7b6c91"}}

Close-out

  1. Show the history. The id is gone, or the call returns 404 if the volume went with it.

The same task with the SDK or CLI: Lineage task 004.

Clone a workspace

Reason for the task: Make a new workspace that starts with a copy of the files of a workspace.

Job set-up

Procedure

  1. Clone the workspace. Use a free name for name.

    AI agent
    {"tool": "workspace_clone", "arguments": {"workspace": "ws-0a1b2c3d4e5f6a7b", "name": "api-experiment", "task": "try the new parser"}}

Close-out

  1. Make sure that interrupted is false, then wait until the new workspace is ready.

The same task with the SDK or CLI: Workspaces task 008.

Clone an environment

Reason for the task: Make a new environment from the present state of an environment, or from one of its snapshots.

Job set-up

Procedure

  1. Clone the present state of the environment. Use a plain name for name.

    AI agent
    {"tool": "env_clone", "arguments": {"env": "env-1f2e3d4c5b6a7988", "name": "dev-copy"}}
  2. Give the id of a snapshot in snapshot_id to clone that snapshot. See Show the snapshot history.

    AI agent
    {"tool": "env_clone", "arguments": {"env": "env-1f2e3d4c5b6a7988", "name": "dev-before-migration", "snapshot_id": "env-1f2e3d4c5b6a7988-8a7b6c91"}}

Close-out

  1. Wait until the state of the new environment is running, then check its services.

The same task with the SDK or CLI: Environments task 008.

Restore a workspace from a snapshot

Reason for the task: Make a new workspace from the state that a snapshot froze.

Job set-up

Procedure

  1. Restore the workspace. Use the id for snapshot_id, and a free name for name.

    AI agent
    {"tool": "workspace_restore", "arguments": {"name": "api-restored", "snapshot_id": "ws-0a1b2c3d4e5f6a7b-8a7b6c91"}}
  2. Add image, packages or quota_gb to the same call to override a value.

    AI agent
    {"tool": "workspace_restore", "arguments": {"name": "api-restored", "snapshot_id": "ws-0a1b2c3d4e5f6a7b-8a7b6c91", "quota_gb": 40}}

Close-out

  1. Wait until the new workspace is ready, then check its packages.

The same task with the SDK or CLI: Workspaces task 009.

Restore an environment from a snapshot

Reason for the task: Put an environment back to the services and the data of one of its snapshots.

Job set-up

WARNING

The restore replaces the present data of the environment with the data of the snapshot. Take a snapshot first to keep the present state.

Procedure

  1. Restore the environment. Use the id of the snapshot for snapshot_id.

    AI agent
    {"tool": "env_restore", "arguments": {"env": "env-1f2e3d4c5b6a7988", "snapshot_id": "env-1f2e3d4c5b6a7988-8a7b6c91"}}
  2. If the call returns 409 with a list lost, restore again and name those services in discard.

    AI agent
    {"tool": "env_restore", "arguments": {"env": "env-1f2e3d4c5b6a7988", "snapshot_id": "env-1f2e3d4c5b6a7988-8a7b6c91", "discard": ["redis"]}}

Close-out

  1. Read rolled_back, added, removed and discarded in the answer. Wait until the state is running.

The same task with the SDK or CLI: Environments task 009.

Show the volumes

Reason for the task: Find the volumes that hold your snapshots, and which of them nothing uses.

Job set-up

Procedure

  1. Show the volumes. Use kind and owner to filter the list.

    AI agent
    {"tool": "volume_list", "arguments": {"kind": "environment", "owner": "acme"}}

Close-out

  1. Write down the id of the volume. Where deleted is true, nothing uses it.

The same task with the SDK or CLI: Volumes task 001.

Delete a volume

Reason for the task: Remove a detached volume and all its snapshots to free disk.

Job set-up

WARNING

The platform deletes the volume and all its snapshots at once. You cannot restore from them afterwards.

Procedure

  1. Delete the volume. Use its id.

    AI agent
    {"tool": "volume_delete", "arguments": {"volume": "env-1f2e3d4c5b6a7988"}}

Close-out

  1. Show the volumes. The deleted name is gone.

The same task with the SDK or CLI: Volumes task 002.

Troubleshooting

SymptomPossible causeCorrective action
409 with snapshots: 20 of 20 in use; request more under QuotaYou used all the snapshots of the quota. The numbers are examples.Delete a snapshot, or request more quota.
409 with a snapshot is already being cut for this workspaceAn earlier snapshot is still in progress.Wait until its phase is ready, then take the snapshot again.
409 with a sync point cannot be deleted by handThe id is not a snapshot.Show the history and use an id from it.
409 with this snapshot is the base of a running worktreeA workspace or an environment is based on this snapshot.Stop or delete it, or delete a different snapshot.
422 with volume: this volume has no name yet; name it on its first pushThe volume has no name, and the push gave no volume.Push again with volume.
409 with volume go-base already exists; delete it firstAnother volume of the owner has this name.Use a different name, or delete the other volume.
409 with volume go-base is used by pipeline buildA pipeline or a run reads the volume.Wait for the run, or change the pipeline. See Delete rules.
409 with a list lost when an environment is restoredThe restore removes services that hold data.Restore again and name those services in discard.
409 with the volume still has a workspace or environmentA workspace or an environment uses the volume.Delete it, or delete a snapshot instead.
404 with not foundThe volume does not exist or is not yours.Use an id from the list.