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.
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).
- Tracked 🔒
- A string being built, with its length in characters kept alongside.
Enums§
- 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. - Tier
- Whether an entry is Global Memory (Operator Config included) or the agent’s own Personal Memory.
Constants§
- 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_
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_
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). - push_
sections 🔒 # Global Memory (n entries)and# Personal Memory (…), each item’s text whole, sections separated by a blank line; empty sections left out. The frontend’scomposeReinjectionMessagewrites the same, so a re-delivery carries the startup block’s sections byte for byte. Returns whether anything was written.- split_
into_ parts_ counted - [
split_into_parts], plus how many oftext’s characters the parts carry: all of them unless the text was cut.