Expand description
Tool-output spill files: where they live and how they go away.
A tool result bigger than tool_output_spill_bytes is stored whole in
<base>/spill/<session>/<tool_use_id>.txt, and model history carries a
short head + tail preview that points at the file (the engine’s
runtime::tool_spill). <session> is the persisted conversation id for
a foreground session and the runtime trace session id for a worker.
Spill files are a cache of output the model already saw a preview of, so they are disposable. They go away two ways:
- with their session: retention (
crate::retention) removes<base>/spill/<id>/when it deletes or forgets session<id>; - by age:
sweep_stale_spillruns at startup, like the trace content-capture sweep, and removes session dirs nothing has written to forSPILL_MAX_AGE. Worker dirs have no session file, so this is what removes them.
Every directory is 0700 and every file 0600 (spec §5.4).
Structs§
- Spill
Removal - What a removal freed: spill-root entries (session dirs, strays), the regular files inside them, and their bytes.
Constants§
- SPILL_
DIR_ NAME - Name of the spill root under the Synaps base dir.
- SPILL_
MAX_ AGE - A session spill dir nothing has written to for this long is removed by
sweep_stale_spill. A week covers a session resumed after a weekend; past that the preview in history is what remains (the pointer goes dead, and areadof it says so).
Functions§
- default_
spill_ root <base>/spill, resolved through the base-dir helper (crate::config::base_dir, which honoursSYNAPS_BASE_DIR). Callers bind this ONCE at construction, like the capture dir.- remove_
session_ spill - Remove session
session_id’s spill dir underroot. Idempotent: a missing dir isOkwith nothing freed. An id that is not a safe path component is a no-op (nothing could have been written for it). A symlink planted at the dir’s path is removed as a link, never followed. - session_
component idwhen it is safe as ONE path component: 1-128 bytes of[A-Za-z0-9._-], and not.or... Session ids (20261029-143000-ab12) and runtime trace ids (session-<pid>-<ms>-<seq>) both qualify; anything else is refused rather than rewritten, so two different ids can never share a directory.- spill_
root <base>/spillfor an explicit base dir.- sweep_
stale_ spill - Startup sweep: remove every session dir under
rootwhose last write (dir mtime: creating a spill file updates it) is older thanmax_ageatnow, plus anything that is not a directory (nothing else lives here). Bounded, fail-soft and confined toroot’s own entries. A missing root is a no-op.