Skip to main content
Isolation is already on. You do not need to configure it to follow the quickstart or use the SDK in an application. This page is for understanding defaults and deliberately changing them.

What happens automatically

When you use Agent, query(), or a locally spawned createAgentClient(), the SDK starts a runtime with temporary configuration and state directories. It does not automatically read your personal authentication files or agent configuration. A session’s settingSources is empty unless you choose otherwise. The high-level Agent and query() facade also disables title generation, language servers, and formatters by default. It hides the interactive question, todowrite, and skill tools unless your tool policy replaces those defaults. Other tools are subject to your selected tool list and permissions. See built-in tools.

Configuration isolation is not a tool sandbox

File, shell, and network tools run with the runtime process’s operating-system access. cwd selects a working directory; it does not create a filesystem security boundary. Your custom tool callbacks run inside your application process. Choose tool permissions for your workflow. If an application requires operating-system confinement, run it in a container or another sandbox you operate.

Supply credentials explicitly when needed

A supported key in your environment is sufficient for the quickstart. For a different variable name or an application-managed credential, pass spawn.auth:
Explicit spawn options give this Agent a dedicated runtime, so close() also stops that runtime. The example still uses the default isolated mode. spawn.passEnv forwards named host variables; spawn.env supplies explicit child values. Arbitrary *_API_KEY names and GITHUB_TOKEN are not automatically forwarded. Standard proxy variables and AWS_*, AZURE_*, GOOGLE_*, and OTEL_* have forwarding rules. See SpawnOptions for the options and reserved variables.

Deliberately use host configuration

Use this only when the agent is intended to behave like a tool running in your existing local environment. The following options are a configuration fragment to pass to new Agent():
These choices do different things: non-isolated spawn enables host configuration, settingSources selects discovered settings, and the preset chooses the coding-oriented system prompt. You do not need any of them for normal SDK use.

Choose the right state lifetime

A session ID can be resumed while its backing runtime and database remain available. Default isolated scratch is temporary, so keeping the ID alone does not preserve a conversation after runtime shutdown. For a service that needs longer-lived sessions, operate a persistent runtime and connect in remote mode. For cleanup behavior in a script or service, see lifecycle and cleanup. spawn.keepScratch: true preserves temporary state for debugging. It is not a persistence strategy. See troubleshooting before enabling it.