Expand description
An agent’s memory, delivered through Claude Code’s SessionStart hook
(docs/specs/SPEC_GLOBAL_MEMORY_DELIVERY_2026_09_27.md §7 P2).
The hook’s additionalContext reaches the model without showing as a
conversation turn — but, measured against the CLI AgentMux bundles
(2.1.280), only up to about 10,000 characters per hook command: past
that the CLI swaps it for a saved file plus a 2 KB preview, which the model
can’t reliably read. Several hook commands’ contexts are all delivered,
each under its own cap, in the order the hooks finish (they run in
parallel). So the memory is split into MAX_PART_CHARS parts, each
labelled “part N of M”, and HOOK_PARTS hook commands each ask for one.
This module is pure: composition, splitting and the source rules. The per-session cache, the acknowledgements and the notice live in the server handlers.
Personal Memory goes in as an index (index.rs), and the Global Memory the agent’s startup file already
carries is not sent again (SPEC_MEMORY_DELIVERY_INDEX_NOT_FULL_TEXT_2026_11_17.md).
Structs§
- Composed
- A composed delivery and where each item sits in it.
- Entry
- One memory entry: a Global Memory section as the startup file carries it, or one Personal Memory file.
- Item
Span - Where one item sits in a composed delivery, in characters (SPEC_CONTEXT_DELIVERY_2026_09_30 §3.4 step 3).
- Layout
- What a delivery carries besides the entries it sends in full: how much Global Memory the startup file
holds, the Personal Memory index, and a closing note (
memory::fit’s left-out note and pruning nudge).
Enums§
- Catch
UpKind - Which resume phase a catch-up turn follows.
- Delivered
- How much of one item a delivery carried.
- Fallback
Reason - Why the frontend’s fallback re-delivers memory
(
memory-reinjection.ts’sReinjectionReason). - Reason
- Why memory is being delivered — the
SessionStarthook’ssource, for the sources that get a delivery. - Startup
Carry - How much of the Global Memory the agent’s startup file already carries (SPEC_MEMORY_DELIVERY_INDEX_NOT_FULL_TEXT_2026_11_17.md §3.1). A file AgentMux wrote that holds a section byte for byte carries it; a section the file lacks, or holds in an older form, is newer than the file and is sent whole.
- Tier
- Whether an entry is Global Memory (Operator Config included) or the agent’s own Personal Memory.
Constants§
- CATCH_
UP_ SIGNATURE - What opens the catch-up block of a resume phase’s message, and what
is_hidden_reinjection_text(srv) and the stream parser (frontend) know the message by when it carries no memory. The block is AgentMux’s, not the user’s: the pane shows a card for it, never the text, but the agent’s reply is shown (SPEC_RESUME_PHASE_CATCH_UP_TURN_2026_10_13.md §3.3). - CATCH_
UP_ TAIL - The last words of the instruction, which end every catch-up block. The
frontend’s
isCatchUpMessagematches the block by them too. - COMPACTION_
CLAUSE - The sentence after the signature when a compaction caused the delivery:
one definition for the hook’s text, the fallback’s, and the check that
adds the running summary (
continuity_state). - HOOK_
PARTS - How many hook commands are installed, so the most a delivery can carry is
HOOK_PARTS * MAX_PART_CHARScharacters. A memory larger than that is cut at the end, and the last part says so. - MAX_
PART_ CHARS - The most characters one part carries. The measured per-hook cap is about 10,000; the margin covers the part label and any counting difference.
- REINJECTION_
SIGNATURE - The sentence every hidden memory re-delivery opens with, whatever the
reason: what
is_hidden_reinjection_text(srv) andisMemoryReinjectionMessage(frontend) recognise it by.
Functions§
- compose_
catch_ up - The message of a catch-up turn: the memory re-delivery when
memoryis the text of one (compose_fallback), then the catch-up block, in one<system-reminder>. Without memory the block stands alone: the hook already delivered it, or the phase delivers none. - compose_
fallback - The fallback’s hidden message, composed on srv
(SPEC_CONTEXT_DELIVERY_2026_09_30.md §3.4 step 2, CD2b). Its wire format
is the frontend’s
composeReinjectionMessage, unchanged: the<system-reminder>envelope andREINJECTION_SIGNATUREare how srv’s digest, the continuation packet and replay recognise a hidden turn. No part cap: the fallback is one message.Nonewhen there is no memory. A compaction’s running summary is not here: srv’s input handler appends it (continuity_state::with_state_after_compaction). - compose_
fallback_ layout compose_fallback_withwith the Personal Memory index and a closing note, as the hook’s delivery has them. No part cap here, but the same classes: the index first, files marked always, the Global Memory the startup file lacks, then the note.- compose_
fallback_ with compose_fallback, saying so when the Global Memory is left out because the new session’s startup file already carries it (entriesthen holds the Personal Memory only), as the hook’s delivery does (compose_items_with).- compose_
items_ tail compose_items_with, with the Personal Memory index and a closing note (memory::fit’s left-out note and pruning nudge) after the memory and before the running summary.- compose_
items_ with - [
compose_items], saying so when the Global Memory was left out because the agent’s startup file already carries it (a new Claude session that loadedAGENTMUX_MEMORY.mdor an AgentMux-ownedCLAUDE.md; SPEC_LAUNCH_CONTEXT_WORKSPACE_RULE_AND_STARTUP_FILES_2026_09_30.md §4.4). - is_
catch_ up_ text - Whether
textis a catch-up message, which has no reinjection signature when it carries no memory. Its input is hidden, but the agent’s reply is shown and read: the ambient digest and the continuation record skip the input without hiding what follows, and the hidden-reinjection gate (set_hidden_reinjection_active) is not set for it. - split_
into_ parts_ counted - [
split_into_parts], plus how many oftext’s characters the parts carry: all of them unless the text was cut.