- MCP Server ToolsUpdated
- Managed MCP with chat()Updated
- Manual MCPUpdated
- MCP Type GenerationUpdated
- MCP Client InputUpdated
- MCP Server Tools: AdvancedNew
- MCP EventsNew
- MCP AppsUpdated
- Serve Tools over HTTPUpdated
- Serve Resources and PromptsUpdated
- Ask for InputUpdated
- Draft Text from a ToolUpdated
- MCP Server TasksUpdated
- MCP Server AuthUpdated
- MCP Server SessionsUpdated
- MCP Server on stdioUpdated
Persistence (Advanced)
- GenerationsUpdated
- Realtime Voice ChatUpdated
- Text-to-SpeechUpdated
- TranscriptionUpdated
- Transcription: AdvancedNew
- Voice CreationUpdated
- Audio RecordingUpdated
- Audio GenerationUpdated
- Image GenerationUpdated
- Image Generation: AdvancedNew
- Video GenerationUpdated
- Video Generation: AdvancedNew
- Live GenerationUpdated
- World GenerationUpdated
- Generation HooksUpdated
- Build your first harnessUpdated
- Host optionsNew
- Send and show mediaUpdated
- Connect clientsUpdated
- Write a client in any languageNew
- Access and tenantsNew
- Run in the terminalUpdated
- Deploy a harnessUpdated
- Send inputs safelyUpdated
- Run a tool without a model
- Durable sessionsUpdated
- Run background work on workersNew
- List, rename, and fork sessionsUpdated
- Lifecycle and retentionNew
- Run side effects onceUpdated
- Wait for a personNew
- Build on the session logUpdated
- Control how a turn endsUpdated
- Store settings per threadUpdated
- Compact a long sessionUpdated
- Fork and reset a threadUpdated
- One log for a session treeUpdated
- Write a pluginUpdated
- Track usage and costUpdated
- Ask before risky tool callsUpdated
- Give your agent coding toolsUpdated
- Sandbox and extend the coding toolsUpdated
- Run the coding tools for many threadsNew
- Undo a turnUpdated
- Build a coding agentUpdated
- Delegate to coding agentsUpdated
- Switch between agent profilesUpdated
- Auth and connectorsUpdated
- Share a thread between peopleUpdated
- Connect model providersUpdated
- Build your own UIUpdated
- Code mode in a harnessUpdated
- Work until a goal is metUpdated
- Run agents from a harnessUpdated
- Hand off a conversationNew
- Add skillsUpdated
- Use MCP serversUpdated
- Give your agent a computerNew
- Use from any MCP clientUpdated
- Use a harness from an editor (ACP)Updated
- OverviewUpdated
- Quick StartUpdated
- ProvidersUpdated
- HarnessesUpdated
- Harness AuthUpdated
- WorkspaceUpdated
- ToolsUpdated
- PolicyUpdated
- Lifecycle & SnapshotsUpdated
- Portable SnapshotsUpdated
- Keep Files After ReloadUpdated
- Save a Named VersionUpdated
- Branch From a VersionUpdated
- Send a Frozen FileUpdated
- Let the Agent Save and ForkUpdated
- Pick Which Files to KeepUpdated
- What a Snapshot StoresUpdated
- Instance DurabilityUpdated
- Durable RunsUpdated
- EventsUpdated
Sandboxes (Advanced)
- Runtime ContextUpdated
- Bring Your Own KeyUpdated
- Keep Keys on the ServerNew
- Debug LoggingUpdated
- Multimodal ContentUpdated
- Files APIUpdated
- Per-Model Type SafetyUpdated
- Runtime Adapter SwitchingUpdated
- Tree-ShakingUpdated
- Extend AdapterUpdated
- Extend Adapter: AdvancedNew
- Typed Pre-Configured OptionsUpdated
- Test with a Fake ModelUpdated
- Prompt CachingUpdated
- Mid-Conversation ChangesUpdated
- Approval Flow ProcessingUpdated
Save a Named Version
snapshots.save writes the live sandbox to a named checkpoint. Automatic saves still run at the end of each completed run.
The method needs a live, reusable sandbox for the thread. A lifecycle with reuse: 'none' cannot create a named checkpoint.
Keep this route on the server. Read the owner from the session. If the owner cannot access the thread, return 404. Then call snapshots.save.
When you create the snapshots object, bind sandbox and instances. You can also pass them on save. Use the same instance store that withSandbox uses. See Keep Files After Reload.
import { requireSession } from './auth'
import { snapshots } from './sandbox-server'
export async function POST(request: Request) {
const session = await requireSession(request)
let payload: unknown
try {
payload = await request.json()
} catch {
return new Response('Invalid request', { status: 400 })
}
if (
payload === null ||
typeof payload !== 'object' ||
!('threadId' in payload) ||
!('runId' in payload) ||
!('label' in payload) ||
typeof payload.threadId !== 'string' ||
typeof payload.runId !== 'string' ||
typeof payload.label !== 'string'
) {
return new Response('Invalid request', { status: 400 })
}
const threadId = payload.threadId
const runId = payload.runId
const label = payload.label
if (!(await session.canAccessThread(threadId))) {
return new Response('Not found', { status: 404 })
}
const checkpoint = await snapshots.save({
threadId,
runId,
label,
tenant: { userId: session.userId },
})
return Response.json({ checkpointId: checkpoint.id, label: checkpoint.label })
}The client sends its request to this route. It does not call snapshots.save or read the persistence stores.
export async function saveCheckpoint(
threadId: string,
runId: string,
label: string,
) {
const response = await fetch('/api/snapshots/save', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ threadId, runId, label }),
})
if (!response.ok) throw new Error('Could not save checkpoint')
return response.json()
}A named checkpoint stays available for a read or a selected fork. Automatic restore still uses the latest checkpoint. See Branch From a Version to copy one selected checkpoint into a new thread.
When the agent must call save itself, use Let the Agent Save and Fork.