Expand description
bundle.export_for_agent / bundle.export_for_agent_with_history: build an
ABF from a live agent definition, optionally with its session history under
the size budgets defined here.
Structs§
- Bundle
Export 🔒With History Response - Response for
bundle.export_for_agent_with_history, which always zips. - Export
ForAgent 🔒Req bundle.export_for_agent— ABF v0.2 §2.3. The only export path that carries native memory: pulls a bundle’s normal components (identical tobundle.export) plus a snapshot of ONE agent’sdb_agent_native_memoryrows, refreshed from the live filesystem first (see [native_memory_handlers::refresh_memory_mirror_from_live_fs]’s doc comment for why that refresh is required, not optional).bundle. exportstays agent-less and memory-less — bundles are reusable across many agents by design, so memory (inherently per-agent) needs its own, explicitly-scoped entry point rather than an implicit “whichever agent happens to be attached” guess.- Export
ForAgent 🔒With History Req
Constants§
- MAX_
HISTORY_ 🔒SESSION_ FILE_ SIZE_ BYTES - Per-transcript size ceiling for
bundle.export_for_agent_with_history. reagentx P1 on PR #2613: reading every session fully into aStringwith no bound could exhaust server memory for the multi-GB histories this feature exists to migrate. UnlikeMAX_ABF_FILE_SIZE_BYTES(context files, truncated with a warning when oversized — fine, since a partial context file is still useful), a transcript is skipped ENTIRELY rather than truncated: JSONL requires whole lines, and a truncated mid-record file could fail to parse (or silently misparse) on the receiving end, which is worse than the session being visibly absent with a warning explaining why. - MAX_
TOTAL_ 🔒HISTORY_ BYTES - Aggregate ceiling across every session included in one
bundle.export_for_agent_with_historycall. reagentx P1, third review round: a per-file cap alone doesn’t bound an agent with many sessions each just under it — this is the analogous total cap the sibling import path already enforces (MAX_TOTAL_UNCOMPRESSED_BYTES,bundle_import.rs), sized larger since export’s job is specifically to carry as much real history as reasonably fits, not to validate a small hand-authored bundle. Sessions are processed insessions_for_agent’s existingmodified_at descorder, so hitting this cap keeps the most recent conversations and cuts off the oldest — the same priority a human moving “my history” to a new machine would want. Unlike import’s reject-the-whole-thing-on-overflow behavior, export keeps its existing best-effort philosophy: stop including further sessions and say so in a warning, never fail the call outright.
Functions§
- build_
export_ 🔒for_ agent bundle.export_for_agent— ABF v0.2 §2.3. The only export path that carries native memory: pulls a bundle’s normal components (identical tobundle.export) plus a snapshot of ONE agent’sdb_agent_native_memoryrows, refreshed from the live filesystem first (see [native_memory_handlers::refresh_memory_mirror_from_live_fs]’s doc comment for why that refresh is required, not optional).bundle. exportstays agent-less and memory-less — bundles are reusable across many agents by design, so memory (inherently per-agent) needs its own, explicitly-scoped entry point rather than an implicit “whichever agent happens to be attached” guess. Extracted from the RPC closure into a directly-callable, directly-testable function, matchingbundle_import_preview_impl’s pattern. Shared bybundle_export_for_agent_implandbundle_export_for_agent_with_history_impl: resolve the bundle + agent, build the baseBundleExport, splice in native memory. Returns the export, the resolved agent (the history variant needs its id), combined warnings, and missing skill ids. Everything after this point (whether to zip, whether to also append history files) is caller-specific.- bundle_
export_ 🔒for_ agent_ impl - bundle_
export_ 🔒for_ agent_ with_ history_ impl bundle.export_for_agent_with_history—docs/specs/SPEC_AGENT_IDENTITY_HISTORY_PERSISTENCE_PROTOCOL_2026_08_16.md§3.3. Deliberately a SEPARATE, explicit, opt-in action frombundle.export_for_agent— seeCOMMAND_BUNDLE_EXPORT_FOR_AGENT_WITH_HISTORY’s doc comment for why conversation transcripts must never ride along in the default (shareable, reusable-across-agents) bundle export. Builds the identical base export, then appends every sessionHistoryService::sessions_for_agentfinds for this agent underhistory/<provider>/<session_id>.jsonl. Always returns a zip — a multi-file, potentially large archive has no sensible inline-JSON shape, unlike the plain export’s optional format. A transcript that fails to read (deleted, permission issue, or overMAX_HISTORY_SESSION_FILE_SIZE_BYTES) is warned about and skipped, never fails the whole export — same best-effort philosophy as the memory-splicing step above.- register_
bundle_ 🔒export_ for_ agent - register_
bundle_ 🔒export_ for_ agent_ with_ history - sessions_
within_ 🔒total_ budget - Given per-session sizes already in priority order (most-recent-first,
matching
sessions_for_agent’smodified_at descsort), decide how many fit withintotal_cap. Returns(count_included, stopped_at_cap). Pure — no I/O — deliberately extracted so this decision is testable with tiny numbers instead of needing realMAX_TOTAL_HISTORY_BYTES- scale files on disk.