Session attachments and history summaries
analyze_image reads and normalizes an image through the sandbox, then stores an immutable JPEG snapshot through the current Run’s SessionStore. The ledger keeps a sage-image:<sha256> reference. Inference loads pixels from that snapshot; summarization uses an attachment marker. Changing the original path cannot change a stored image. Legacy data URLs remain readable, with image bytes excluded from summary projections.
SessionArtifactStore is the internal Run-bound ArtifactStore view published by the Session storage plugin alongside session.store and derived-state.store; it is not separately registered or configured. The selected session plugin controls authorization, durability, and lifecycle. Generic artifact.store remains available for other outputs. Custom session plugins must implement attachments; unsupported plugins return session.attachments_unsupported without silently selecting separate storage.
- Ephemeral stores retain bytes in memory only.
- Filesystem stores keep immutable binary files under the owning session’s
attachments/directory. Files become durable before the manifest commits. Unreferenced files left by an interrupted write are reclaimed with the session. A complete directory backup includes descendants and attachments. - MySQL stores bytes in an attachment table under the same database and table prefix. Bytes and the session manifest commit in one transaction; session deletion cascades through foreign keys. No new SQLite storage is introduced.
Runs within a session share its attachments. Forks inherit snapshots. Before using a reference in another session, call copy_attachment(source_session_id, target_session_id, artifact_id, context=...). Both owners are authorized and the destination receives its own snapshot, which survives source deletion. Individual attachments cannot be deleted while their session exists, preserving historical replay.
export_session_backup(session_id, context=...) exports canonical session state, fork descendants, and attachments. Only this explicit portable backup encodes binary bytes as base64; regular messages and state snapshots do not. restore_session_backup(backup, context=...) validates ownership, tree structure, manifests, sizes, and checksums, and rejects conflicting destination state or identities owned by other sessions. Restoration commits each session atomically, ancestors first. The whole tree is not a single transaction. Retrying the same backup skips identical completed sessions, allowing recovery after interruption. Pause destination execution during restoration. Internal export_state/load_state debugging snapshots do not replace the attachment-inclusive backup API. Derived summary caches are rebuildable and excluded from authoritative backups.
Actual tool execution and the canonical ledger remain unchanged. When a tool group exceeds the summary source budget, only its summary projection splits into records carrying call IDs. Large individual results split further; small fragments pack into bounded requests. Original message coverage advances after the entire group completes. Provider failure or insufficient summary-call budget cannot mark unprocessed fragments as covered. This handles oversized tool groups producing context.summary_source_too_large; provider network failures, 502 responses, and empty summaries retain their existing error handling.