Skip to content

Commit e256af0

Browse files
dvdksnclaude
andcommitted
Document memory blocks in mixin kits
The kits doc described `memory:` only as part of agent kits, but mixin kits also support it. When several kits with memory load together, each kit's content lands in its own `kits-memory/<kit>.md` file and the main memory file gets a `## Kits` index pointing to them — a layout that lets the agent lazy-read kit-specific guidance instead of carrying every kit's memory on every turn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 58199af commit e256af0

1 file changed

Lines changed: 64 additions & 18 deletions

File tree

  • content/manuals/ai/sandboxes/customize

content/manuals/ai/sandboxes/customize/kits.md

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ A kit packages a set of capabilities a sandbox can use, such as:
2121
- Domains to allow
2222
- Files to drop in
2323
- Startup commands to run
24+
- Memory instructions to give the agent
2425

2526
You declare these in a single `spec.yaml` file, point the CLI at the
2627
directory (or a ZIP, OCI artifact, or Git URL), and the sandbox applies
@@ -166,6 +167,40 @@ See [Credentials](../security/credentials.md) for how to provide the
166167
credential value on your host, other approaches for cases the example
167168
above doesn't fit, and what the proxy does at request time.
168169

170+
### Inject agent memory
171+
172+
A kit can append content to the agent's memory file, such as `CLAUDE.md`
173+
or `AGENTS.md`. The agent reads this file at startup. Use it to give
174+
the agent project conventions, usage tips for a tool the kit installs,
175+
or other guidance that should be in scope when the sandbox runs.
176+
177+
```yaml
178+
memory: |
179+
Ruff is installed. Run `ruff check` before committing.
180+
Shared config lives at `/workspace/ruff.toml`.
181+
```
182+
183+
Both mixin and agent kits can declare `memory:`. The content is written
184+
only when the active agent kit sets [`agent.aiFilename`](#agent-block),
185+
which determines the memory file's name.
186+
187+
When more than one loaded kit declares a `memory:` block, each kit's
188+
content is written to its own `<kit-name>.md` file under a sibling
189+
`kits-memory/` directory. The main memory file gets a `## Kits` section
190+
that points to each kit file:
191+
192+
```text
193+
/Users/you/
194+
├── myproject/ # workspace
195+
├── AGENTS.md # main memory file with a "## Kits" index
196+
└── kits-memory/
197+
├── ruff-lint.md
198+
├── vale.md
199+
└── git-ssh-sign.md
200+
```
201+
202+
See [`memory`](#memory) in the spec reference for the full field schema.
203+
169204
### Define an agent
170205

171206
Agent kits declare an `agent:` block with the image the agent runs in and
@@ -551,6 +586,35 @@ Parent directories are created automatically. Existing files are
551586
overwritten. Absolute paths and path-traversal sequences (`../../`) are
552587
rejected.
553588

589+
### Memory
590+
591+
```yaml
592+
memory: |
593+
<markdown>
594+
```
595+
596+
Top-level field. Available in both mixin and agent kits. Markdown
597+
appended to the agent's memory file at sandbox creation. The agent reads
598+
this content at startup. Write it as instructions or notes the agent
599+
should follow when working in the sandbox. Applied only when the active
600+
agent kit sets [`agent.aiFilename`](#agent-block).
601+
602+
The file is written to the parent of the workspace path inside the
603+
sandbox, not to the workspace itself. For a workspace mounted at
604+
`/Users/you/myproject`, the memory file lands at
605+
`/Users/you/AGENTS.md` (or whatever `aiFilename` is set to). It exists
606+
only inside the sandbox. Nothing is written to the host.
607+
608+
When several loaded kits declare `memory:` blocks, the content is split
609+
across files instead of being concatenated into the main one:
610+
611+
- Each kit's memory is written to `<kit-name>.md` in a sibling
612+
`kits-memory/` directory next to the main memory file.
613+
- The main memory file gets a `## Kits` section listing every kit with
614+
a pointer to its file. The section is delimited by
615+
`<!-- sbx:kits-section start -->` and `<!-- sbx:kits-section end -->`
616+
markers so it can be regenerated when kits are added or removed.
617+
554618
### Agent block
555619

556620
Required for `kind: agent`.
@@ -587,24 +651,6 @@ The agent's container image must provide:
587651
Build on top of `docker/sandbox-templates:shell-docker` to get these for
588652
free.
589653

590-
#### Memory
591-
592-
```yaml
593-
memory: |
594-
<markdown>
595-
```
596-
597-
Top-level field. Markdown appended to the agent's memory file at sandbox
598-
creation. The agent reads this content at startup, so write it as
599-
instructions or notes the agent should follow when working in the
600-
sandbox. Applied only when `agent.aiFilename` is set.
601-
602-
The file is written to the parent of the workspace path inside the
603-
sandbox, not to the workspace itself. For a workspace mounted at
604-
`/Users/you/myproject`, the memory file lands at
605-
`/Users/you/AGENTS.md` (or whatever `aiFilename` is set to). It exists
606-
only inside the sandbox — nothing is written to the host.
607-
608654
## Debugging
609655

610656
When a kit doesn't behave as expected, start with the network policy log

0 commit comments

Comments
 (0)