Expand description
The end of a provider session, found from the segment index (SPEC_HISTORY_COMPACT_FORM_ONLY_2026_11_23.md 5.4).
AgentMux records every provider session it starts, per agent (continuity_segments: the session id, the config
folder, the working folder). A session has ended when
- the agent has moved on to another session (a fresh start, or an id that could not be resumed): it is no longer the newest session the agent’s segments name; or
- it is the agent’s newest session, no process holds it, and nothing has written to it for the idle limit
(
agent:rawsessionidledays, 7 days, at most 30); or - the agent was deleted (provably: its definition is retired and no longer active), which ends its newest session at once.
A stop, a restart and a quit do not end a session: the agent resumes it. Only sessions AgentMux started are ever
looked at (the ids in its own segment log), only inside folders AgentMux owns (never a person’s own CLI home), and
only by exact session id: <project folder>/<id>.jsonl and <id>/. For each ended session
provider_end::end_session proves, imports and removes.
A sweep removes files, so it runs only when history:sessionfilesweep is on. It is off by default and is
switched on with the migration of existing stores (spec 9), after the earlier steps have soaked.
Structs§
- Admission
- What keeps an agent from starting while its session files are removed: the agent’s single-live-instance lease, taken for the removal only. An agent that is running (or starting) holds it, so its sessions are not touched.
- Ended
- An ended session whose files are there.
- Policy
- Report
- What a sweep did, in counts.
- Report
Totals - What the report-only pass found, by why: how many session files and how many bytes.
- Roots
- The folders AgentMux owns provider homes in.
Enums§
- Reason
- Why a session ended.
Constants§
- DEFAULT_
IDLE_ DAYS - KEY_
IDLE_ DAYS - How long the newest session may go unwritten before it ends. A person’s setting; the word stays internal.
- KEY_
REPORT - The switch of the report-only pass: off unless set, and it never removes anything.
- KEY_
SWEEP - The sweep’s switch: off until the migration turns it on.
- MAX_
IDLE_ DAYS
Functions§
- ended_
sessions - The agent’s ended sessions whose file is there, from its segments (oldest first). The newest session is ended when it has been idle for the limit; whether the agent is running now is for the lease to say.
- report_
enabled - Whether the report-only pass is asked for.
- report_
global - The report-only pass over the global store: for every provider session file no segment log names, the sweep’s own
owner test and proof, and the result written beside the store (
provider-session-report.tsv, replaced each time) with its totals returned. It removes, imports and locks nothing, and runs only when asked for. - sweep
- End every ended session, when the policy is on. A pass that is not enabled reads nothing and removes nothing.
- sweep_
global sweepover the global transcript store, where the segment logs, the conversation zones and the agent’s provider zone live (the per-channel store holds none of them).Nonewhen there is no global store: nothing is swept then.