diff --git a/content/manuals/ai/sandboxes/agents/claude-code.md b/content/manuals/ai/sandboxes/agents/claude-code.md index 931a5d7f8429..14b29879df9c 100644 --- a/content/manuals/ai/sandboxes/agents/claude-code.md +++ b/content/manuals/ai/sandboxes/agents/claude-code.md @@ -33,6 +33,13 @@ prompt from a file with `-- "$(cat prompt.txt)"`. To create a [mountless sandbox](../usage.md#choose-a-workspace), use `sbx create` without a workspace path, then attach by name. +## Preserve conversations after sandbox removal + +To keep Claude Code conversations when you remove and recreate a local sandbox, +add its session mixin when creating the sandbox. See +[Preserve Claude Code and Codex conversations](../customize/use-kits.md#preserve-claude-code-and-codex-conversations) +for commands and steps to resume a conversation. + ## Authentication For the default Anthropic models, Claude Code requires either an Anthropic diff --git a/content/manuals/ai/sandboxes/agents/codex.md b/content/manuals/ai/sandboxes/agents/codex.md index da3e8d289a9e..ca97259c6bb3 100644 --- a/content/manuals/ai/sandboxes/agents/codex.md +++ b/content/manuals/ai/sandboxes/agents/codex.md @@ -32,6 +32,13 @@ $ sbx run codex To create a [mountless sandbox](../usage.md#choose-a-workspace), use `sbx create` without a workspace path, then attach by name. +## Preserve conversations after sandbox removal + +To keep Codex conversations when you remove and recreate a local sandbox, +add its session mixin when creating the sandbox. See +[Preserve Claude Code and Codex conversations](../customize/use-kits.md#preserve-claude-code-and-codex-conversations) +for commands and steps to resume a conversation. + ## Authentication For the default OpenAI models, `sbx run codex` prompts you to authenticate on diff --git a/content/manuals/ai/sandboxes/customize/use-kits.md b/content/manuals/ai/sandboxes/customize/use-kits.md index 1879ddc09fb0..ae9818f9bfd8 100644 --- a/content/manuals/ai/sandboxes/customize/use-kits.md +++ b/content/manuals/ai/sandboxes/customize/use-kits.md @@ -328,6 +328,43 @@ discarded when the sandbox stops. For how to preserve storage when changing a kit, see [Configure the volume](author/patterns.md#configure-the-volume). +### Preserve Claude Code and Codex conversations + +For local sandboxes, add a session mixin to keep conversations after removing +and recreating the sandbox, including when you use `--rm`. Choose the mixin +that matches your agent: + +{{< tabs >}} +{{< tab name="Claude Code" >}} + +```console +$ sbx run --rm docker.io/docker/sbx-kit-claude:2.1.267 \ + --kit sbx/claude-sessions:1.0.0 +``` + +{{< /tab >}} +{{< tab name="Codex" >}} + +```console +$ sbx run --rm docker.io/docker/sbx-kit-codex:0.155.1 \ + --kit sbx/codex-sessions:1.0.0 +``` + +{{< /tab >}} +{{< /tabs >}} + +Start a conversation, then enter `/exit`. Run the same command again from the +same project directory and enter `/resume` inside the agent to select the saved +conversation. + +The mixins use host directories managed by Docker Sandboxes to store session +state. They don't share conversations with Claude Code or Codex running directly +on your host. Include the session mixin each time you recreate the sandbox. + +To choose a host directory, see [Choose directories for kit host mounts](#choose-directories-for-kit-host-mounts). +The sandbox mount paths are `/home/agent/claude-history` for Claude Code and +`/home/agent/codex-history` for Codex. + ## Restrict kit sources [`kit.allowedSources`](../configuration/settings.md#kitallowedsources) controls