The teardown RLock comment promised that an acquire warms only after the
running unload's hooks finish. A release() hook re-entering on the same
thread warms at once, and the unload now skips the owners that hook
superseded and keeps the models when a holder or new window came back.
The comment now says so. The owner-map and barrier comments no longer
claim more than the code does.
The web lease route comment said release "reads nothing" from the
requester, but the requester scope still resolves the profile, activates
hosting and hydrates its secret sources. It now names those effects.
Comments only; no behaviour change.
A release() hook that re-enters the lease lifecycle could undo its own work:
- Reacquiring a local engine (holding it, or releasing it into a new
positive keep-warm window) still had its freshly warmed model dropped,
because the unload cleared the caches unconditionally. The drop now
re-checks the keep-warm generation and holders under the lease lock.
- With several claimed owners, a hook that reacquired as another owner
(B) still got B signalled with its superseded acquisition context. A
nested zero-window release signalled B twice. Each owner now records a
per-home generation, and the unload skips an owner whose generation
moved. An untouched owner is still released at once, even when the hook
reacquired only its own profile.
The context-copy test now also asserts that the release hook actually ran,
so a release path that drops `.copy()` is caught.
[Salvage: posted on PR #156045 review 5972197019 (inline comments 4626560969 and 4626560994); applied onto 276c9d50d3 by kshitijk4poor as posted]
The unload released each acquiring profile with release_tts_provider(),
which both signals the profile's user provider and clears every local
model cache. It then swept the caches again per engine name to catch what
a failed owner left behind. That is N+M cache passes for one context-free
operation, and the per-owner call hid that the sweep is what makes a
failed owner safe.
Split the two halves. _signal_release() runs in each owner's acquisition
context, because it reads that profile's config, hook and secrets.
_drop_local_models() reads no config and runs once, outside any owner.
release_tts_provider() is composed from the same two pieces, so its
public contract does not change: default/blank -> signal + clear all;
named -> clear that cache only, no signal; {"released": n}.
Tests (new guard file only):
- public-API parity for release_tts_provider (none/blank/whitespace,
named with normalization, unknown name), plus one unload that signals
each owner once in its own profile and counts models once. These also
pass on the previous lifecycle file, which shows the refactor keeps
its behaviour.
- the bare-home fixtures share one `homes` fixture. It is HERMES_HOME
override only, deliberately not bind_profile_scope (no secret hydration).
- the barrier test releases the real teardown lock if a failing run
acquired it, instead of leaving the module lock held.
- the web release comment now names the scope's real remaining side
effects (hosting activation, secret-source hydration).
Follow-up to the acquisition-owner change. When the last lease drops, every
owner's keep-warm window is read, and later every owner is released, each in
its own profile. One owner whose tts config the real loader passes through
malformed (a truthy non-dict `tts:`, a non-string provider) or whose config
backend is down raised out of the shared path:
- a failed window read left no timer and no inline unload, after the
leases were already empty;
- a failed release skipped every later owner and the local-cache unload,
and those owners had already been dropped from tracking.
Each owner's window read and release now run on their own. A failed window
read counts as the default window. A failed release releases nothing for
that owner, and the loop continues. The local engine caches, which need no
owner config, are swept once after the owner releases, so a model is never
left resident. Only the exception type is logged, never the message (it can
quote config). ConfigBackendUnavailable is a SystemExit by design and is
caught explicitly, as other callers that must not block their siblings do.
Holder names, revocation, the released count and the timer/generation fence
are unchanged.
Lease names are process-wide ("tui:voice-tts", the desktop's shared
"desktop:read-aloud"), and since #155608 voice.toggle runs in the calling
session's profile, as /api/audio/tts-lease?profile= already did. So profile B
can acquire and profile A, or the keep-warm timer, can drop the last hold.
On main the last release then reads the keep-warm window from A's config,
signals A's provider (release_command / plugin release()) with A's secrets,
and never releases what B warmed.
Each profile home that acquires now keeps its acquisition context until the
unload. The window is the longest any of those owners configured, read in
that owner's context. The unload runs release_tts_provider() once per owner,
in a copy of that owner's context. The caller of release only decides when
the last hold ends, never whose resources are released.
The release hooks now run outside the lease lock, so a plugin release()
that touches the lease API no longer deadlocks. A teardown lock keeps an
acquire that arrives during those hooks from warming until they finish.
A warm that the unload overlapped restores its owner, so the unload that
follows still releases it in the right profile.
Not changed: holder names stay process-wide, so any profile's release still
ends a hold of that name, as before.
Follow-up to #155608 (salvage of #114196, which scoped the toggle but left
the lifecycle unchanged).
On daytona and vercel_sandbox the prune stub names ~/.hermes/cache/pruned/<name>,
where ~ is the sandbox's home. _resolve_path_for_task expands ~ with the HOST home
for every non-ssh backend, and _read_extracted_document handed that host path to
file_ops.read_file_bytes. When the sandbox home differs the byte read missed, the
read fell through to the ordinary reader, and a one-line JSON archive came back cut
at the per-line cap with no way to page it.
The byte read now gets the same path the ordinary read uses: the resolved host path
when the file ops target the host filesystem, the path as given otherwise. This
covers extractable documents too (same class). Suffix and archive checks still use
the resolved path.
On docker, modal, ssh, daytona and vercel_sandbox the cold prune and the compaction
offload kept every result whole (no saving) or dropped it without an archive, because
cache/pruned was not published into the sandbox and the stub named a host-only path.
cache/pruned now joins the cache dirs docker bind-mounts and the synced backends push,
the stub names the path the sandbox reads (to_agent_visible_cache_path), and read_file
forces a sync before opening an archive on a file-synced backend. Plugin backends and a
hosted scope still keep results whole.
The macOS lane (bash 3.2) still failed the errexit test cases. With SHELLOPTS exported,
3.2's `export -p` writes `declare -rx SHELLOPTS=...`; sourcing that line fails because the
variable is read-only, and the inherited errexit then ends every later command with rc 1 and
no output. Main has the same failure on bash 3.2: a replay of main's real wrapper scripts in
a bash:3.2 container returns rc 1 with empty output for every command.
The dump now runs `export -n SHELLOPTS BASHOPTS` inside its subshell before `export -p`:
shell options are not environment the next command needs, and the inherited option still
applies (`$-` shows errexit on both main and this branch). Replay on bash 3.2 and 5.2 now
prints each command's output with rc 0.
Greptile: with `SHELLOPTS=errexit` inherited (e.g. `LocalEnvironment(env={"SHELLOPTS":
"errexit"})`), the restore step's `read -r -d ''` returned 1 at the EOF it always reaches
(the set holds no NUL), so bash exited before the user's command and every call returned 1
with no output. `|| :` absorbs that expected status.
The test fixture now also runs every case with an inherited errexit; on 56e55892aa12 all
three errexit cases fail. Checked under errexit, errexit+nounset+pipefail: same output and
exit status as main, and no secret on disk.
Greptile: one `declare -p` record for an 80 KB token made of double quotes is ~160 KB, past
Linux's 128 KiB limit for a single environment entry, so the next spawn failed with
"Argument list too long" and so did every later command, `unset` included.
The declarations of the dump the sourced snapshot names now go to the child on a pipe (a
writer thread feeds sets larger than the pipe buffer) and the wrapper reads them with
`read -r -d ''` + `eval`; nothing secret rides process env any more. `source /dev/fd/N` is
not used for the pipe because bash 3.2 sources nothing from one (checked in a bash:3.2
container); the snapshot file itself is still sourced from its open fd, which 3.2 handles.
The second test now carries that 80 KB quoted token across commands; it fails on the
previous head with the spawn error.
Greptile's re-review of 4a25e59a390f found four more gaps in the in-memory channel:
- The restore loop expanded `${!__HERMES_SD_*}` unquoted: after a command saved `IFS=''`
the names joined into one word, the entries stayed exported and the next dump wrote their
values to disk. It now iterates `"${!__HERMES_SD_@}"`.
- Every kept generation's declarations went into the next command's environment, so four
80 KB secrets over a few commands hit `Argument list too long` and every later command
failed. Only one dump's declarations are passed now.
- The declarations were chosen before bash picked the snapshot file, so a newer publish in
between left the command with no secrets. The backend now opens the file itself, reads
the generation on its first line and hands bash that open file (`source /dev/fd/N`) plus
that generation's declarations, so the two are chosen together.
- Eight failed publishes could evict the generation the file on disk still names. Eviction
now keeps that generation.
Speed: the per-letter case classes in `compgen -X` cost ~5 ms of shell CPU per command, so
the candidate filter is a short superset list (property-checked over 200k generated names
against the exact lists), the exact lists then run under `nocasematch` in `case`, and the
poll loop ticks every 2 ms for its first 50 ms. Paired A/B, 400 alternating `true` commands:
median 24.0 ms vs main 35.2 ms, faster in 332/400 pairs.
Review found three gaps in the in-memory secret channel:
- Two overlapping commands could leave the next command with one dump's ordinary exports and
the other dump's secrets (`B SYNTH-A`): independent reader threads committed in their own
order. Each dump now has a generation id; the file records it and the shell applies only the
secret declarations stored under the generation of the file it actually sourced.
- An exported secret array came back as a scalar holding element 0. Records now carry bash's
own `declare -p` text, so arrays and readonly/integer/case attributes come back exactly; the
value-less flag line in the file is gone.
- "Stays a secret for the session's lifetime" was the union of names currently stored, so
unset + leave .env + re-export put the value back on disk. The store now keeps a separate
lifetime name set, cleared only by cleanup.
The overlap and re-export tests fail on the previous head and pass here.
- A secret name the session already holds stays a secret after it leaves the profile's .env, so
removing the entry (or a briefly unreadable .env) can no longer land the remembered value in
the next snapshot.
- Name globs match every letter's case (`[Tt][Oo]...`), so `GitHub_Token` is caught on bash 3.2,
whose `compgen -X` ignores nocasematch.
- A secret's other attributes (readonly, integer, ...) go into the file as a value-less
`declare -rx NAME`, which re-applies them to the value the next command receives.
- The dump's closing record is written only after its snapshot file is published, so a failed
publish keeps the previous secrets beside the previous file instead of mixing two dumps.
The terminal tool saves the shell's exported variables to hermes-snap-*.sh after every
command so the next command starts with the same environment. Every credential the profile's
.env defines, and every token an agent exported in the shell (a Hermes Cloud service
credential, for one), landed in that file in plaintext and came back after every delete.
Secret exports now leave the file and travel in memory: the dump hands each one to the host
over an inherited pipe, and the next command receives it back as process env. The shell sees
the same variables as before (export in one call, read it in the next), and the file on disk
holds none of the values. A secret is any name the profile's .env or secret sources define,
any credential-shaped name (token/key/secret/password/cookie/webhook/creds/client id, any
case), or a URL-shaped name whose value carries user:pass@. Readonly exports are cleared with
export -n, which unset refuses.
Faster than before: matching runs inside bash with one compgen -X (no per-variable fork, the
cost that made #148406 ~25x slower), the PATH every command composes no longer re-resolves the
tool store per package (~11 ms -> ~1 ms), and the wait loop's first poll tick is 1 ms instead of
5 ms. Median `true` on the local backend: 31 ms on main, 15 ms here.
Local backend on POSIX; Windows (no pass_fds) and remote backends keep their snapshot as it
was, since dropping values there would drop the user's exports from later commands.
Salvages #148406 (fail-closed scrub, readonly handling) and the thread's design on #62336:
scope-driven names from the profile's .env, the missed cookie/webhook/creds shapes, and the
fork-free matching.
Fixes#62336
Co-authored-by: Paul Hill <paulipopshill@gmail.com>
Co-authored-by: Keaton Chia <88001418+kwchia@users.noreply.github.com>
Co-authored-by: Kevin Rajan <7121943+kvnloo@users.noreply.github.com>
Co-authored-by: Yags <166958865+whyyagswhy@users.noreply.github.com>
A pending receipt that exists but raised a read error was skipped like a foreign file, so
bot_delivery.list answered a shorter list and the Waiting on teammates strip dropped a
delivery that was still waiting. Only a deleted or malformed file is skipped now; any other
read error reaches the RPC as storage_unavailable, which the strip already handles by keeping
its last rows greyed.
Rebasing onto main: the old session store (hermes_state_runtime, SessionDB's
admission helper) was removed, so bot_delivery.list failed at import and the
gateway handler table could not load. The owner join now reads the target's
admission from its authority's persistence handle, the sidecar's stored state
from a read-only persistence reader, and the sender's home from the authority's
profile_id. bot_mode_probe._handle now takes the roster's names (a real
profiles/hermes keeps @hermes), so the strip and the sidecar resolve handles
the way the rest of Bot Mode does. Regenerated the serve handler ledger.
The strip polls every 5 s and each poll opened and parsed every retained
delivery receipt in every teammate profile, settled history and other
senders' included, so its cost grew with every message bots exchanged.
Receipts are kept for recovery and replaced atomically on each write, so
a per-directory cache keyed on (inode, mtime_ns, size) re-reads only files
that changed; a settled receipt is cached as its status alone. Nothing is
deleted or written.
Found in the live two-bot run: bot A sent two requests to bot B, B's first
turn parked on a clarify, and the strip showed BOTH rows as "Waiting on you".
The second one had not started; it was waiting on the first turn, not on
the user. The open prompt now only marks the delivery whose admission is
the running one.
A bot that message_agent's a teammate gets nothing back until the reply lands or the wait times
out; if the teammate is parked on a clarify or approval only the user can answer, nobody sees it.
bot_delivery.list reads the existing receipts under each target profile's
runtime/bot_live_delivery (author bot:<sender>) and reports each unsettled delivery as
queued / claimed / working / waiting_on_you / failed (typed reason; unknown_outcome for an
ambiguous receipt, which must never be resent). The canonical owner joins each target's
admission row and its open prompts (PendingControls.waiting_kinds, a non-pruning read) under
that target's owner scope; the legacy sidecar handler reports the durable admission state only.
Nothing is written, claimed, cancelled or resent.
A resumed history can repeat a tool_call_id. The whole-transcript id map gave an
older result the later call's arguments, so a later archive read-back made the
prune skip saving that older result's own original. Each row now takes the
nearest preceding assistant call with its id.
spillover_reference_rows now streams its rows, so it has no awaitable form; the
awaitable-form contract lists it with the other streamed verbs.
Remove a partial prune archive after an exclusive write fails, only when this call created it. Preserve existing files on collisions and default spillover overwrite behavior.
(cherry picked from commit 8abb7e3de71402684a0be156eae59c114fa18a2b)
referenced_archive_refs read at most 20,001 rows and answered "unknown"
past 20,000, and the sweep then kept every file in cache/pruned and
cache/spillover. Every prune stub row counts toward that number, so a
busy home passed it and was never swept again.
Rows are now read one at a time with no cap; memory is bounded by the
reference set. Any database error still answers "unknown", so the sweep
still fails closed. Below the old cap the cost is unchanged (the filter
has no index, so the whole table was already scanned). Past it the read
used to stop at the 20,001st match and now runs to the end, so on a
large home it stays open longer. The docs sentence about the cap is
removed.
(cherry picked from commit a5bed1d2d9fb436f6129388b237330a509abb6aa)
When the model reads an archive back, the read_file result is an
ordinary tool result. A later prune archived it a second time, as a new
file holding the line-numbered rendering, and the stub named the copy.
A read_file result whose path is absolute and names an existing file
directly inside this home's cache/pruned is no longer archived again:
its stub points at that same file. Only on a backend that reads host
files; a sandboxed backend, a look-alike path elsewhere, a missing file
or a relative path takes the usual path.
(cherry picked from commit 4569ceaaf8b220d0477bed5cbebd9938d4aab485)
The env re-dump wrote 'export -p > $mktemp_file'; under 'set -C' that redirect
fails on the existing temp file, so every export was dropped before the next
command (the sudo noclobber test then ran the host's real sudo). Use '>|'.
test_bot_desktop_idle_self_stop: pin the idle check to the test interpreter
instead of a published checkout launcher that has no dependencies under the
temporary HERMES_HOME. test_fal_sdk: importorskip the optional fal_client.
ripgrep accepts (?i) natively, but POSIX ERE has no inline flags: grep -E
warns '? at start of expression' and matches nothing, so a case-insensitive
search_files silently returned zero hits whenever rg was unavailable (local
without rg, or any remote backend without it). _grep_cmd, shared by the plain
and the find-pruned grep lanes, now turns a leading (?i) into -i.
The carried rebuild read raw entry.schema, dropping dynamic_schema_overrides
(delegate_task limits, backend task params) and the build's schema
sanitization. registry.definition_for builds a definition the way
get_definitions does, minus the check_fn gate; the restore rewrites and
sanitizes it like the build. Found by Greptile on #157534.
A narrowed restore can carry execute_code from the pin when its check_fn
fails here, so it is not in this build and fresh.get() kept the pinned
helper list. Rebuild it from the registry schema against the final names.
Found by Greptile on #157534.
restore_agent_tool_prefix keeps every still-available tool's pinned bytes
so tools[] (the head of every request) stays cached. When the resumed
session has fewer toolsets, the restore drops pinned tools, so tools[]
has already moved; a survivor whose description model_tools'
_DYNAMIC_SCHEMA_REWRITERS derives from the other tool names
(execute_code's sandbox list, delegate_task's sibling line, browser_exec's
vision hint) kept naming the dropped tools. In that case only, those
survivors take this build's definition. A restore that drops nothing is
byte-identical to the pin, as before.
Raised by @BearHuddleston on #157517.
A get_window_state reply that keeps only the driver's elements-format
instruction text (structured payload and image lost in transit) passed
`_gws_is_empty` because the text was non-blank, so the CLI re-fetch never
ran and the model got neither pixels nor elements. Count text as usable
only when the tree parser recovers an element from it.
The opt-in macOS live smoke sent `element_index` straight to `type_text`,
which the pinned 0.52.0 schema refuses; it now sends the index only when
the live schema accepts it, and its fake covers a token-only schema.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
Negotiate the elements view against the live get_window_state property schema, keeping legacy and pixels-only requests unchanged. Consume structured window titles when elements mode omits Markdown and clarify the driver-default AX walk cap.
Keep action-time token and snapshot attachment unchanged. Cover negotiation, metadata, MCP/CLI parity and the direct smoke readers with focused base-red behavior contracts.
A strict token-only schema never accepts the bare element_index
either, so an index with no token from the latest capture (model
reusing an older capture, or a capture that returned no tokens)
would reach the driver only to fail with the same opaque
'unknown argument element_index' rejection. Refuse it locally with
an actionable stale_element message instead.
cua-driver 0.32+ publishes strict per-tool schemas (additionalProperties:
false) that declare element_token but drop element_index entirely, so the
wrapper's token attachment — which kept the index alongside — got every
element action rejected before it ran (#132876). Strip the index only when
the live schema names the token but not the index; 0.21-era schemas that
accept both keep today's behavior, as do capability-only drivers.
The round-2 rule left any match ending on the backslash of `\ ` unfolded. That
holds only when the backslash continues the home's own last name (a sibling such
as `hermes\ data\ backup`). Inside a child name, bash can expand it away:
`config.yaml${u:+\ }` and `config.yaml{,\ }` still write the policy file, and a
spaced home had no other fold, so they passed as safe. The fold now drops only
the trailing backslash from such a match, so `~/.hermes/config.yaml${u:+\ }`
reaches the patterns. This also keeps `~/My\ Documents` home-relative instead
of a "delete in root path" prompt.
`config.yaml\\\\ x` is the file plus a literal backslash, then a new word:
the space after an even backslash run is not escaped. The previous
commit kept any match ending on a backslash before a space unfolded,
which lost the gate main has there. Only an odd run escapes the space.
The quote check read the shell with a lexical scanner that a quote in a
comment, heredoc body or backtick desyncs, so a real unquoted
/home/John\ Smith/hermes/config.yaml after one looked quoted, stayed
unfolded and passed as safe. Read every \ inside the home as a space:
a quoted one now costs a prompt instead of a lost gate. The rule for a
\ right after the home needs no quote state and stays. Dropping the
scanner also removes its per-$( recursion.
The optional `\` before a space let a home component match `John\ Smith` in any
context, and the path tail took the next backslash as a separator. Both made
commands about other directories fold onto the protected home:
- quoted `'/home/John\ Smith/...'` (or double-quoted) keeps the backslash, so it
names a different directory than `John Smith`;
- unquoted `hermes\ data\ backup` is one name, a sibling of the home
`hermes data`; the same held for spaceless homes (`hermes\ old`).
Matches are now checked against the shell's quote state: every escaped space
inside a fold must be live, and one right after it keeps the match unfolded.
The quote scan is the shared linear `_scan_shell` and runs at most once per fold.
An unquoted Git Bash path escapes the space in a profile name (``John\ Smith``);
the fold built its components with bare ``re.escape``, so that spelling never folded to
``~/.hermes`` and the edit of the policy file passed as safe.
Follow-up to #155463 (which closed#144033).
alt-glitch's review of 893b54f9:
- Hermes' own managed llama-server unloads an idle model (and its prompt cache) after 15 min (+ two
120 s sweeps): its clock now ends there, so /context and the cold offload see it; a user's own local
server still never expires on the clock. The guarantee is capped at the estimated end.
- A malformed entry in cache/prompt_cache_routes.json (non-numeric timestamp, counters or gap lists) is
dropped instead of raising into agent build and usage accounting.
- The route key keeps the port (normalized base URL): two local servers on one host learn apart.
- The classic CLI's idle cache hook never ran: `hermes chat --cli` drives a GatewayAgent and the gateway
owns the warmer and its housekeeping. The hook, its test and its helper are removed (the two CLI
files are main's again).
- A due-scan's claimed action is handed to a release job that registered for the same chat while the
scan ran, instead of being dropped.
- Keep-alive log lines carry the chat's session tag (set on the timer thread).
- Tests that could not fail now can: the claim race pauses after the decision, the late-miss branch with
no successor, and the compaction hand-off through carry_compression_automation (each red when its fix
is reverted).
- Follow-ups folded in: a finite admission arms no idle keep-alive; delegate cost folding takes the
session-totals lock; the docs say the gateway offload lands on its 5-minute tick.
- Keep-alive totals go through turn_usage.add_session_usage, the same fold a response uses
(it now also counts reasoning tokens, as a response does).
- PromptCacheWarmer._with_aux_hooks is auxiliary_hooks.run_with_aux_hooks with a lazy
normalized= view; _rough_tokens is conversation_compression_manual.estimate_request_tokens.
- prompt_cache_is_cold lives in prompt_cache_clock (its only inputs), ending the
turn_proactive_prune -> turn_preflight -> turn_proactive_prune circle; the read-dedup reset
after a committed prune happens once, in _proactive_tool_result_prune, not at three call sites.
- Public names for the helpers other modules import: turn_usage.cache_clock_column /
agent_session_source, context_compressor_summary.accepts_keyword_argument.
- archive_pruned_originals / archive_compaction_drops lose the never-passed skip= parameter.
Co-authored-by: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com>
Main's root AGENTS.md adds no new flat <stem>_<topic> siblings unless an area AGENTS.md prescribes
one. The compaction/prune archive helpers (archive_pruned_originals, archive_compaction_drops,
pointer parsing, the summary's archive list) move into tools/tool_result_storage.py, which already
owns spilled and pruned tool-output files and their sweeper; the TUI cache-expiry ticker and
release-time compaction move into tui_gateway/session_reaper.py, which owns idle/LRU reaping and
already calls them. No shims; imports, docs and tests follow.
A store error after a worker committed the prune (reply lost) deleted archives
the transcript already names; they now stay for the reference-aware sweep.
Archive lines wrap at min(line cap, file_read_max_chars - gutter), so a small
read budget no longer cuts a line mid-way and skips its remainder.
The byte-exact archive may be a compact top-level JSON array. Render arrays on multiple lines so the existing read_file paging limit does not hide later entries; preserve the saved original bytes.
Regression for the review of NousResearch/hermes-agent#156081. Credit teknium1 and kshitijk4poor for the archive implementation; 100yenadmin for the read-back analysis.
(cherry picked from commit 8dc1f748ada9b64ab48c4a1fe003812566926294)
Review round on #156081 (100yenadmin's review + /review):
- Sandbox guard decides on the terminal backend: archive-and-prune only on
`local` outside a hosted scope; every other backend (docker, modal, ssh,
daytona, vercel_sandbox, plugin or unknown names) and a refusal scope keep
the result whole. The old path-translation check never fired because
cache/pruned is mounted nowhere. The mocked test is replaced by
100yenadmin's real-resolver test (cherry-picked) plus unknown backends.
- Warm proactive pruning is back to main's defaults (0 / 8000 / 4096: off).
The cold path (provider cache already expired) needs no trigger and stays
on by default with its 16K reclaim gate; a warm gate only lowers it when
the warm prune is switched on. The two skill-safety fixtures and the
other prune test files are byte-identical to main again.
- The running-turn guard fails closed: a turn index that names no user row
(-1 after a compaction, or any other row) skips the round instead of
falling back to the count-only tail.
- The protected-tail boundary is aligned with _align_boundary_backward, so
one assistant step's parallel results are pruned all-or-none.
- read_file pages every cache/pruned archive (.json and .txt) and wraps a
line longer than the per-line cap, so a one-line 300,000-char archive
reads back completely.
- Archive writes are read back and compared byte-for-byte, not size-checked.
- Docs: what is on by default, the backend rule, that a referenced archive
stays until its session is deleted (sessions.auto_prune is off by
default), and that the sweep keeps everything past 20,000 referencing rows.
- Plugin engines: the call site's store-row gate is the built-in compressor's
own (it opts in via prune_needs_session_store), so a plugin engine that
implements prune_tool_results_only without the built-in's private
_session_db/_session_id is called again.
- Archives never overwrite: resumed histories can repeat a tool_call_id, so
the name gets a numeric suffix until free and the file is created
exclusively.
- Sandboxed backends: the prune holds no environment to sync and probe a
remote copy, so a stub could name a file the model cannot open yet. On those
backends the result is kept whole (no information loss) and cache/pruned is
not mounted.
- Full in-place compaction clears the cold-prune credit with the runway, so a
stale credit cannot lower the next warm gate.
Found by the live run on Nous (real hermes chat, low thresholds):
- The loop's transcript carries no system row, so a session's first turn
starts at index 0; the running-turn guard required > 0 and the first turn
of every session lost its own read_file bodies mid-turn.
- A JSON tool result is archived byte-exact, so it is one long line, and
read_file cut it at the per-line cap: the model opened the archive and saw
only the first ~30 lines. read_file now pages cache/pruned/*.json by the
text it wraps (the same rendering spill files use); the file on disk stays
byte-identical to the original.
Salvage of #136488 (kshitijk4poor), review findings from 100yenadmin and kvnloo.
- No information loss: before the proactive prune shortens a tool result, its
full original is written byte-verified to
$HERMES_HOME/cache/pruned/<session>_<UTC>_<tool>_<id>.<json|txt> and the stub
ends with " — full result: <path>", so read_file returns the exact output.
A result whose write fails stays whole and the reclaim gate is re-checked on
what is left (no commit -> the written files are removed).
- This also closes kvnloo's unflushed-original case without deferring the
prune: the original no longer depends on the store having seen the row.
- The running turn is never shortened: the post-tool site passes the turn's
user-row index (turn_start), and every row from it on is kept whole. Before,
the count-only tail let a long tool loop stub its own earlier calls.
- One sweeper: the spillover reference/retention machinery now covers
cache/pruned too (archive_refs_in_text / referenced_archive_refs; session
delete retires both). Pruned files follow sessions.retention_days and are
never deleted while state.db references them. cache/pruned is mounted for
sandboxed backends like cache/spillover, and the stub names the path the
backend sees.
- Cold-cache reading isolated in turn_proactive_prune.prompt_cache_is_cold so
the shared cache clock can replace it in one line.
- Two skill-safety fixtures pin the old 4096 reclaim gate (the shipped 64K
default made their ~7K-token transcripts no-ops).