Skip to main content

Module fit

Module fit 

Source
Expand description

What of an agent’s Personal Memory fits in a delivery, and what the agent is told about the rest (the re-send after a compaction; memory_delivery composes and splits what this keeps).

A delivery carries at most HOOK_PARTS * MAX_PART_CHARS characters. Before this, the files went in by name and the cut fell wherever the budget ended: one stale 50 KB snapshot at the front used it all, and every later file, including the one the index marks “read first”, showed as not sent.

  • Order: newest first (the file’s modified frontmatter, else its mtime), done where the files are read.
  • Index: Personal Memory goes in as an index (index.rs), one line per file, always complete. Only files marked deliver: always (up to ALWAYS_MAX_FILES files and ALWAYS_MAX_CHARS characters) go in full.
  • Fit: Global Memory entries that still don’t fit are left out whole and listed by name with the way to read them, never cut at the end of the text.
  • Hygiene: on a compaction, one note when Personal Memory is over PERSONAL_BUDGET_CHARS, a file is over the cap, or a project file hasn’t been touched for STALE_DAYS. AgentMux never deletes memory: it can’t tell a stale snapshot from a durable rule, so the agent trims its own.

Structs§

Fitted
What the model gets to read: everything that fit, and a note about the rest.
Seen
What a Personal Memory file looks like to the hygiene check.

Constants§

FILE_CAP_CHARS
The most characters one Personal Memory file contributes.
NO_CAP
A capacity for a delivery that has no part cap (the fallback’s one message).
PERSONAL_BUDGET_CHARS
Personal Memory above this (in characters, counted before the cap’s cut) is worth pruning.
STALE_DAYS
A project file untouched for this many days is called stale.

Functions§

fit
Caps the Personal files and keeps, in the order given (the caller put the newest first), as many as fit in one delivery after reserve_chars (the running summary and anything else that rides along). Global Memory goes in whole entries only; Personal Memory goes in the index, and the few files marked deliver: always in full within their limit. The tail is the left-out note, and the hygiene note when hygiene is set.
frontmatter_value
The value of key in the frontmatter block at the top of text (--- … ---), at any indent so a nested metadata: key is found too.
hygiene_note
The note asking the agent to trim its Personal Memory, when it needs it: over the budget, a file over the cap, or a project file stale for STALE_DAYS.
skipped_note
The note naming the Global Memory entries left out of the delivery, with how to read each.