Security
What the SDK protects, what you must do yourself, and its known limits.
What the SDK does
| Area | Behavior | Control |
|---|---|---|
| API keys | A key is never sent to another vendor. A custom prefix needs its own key and address. Keys are not enumerable on errors. | apiKey, env |
| Request audit | Header names with key, token, secret, cookie or authorization, and values that look like credentials, are redacted. | captureRaw: "redacted" (default, no bodies), true (full bodies, for debugging), false |
| Local files | A local media path must resolve inside roots: in a prompt, in a loaded session, and in media a tool returns with toolContent. [] denies all. Unset means unrestricted. | fileAccess: { roots } |
| URLs | A media URL that the SDK downloads itself (for example audio, a picture a tool returns, or an input of generateImage, generateVideo, generateEmbedding or generateDecision) may not point to a private, loopback or link-local host, however it is written (an IPv4 address inside an IPv6 one too), including what DNS returns. A name whose address cannot be looked up is refused too. Redirects are re-checked and the size is capped. A link the provider fetches itself is sent as it is. For a file on your intranet, read it yourself and pass the bytes or base64. | Automatic |
| Tool errors | Stack frames are dropped. Absolute paths and URL credentials are removed. | redactError |
| Worker traces | Visible only to the agent that started the worker. Results are branded, so a tool cannot forge them. | Automatic |
| Sessions | The shape is checked on load. Files are created 0600 and folders 0700. | fileAccess |
Hardening checklist
- Set a finite
maxTurns, alimits.deadlineMsand abudget. - Set
fileAccess.roots. - Leave
captureRawat"redacted". - Make tools validate their own input and honor
ctx.signal. - Keep secrets out of
instructions. - Treat web content that a tool fetches as untrusted. It can try to give the model instructions.
- Log with
telemetryBus. - To require approval for a tool, use the
beforeToolhook, or ask insideexecuteand refuse withctx.stop(reason). See Tools.
Known limitations
The SDK is before version 1.0. Be aware of these:
- One process per session folder. A saved session is locked. A second process that opens the same session fails fast with a
ConfigError. A lock left by a killed process is taken over. Local disks only. See Sessions. - Durable writes. Files are written with
fsync, a.bakcopy and an atomic rename, so a crash or power cut never leaves a half-written file. Telemetry files are appended withoutfsync. - Scheduled actions run only while your process is alive, and only if the creating agent is still referenced. See Scheduled actions.
thinking.budgetTokensis accepted but not forwarded to any provider.- History is sent again each turn. Providers other than Google need the whole history on every call. With
persist.filethe whole snapshot is rewritten at each step. Withpersist.dira journal is appended instead. - Memory. An idle process that imported the SDK uses about 40 MB: Bun about 17 MB,
zodabout 10 MB and the SDK about 15 MB. The model catalog is read lazily and is small. 100 parallel streaming runs add about 17 MB at their peak.bun run benchmeasures both. The SDK is not yet tuned for very small hosts. - Reply size. The SDK stops reading a provider reply that is too large and cancels the connection: 64 MB for a chat reply, 256 MB for pictures, vectors and decision answers, 1 MB for an error body and 512 MB for a downloaded video. A reply over its cap is a
ProviderErrorthat is not retried. A misconfigured or hostile endpoint cannot fill the memory of a small host. - The address check resolves DNS before it calls
fetch, so a small DNS-rebinding window remains. - Local disk only. Network drives are not supported.