Expand description
The endpoints Claude Code’s SessionStart hook calls to deliver an agent’s
memory (docs/specs/SPEC_GLOBAL_MEMORY_DELIVERY_2026_09_27.md §7 P2). The
composition and the part rules are backend::memory_delivery.
POST /api/v1/agent/memory/session-start/part— one part. Each of theHOOK_PARTShook commands asks for its own part number. They run in parallel, so the first request for a (block, session, reason) composes the delivery and caches it, and every other part comes from that same composition.POST /api/v1/agent/memory/session-start/ack— a hook wrote its part to Claude. Once every part is acknowledged the delivery is complete: the pane gets one persistedagentmux_memory_injectedframe naming each entry and its size (owner decision D11). A part fetched but never acknowledged (the hook crashed or timed out) leaves the delivery incomplete, and no notice claims otherwise.
The agent comes from the request’s credential (X-Agent-Token →
Caller::Agent): its Personal Memory is that
agent’s. Without a token only Global Memory is delivered.
Structs§
- AckRequest 🔒
- Delivery 🔒
- Delivery
Key 🔒 - Delivery
State 🔒 - Deliveries and fallback claims, behind one lock so “who claimed this event first” is decided atomically.
- Entry
Size 🔒 - One item of a delivery as the notice shows it: one card row
(SPEC_CONTEXT_DELIVERY_2026_09_30 §3.1, §3.4).
labelandsourceare what older builds read; the rest is per-item detail. Sizes are those of what was delivered, so an item cut by the part cap reports its slice. - Fallback
Delivery 🔒 - A re-delivery srv composed for the frontend’s fallback (CD2b).
- Launch
Dirs 🔒 - Where a session’s CLI looked for its startup files.
- Part
Request 🔒 - Part
Response 🔒 - Startup
Detail 🔒 - What a
startup_fileitem adds (SPEC_LAUNCH_CONTEXT_WORKSPACE_RULE_AND_ STARTUP_FILES_2026_09_30.md §4.1,backend::startup_files).
Enums§
- Fallback
Claim 🔒 - What the fallback’s claim found.
Constants§
- BOUNDARY_
ORIGINS_ 🔒MAX - How many compaction boundaries’ origins are remembered. Boundary uuids are unique across blocks.
- CLAIM_
WINDOW_ 🔒MS - How long a claim on one event (a session start, a compaction) holds: the
hook and the frontend’s fallback for the same event arrive within
seconds of each other, and one block has no two such events that close.
Not for a fallback that waited behind a turn: a dated claim
(
DeliveryState::claim_event) covers that. - DELIVERY_
TTL_ 🔒MS - How long a composed delivery stays cached for its remaining parts and acknowledgements. The hooks of one session start run within seconds.
- EVENT_
SLACK_ 🔒MS - A fresh session’s
agentmux_session_outcomeframe can be written just after the respawn it reports (retry_after_resume_failure), so a hook delivery composed up to this long before the frame is still that session’s. - FALLBACK_
TTL_ 🔒MS - How long a composed fallback delivery waits for its hidden message. The frontend sends it right after composing, unless the pane turned busy.
- PENDING_
POLL 🔒 - PENDING_
WAIT 🔒 - How long the fallback waits for a hook delivery still in flight, and how often it looks. A hook that never finishes must not leave the agent with no memory, so after this the fallback delivers instead.
Statics§
- STATE 🔒
Functions§
- acknowledge 🔒
- Marks
partwritten. True exactly once: when this makes every part written and no notice has gone out yet. - claim_
fallback 🔒 - Whether the frontend’s hidden-reinjection fallback should deliver this
event (
true) or stand down because theSessionStarthook delivered it (false). Waits out a hook delivery still in flight for up toPENDING_WAIT, then lets the fallback deliver, so a hook that died part-way never leaves the agent without its memory. With aboundary_uuid, only the block whose CLI compacted can deliver. Withevent_at_ms(a fresh session’s time), the hook’s delivery for that session counts however late the claim comes. - compose_
delivery 🔒 - Reads the memory and composes the delivery.
Nonewhen there is nothing to deliver. A new session’s delivery also lists the startup files the CLI loaded fromlaunch(startup_items), ahead of the memory items. - compose_
fallback_ 🔒delivery - Composes the fallback’s hidden message from the same memory the hook
delivers (
global_entries,personal_entries), and the card that will stand for it.Nonewhen there is no memory. - delivery_
items 🔒 - The notice’s items, in delivery order, sized by what the parts carried.
- fallback_
frame 🔒 - The card for a fallback re-delivery: the hook notice’s shape, under the
delivery’s own id.
fallback: truetells replay that the hidden message right after it is this delivery’s echo, not a second one. - global_
entries 🔒 - Global Memory as the startup file carries it — its sections, Operator
Config first (
globalmemory:sections, P1). - global_
memory_ 🔒in_ startup_ files - Whether the CLI already got the current Global Memory from a startup file: one AgentMux wrote that holds every current section, byte for byte. A foreign or stale file with some old section doesn’t count, or the hook would drop current entries the agent never saw (Codex on #4131).
- handle_
session_ 🔒start_ ack POST /api/v1/agent/memory/session-start/ack- handle_
session_ 🔒start_ part POST /api/v1/agent/memory/session-start/part- in_
startup_ 🔒file_ item - A Global Memory entry that reached the agent through its startup file: listed in the card, sized 0 (the file’s own row counts it).
- notice_
frame 🔒 - The persisted notice (D11): which memory was delivered, and each entry’s
size.
idis stable for the delivery, so a live frame and a replay of the same line render once. - part_
response 🔒 - personal_
entries 🔒 - The agent’s Personal Memory files from its latest spawn’s memory folder,
by name, without the
MEMORY.mdindex (the CLI’s own table of contents). - personal_
entries_ 🔒in - reason_
for_ 🔒fallback - The event a frontend reinjection reason stands for: a compaction, or a
fresh session (a spawn without
--resume, whose hooksourceisstartup).Nonefor anything else. - record_
compaction_ 🔒boundary - Records that
block_id’s CLI wrote the compaction boundaryuuid. Called from its stdout reader, before the line reaches any pane. - register_
memory_ 🔒delivery_ handlers - Registers
memorydelivery:claim_fallback— the frontend’s hidden memory reinjection asks it right before it would fire — andmemorydelivery:compose, which composes what it sends. - send_
partless_ 🔒notice - A delivery with nothing for the hook to carry (its Global Memory is in the startup file, and there’s no Personal Memory) still has a card: written on the first part request, exactly once, since no part will be acknowledged.
- startup_
card_ 🔒written_ since - Whether
block_id’s new-session card went out for a delivery composed aftersince_ms: what the continued-session note waits for (backend::continued_note). - startup_
files 🔒 - The files the CLI read by itself at session start.
- startup_
items_ 🔒of - state_
lock 🔒 - take_
fallback_ 🔒frame - The card of the fallback delivery
delivery_id, taken once, when its hidden message reaches srv.Nonefor an unknown or expired id, or one composed for another block.