The profile switch reached every turn the gateway ran, so turning it on in
Desktop also sent Daybreak on that profile's Telegram, Discord and Slack
chats. OpenAI allows Daybreak no third-party or downstream access, and a
bot's chats can be other people.
- gateway: _load_daybreak(source) is true only for Platform.LOCAL turns
(Desktop, TUI, CLI).
- standalone hermes serve: agents built for a non-local source (a plugin
session tagged telegram) never carry it, and a live flip skips them
(agent.session_source.DAYBREAK_SOURCES).
- docs: say who gets it and why messaging chats don't.
Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
OpenAI Daybreak (Trusted Access for Cyber) reduces cyber refusals for
approved accounts. Codex's model picker has a Daybreak toggle; Hermes had
no way to request it.
The signed-in account's Codex /models catalog already lists, per model,
which cyber programs that account may use
(available_access_programs.cyber). Hermes reads that catalog for Fast and
Ultrafast; it now keeps the cyber list from the same fetch.
- agent.daybreak (default false) is one profile-wide switch, like Codex's.
- Desktop shows a Daybreak switch in a model's options submenu, next to
Fast, only when this account's catalog lists daybreak_blue for that
model. Unknown or unreachable catalog: hidden.
- Each Responses request adds access_programs.cyber=daybreak_blue only
when the switch is on AND the request's credential and model are listed.
Checked per request, so a /model switch, credential rotation or expired
catalog never carries it to a model or account without it.
- The gateway re-reads the switch every turn, so a flip applies to the
next turn of a running chat without rebuilding its agent.
- The opt-in codex app-server runtime does not send it, so the switch is
hidden there.
Co-authored-by: FroRaut <79215537+Froraut@users.noreply.github.com>
Greptile P1: an interrupted backoff wait reported recovery, so handle_api_error
continued before its interrupt check and the retry loop re-sent the request
(unbounded in the repro). Report not-recovered so the existing interrupt check
aborts the turn, or rebuilds it from a pending redirect.
Review of #147855: a plain Nous 403 entered the transient-401 backoff and waited ~50 s. Only a 401
is the valid-key-refused shape. The episode test now fails on base by its refresh-POST count, not
an ImportError.
The 401 pool refresh compared the store against the pool ROW's key, not the bearer the
request sent. The pre-expiry adoption swaps the agent's key without touching its row, so the
store's key (the one that just failed) looked "peer-rotated" and was adopted with no refresh:
the swap replayed the dead bearer and the 3-refresh cap fired within ~1.5 s. When refreshes
did POST, each 401 re-redeemed the rotating refresh token (4 POSTs per episode).
- credential_pool: thread the failed bearer (api_key_hint) into the Nous refresh; adopt a
store key only when it differs from it, and pass it as stale_access_token.
- New agent/credential_auth_recovery.py (moved out of agent_runtime_helpers): a Nous 401
episode gets exactly one forced refresh; later 401s on the fresh key (or a refresh that
hands back the failing bearer) wait 5/15/30 s and retry with the store's current key,
then fall through to fallback. Entitlement 403s and dead grants still fail fast.
- turn_recovery: the singleton 401 refresh skips its force when the pool already spent the
episode's refresh.
#147819 raised the limits to 65,536 entries / 64 MiB, so closed sessions could hold more than main
said 4,096 entries ever did. Both limits only evict entries idle for 60 s, so lowering them to 4,096 /
16 MiB costs a running conversation nothing.
The housekeeping tick and the TUI idle reaper now call trim_memory_when_idle: allocator trim
only, plus one full gc.collect() once no turn has run in this process for 5 minutes (again
after a later agent close re-arms it). Nobody is waiting then, so the pause harms no one, and
whatever cyclic garbage remains (openai SDK resource cycles) is still reclaimed. The quiet
clock is the existing process-wide live-turn counter in review_idle_queue.
Each turn's DurableTurnLease kept owner -> scheduler handle -> bound method -> owner and
lease <-> liveness-watchdog cycles (delegate heartbeats too), and those cycles held the agent.
Measured on a scratch gateway after 18 delegation turns and a 240 s idle: 17 closed AIAgents
(each with its OpenAI client and compressor) were reachable only through these cycles. With the
timer trims no longer forcing a full collection, Python 3.14's incremental collector (which only
advances on allocation) left them resident on a quiet gateway.
A cancelled or stopped periodic handle now drops its callback and context, and join_threads
drops the lease's watchdog and handles.
Fixes#146375.
agent/context_compressor.py calls trim_memory(reason="post-compression")
after every successful compaction, and trim_memory() always ran a full
gc.collect() before malloc_trim(0). With dashboard.turn_isolation: false
(still the default), the agent turn runs in the same process as the
dashboard's event loop, so a gc.collect() over a large heap holds the
GIL for seconds -- the reporter measured 11 trims over 5s (5-11.6s) in
one week, 8 of them coinciding with "event loop stalled" warnings, with
WebSocket frames queuing and the UI not streaming for the duration.
Verified the proposed fix#2 ("run the trim off the agent thread") would
not help: the reporter's own stack dump already shows trim_memory
running inside a background compaction thread (_run_summary_dispatch),
and gc.collect() is stop-the-world across the whole interpreter
regardless of which thread calls it -- confirmed directly by measuring
a heartbeat on one thread while gc.collect() ran on another: the
heartbeat's worst gap matched the collection's own duration almost
exactly, whichever thread held the GIL. Moving the call to a different
thread changes nothing; the GIL is process-wide.
Implemented the issue's proposed fix#1: added an opt-out collect
parameter to trim_memory(), reviving the same signature already
designed (and apparently working) in #139798 -- closed unmerged by its
author "to stay under the open-PR limit" for a different call site
(gateway housekeeping) that this change does not touch. #139798's own
design note said pressure lanes like post-compression should "keep the
default" (collect=True), reasoning that a collection is what makes the
trim return anything measurable. Measured directly, with the same
reference-cycle heap construction #139798 itself profiled against:
malloc_trim(0) alone (collect=False) still returned real pages in ~3.5ms
versus ~129ms with the collection, and the compacted-away message dicts
this trim targets (replaced list entries, not deliberately-cyclic
structures) are typically already reclaimed by Python's own reference
counting before the trim runs -- so the full collection's marginal
benefit here is smaller than #139798's note implies, and the stall cost
on the default (in-process) configuration is severe. Only the
post-compression call site is changed; #139798's existing gateway
housekeeping path is untouched by this PR, so no conflict with either
reviving that closed PR separately or merging this one standalone.
Scope note: the issue's secondary suggestion (apply the same to the
forced agent-close trim in run_agent.py) is not included here, to keep
this change targeted at the specific, stack-trace-confirmed call site.
Verified directly: measured trim_memory() against a real reference-cycle
heap with a concurrent heartbeat thread standing in for the dashboard
event loop. collect=True: 129.2ms duration, 77.2ms worst heartbeat gap.
collect=False: 3.5ms duration, 13.1ms worst heartbeat gap -- roughly a
37x reduction in both the trim's own duration and its stall on a
concurrent thread.
Added 3 regression tests to the existing tests/hermes_cli/test_mem_trim.py,
following its established gc.collect/_malloc_trim monkeypatch pattern
from the adjacent test_success_collects_then_trims: collect=False skips
gc but still trims; every existing caller (no collect= argument) keeps
the full collection, confirming this is additive, not a behavior change
for anyone else; and the log line surfaces collected=False, matching
Verified as a genuine regression by reverting just the trim_memory()
signature change and confirming both new collect=False tests fail with
TypeError (the parameter genuinely doesn't exist without the fix).
11/11 pass in the modified test file; 299/299 pass in the full
tests/agent/test_context_compressor.py (no regression).
Inserting it evicted every idle entry that fitted, then stayed over the budget itself. It is now
recomputed instead; the dead-bodies test also asserts the active message stays a hit.
Review finding (P2): lookup reordered the memo without the eviction lock, so a hit between the
writer's idle check of the oldest entry and its pop moved that entry to the end and the pop took
the next, recently used one.
A conversation whose own pinned strings exceed the 64 MiB budget (an image-heavy history of base64 data
URLs) was evicting its oldest messages on every pass, so each estimate missed on almost every message
(96 MB image history: 496 of 505 messages recomputed per pass, 17.9 ms instead of 2.1 ms).
Both bounds (retained bytes and entry count) now stop at the first least-recently-used entry looked up
within _ACTIVE_WINDOW_S (60 s). A running conversation overshoots the budget instead of thrashing; the
overshoot is shed by the first insert after it goes idle. Protected entries pin strings the running
conversations hold anyway. The lookup stamp lives on the pins list (MemoPins, a list subclass), so the
(pins, text, images) entry shape is unchanged.
The per-message token-estimate memo pins every string it fingerprints and was bounded only by a
4096-entry FIFO: a hit never refreshed an entry, so a running conversation's estimates were evicted by
dead sessions' bodies, two concurrent 1M-token conversations (2 x 2403 entries) missed on every
message (0% hit, 73 ms per estimate instead of ~7 ms), and the pinned bytes had no bound at all
(4096 entries of any size).
Now the memo is an OrderedDict in model_metadata_token_memo: a hit moves its entry to the end, and
inserts evict from the front past a retained-bytes budget (pinned string bytes + ~120 B of fingerprint
structure per string leaf; 64 MiB default, a real 1M-token history retains ~9 MB) or 65536 entries.
Insert/evict/forget share one lock so the byte count stays exact. Eviction never changes an estimate.
Review fixes for the bounded-cache PR:
- models_pricing: catalog + deadline are expired, swept and published under one
lock, so a refresh landing between a sweep's two pops can no longer keep its
catalog without its deadline (Nous 300 s policy TTL never expiring).
- model_metadata memos: endpoint sweep+publish and both Codex writers
(evict + context/max publish) hold one MEMO_LOCK.
- skill_commands: the per-scope maps share one recency order, touched on every
use, so a scope used for dispatch no longer loses its /reload-skills baseline
and reports unchanged commands as added.
Shed only entries no reader can use, or the least recently used past a count far
above any real working set; nothing a live session needs is ever dropped.
- models_catalog_static: _PROVIDER_MODELS fills its xAI rows from the
process-wide models.dev copy on the first xAI lookup (or a whole-table walk),
never at import. main parsed the catalog at import and threw it away; an idle
gateway now never parses it, and a reader parses it exactly once.
- model_metadata: the per-credential /models memo sweeps expired entries on
write (rotated keys left one catalog each); the Codex OAuth context memos keep
the newest 128 token fingerprints, the bound codex_service_tiers already uses.
- models_pricing: _cache_catalog drops catalogs past their deadline, as the
reader already does for the one key it reads.
- skill_commands: per-(platform, profile, project) command maps are one LRU of
64 scopes across all three tables; an evicted scope rescans on next use.
- auxiliary_client: async semaphores are held per event-loop object and a closed
loop's table is dropped on the next acquire (main keyed by id(loop) and kept
every loop forever, and a weak key cannot work: a semaphore that made a caller
wait binds its loop). Checked on stdlib asyncio and uvloop 0.23.
- agent_runtime_helpers: the sanitizer-heal log counters are an LRU of 1024
sessions; the told-once set and pending notices are never evicted.
Helpers live in agent/cache_bounds.py and agent/model_metadata_memo_bounds.py;
model_metadata.py does not grow.
- Newlines separate commands (shlex read them as whitespace, so a second-line `sed -i` hid
behind an `echo`).
- Wrapper options that take a value (`sudo -u root`, `xargs -n 1`) are skipped, reusing
self_repo_guard's wrapper table.
- `( ... )` subshells restore the working directory when they close.
- `cp/mv/install/ln -t DIR` and `--target-directory=DIR` are the write destination.
- Recursive copies (`cp -r`, rsync) and archive extraction into a directory above a locked skill,
inside a skills root, are refused: they can merge into it.
- Globs expand against the filesystem like the shell does, so `sed -i ... ops/*/SKILL.md` is
judged by what it matches.
- The curator's auto-archive check resolves rows (frontmatter names) to the directory-keyed lock
via tools/skill_lock.is_locked_skill.
Builds on the per-skill lock record (`hermes curator lock`): the lock now holds against the
agent everywhere, not only the background passes.
- skill_manage refuses every mutating action on a locked skill for every origin (normal turns,
cron, subagents, review fork, curator); a corrupt sidecar still fails closed only for the
autonomous passes so one broken file can't freeze every skill edit.
- write_file / patch hard-refuse any path inside a locked skill's directory and the lock
record (skills/.usage.json) while any skill is locked (tools/skill_lock.path_refusal, wired
into _check_sensitive_path).
- terminal refuses, before approvals and under --yolo, commands that write into a locked skill:
redirections/tee, cp/mv/rm/touch/mkdir/chmod, sed/perl -i, git changes in its tree, archive
extraction into it, inline python/bash code naming it, including after a cd into it; and the
agent running `hermes curator unlock`. Reads and running the skill's own scripts still work.
- The curator never auto-archives a locked skill.
- Docs: "Locking a skill" rewritten for the new contract.
`hermes curator lock <skill>` records `locked: true` beside `pinned` in the
active profile's skills/.usage.json. While locked, skill_manage refuses
patch/edit/write_file/remove_file/delete on that skill when the write origin
is the background review fork or the curator consolidation pass, for the
whole skill directory and on both the single-op and the batch path. The
skill stays readable, listed and auto-loadable; foreground user-directed
writes are not gated; unlocked siblings keep learning.
- tools/skill_usage.py: set_locked / is_locked (strict: a corrupt sidecar
raises instead of reading as unlocked) / locked_skill_names
- tools/skill_manager_guards.py: _locked_guard, wired into
_background_review_preflight ahead of the delete guard; fails closed on
an unreadable sidecar instead of silently relaxing the lock
- hermes_cli/curator.py: `curator lock|unlock`, locked list in `status`
- agent/background_review.py: one prompt sentence so the fork does not
retry or recreate a refused locked skill
- docs: curator.md "Locking a skill's content" section, line 47 corrected
(pins block deletion only, #141673), skills.md pointer
Related: #140332, #142933, #89961
Code Health PRV-09 (plan C1.1), part 2. set_runtime_main() has bound the
turn's main route in a ContextVar since overlapping gateway sessions made a
process global unsafe, but it kept publishing six _RUNTIME_MAIN_* mirror
globals plus a compat snapshot under a lock, and the lookup fell back to
them through _compat_runtime_main() whenever the context variable was unset
on the main thread. Normally that returned None (mirrors equal to the
snapshot), but the publisher stored the six fields one at a time and readers
took no lock, so a main-thread lookup racing another session's
set_runtime_main could read that session's runtime, or one session's base_url
paired with another's api_key (reproduced: tens of thousands of non-None
reads in 3s with a fast switch interval). The mirrors, snapshot, lock,
_publish_runtime_main_mirrors and _compat_runtime_main go; the lookup reads
only the context variable.
Tests that patched the mirrors bind the runtime with scoped_runtime_main()
instead (test_auxiliary_main_first x3, test_auxiliary_client x1); the OAuth
rotation test asserts the outer binding survives a scoped rotation instead
of asserting on the mirrors. The salvaged per-test restore fixture (#134236)
now snapshots just the context variable. New
test_aux_runtime_main_context_only.py: none of the deleted names exist (fails
on prior main), a binding made on another thread never reaches this one, and
a scoped binding is gone after its block.
Closes#105888 (the leaked mirror state is gone; the fixture covers the
context variable, which one pytest process shares across tests).
Code Health PRV-09 (plan C1.1), part 1. auxiliary_is_nous was a process
global written from any thread every time the auto route resolved (reset at the
top of the chain, set by _try_nous), and its only reader was
get_auxiliary_extra_body(), which nothing outside tests calls: Nous product
tags have ridden per call through _build_call_kwargs since #45801. Both go,
with _nous_extra_body(), whose only caller was get_auxiliary_extra_body().
Tests: the two tag-scoping tests no longer patch the global (they already
exercise the per-call path); the non-Nous one now binds a Nous main runtime,
so tags keyed on the main route instead of the call's provider would fail it; the welcome-host contract drops its assertion on
the global (the route it pins is still asserted by base_url and model); the
kanban-decompose and profile-describer tests drop patches of the deleted
function, which were inert (call_llm is already mocked).
Search: no plugin or other NousResearch repo imports either name (only
forks carrying their own copy of this module).
test_a_killed_owner_takes_the_fetch_helpers_with_it polled the helper with
_alive(): signal 0, then /proc/<pid>/stat exists(), then read_text(). Once
the owner is killed the helper is an orphan and its reaper can collect it
between any two of those steps, so the read raised FileNotFoundError
(seen on CI) instead of reporting the exit the test was waiting for. Read
once and treat FileNotFoundError / ProcessLookupError as gone.
Same check-then-read in iron_proxy._pid_alive: when the proxy exits between
the existence probe and the /proc/<pid>/cmdline read, the read was skipped,
`ps -p` then failed, and the function fell through to "believe the OS:
alive", so a dead proxy blocked start_proxy and showed as running. On Linux
a missing /proc entry now means gone. New test is red on base.
The backend's `i18n.languages` lists every language it translates
anywhere. Seventeen are bundled for core messages and the TUI, but the
Desktop bundles only nine. The other eight (af, ga, hu, it, ko, pt, tr,
uk) were added to the Desktop picker anyway, with no Desktop strings
behind them. Picking one saved `display.language` and the UI stayed in
English: a Korean user picking 한국어 saw no change.
Each `i18n.languages` row now carries `surfaces`: the surfaces some
layer has strings for. These come from the bundled
`locales/<lang>[.<surface>].yaml`, the user overlay and plugin packs,
which already record their (lang, surface) pairs. A layer that loaded no
strings (an empty, comment-only or unparseable file, or an empty pack)
does not count.
`agent.i18n.language_surfaces()` builds the map from those records. The
overlay cache now stores the pairs instead of bare ids, and
`overlay_languages` derives from it.
The Desktop registers a backend language it does not bundle only when
`desktop` is among its surfaces. A language pack with a Desktop catalog
(hermes-lang-ko) and a user overlay `<lang>.desktop.yaml` both still
show up. Rows from older backends (no `surfaces`) are kept as before. A
saved `display.language` the Desktop cannot render is left as it is for
core and the TUI; the Desktop falls back to its OS-locale inference, as
it already does for any unrenderable value, and does not save over it.
Introduced in 9bcbe7b5df (#126296).
Clarify questions went through the command escaper, so ordinary prose
showed VS16, ZWJ and ZWNJ as escapes ("⚠\ufe0f Which branch?", Persian
words split by \u200c). sanitize_command_for_display/redact_approval_display
gain prose=True: it still surfaces controls, bidi embeddings/overrides/
isolates, line/paragraph separators and padding, and leaves emoji and
script joiners alone. Choices now get the same display copy; a picked
choice maps back to its raw text by position, so the model still receives
the raw question and answer. Commands keep the strict escaper.
The tool-progress line under the approval prompt, the ACP edit-approval
title, the clarify question's first render and the human-input observer
prompt now go through redact_approval_display like the approval prompt
itself. Display copies only: the executed command, the clarify tool result
and its answer values, and the ACP diff path stay byte-identical.
Selected plugin transports already receive the display copy of command and
description; the new invariant test pins that too.
Review findings on the approval display sanitizer:
- Every control/format/private-use/unassigned code point (category C*), line and
paragraph separators, variation selectors incl. U+E0100-E01EF, Hangul fillers and
U+2800 now render as escapes; ordinary non-ASCII text is untouched. Four or more
repeats of one such code point show once with a count.
- Runs of whitespace-only lines collapse like bare blank lines; the next line keeps
its indentation.
- Consent-prompt descriptions (MCP subscriptions/trust, vault payment) go through the
same display redaction on the messaging gateway, TUI/Desktop and API egresses.
Display only: the executed command is unchanged.
A dangerous command can carry content that renders as nothing: zero-width
and bidi-override characters, the U+E0000 tag block, raw ANSI/OSC escapes
or a bare carriage return, or a few hundred (ASCII or Unicode) spaces that
push the real tail off screen or past the 200-char chat preview. The human
then approves something other than what runs.
agent/redact.py gains sanitize_command_for_display() (hidden characters ->
visible \uXXXX / \xNN escapes, padding -> an explicit marker, legit
indentation and tabs/newlines untouched) and redact_approval_display()
(secret redaction + sanitize). Every approval mint site uses it: the CLI
prompt and its callbacks, the gateway notify payload, the execute_code
pending body, plugin approval transports, and gateway.run's
_redact_approval_command seam, which feeds messaging cards, TUI/Desktop
and the API server. Display-only: the executed command, smart assessment
and allowlist keys are unchanged.
A vetoed user row stores the withheld placeholder as its content, so /retry
(CLI, TUI, gateway, ACP, Desktop) re-sent the placeholder as a new prompt and
/undo pre-filled it into the composer. A rewind's live view and its receipt now
swap the placeholder back for display_metadata.withheld_prompt: /retry
re-submits what the user typed, so the hook decides on it again, and /undo
restores it. Stored rows, compaction and search are unchanged.
finalize_turn still ran micro-compaction and the prepare-ahead summary after
a pre_llm_call veto, so with micro_compact on, a turn reported as api_calls=0
made an auxiliary model call (loopback probe: 1 aux POST -> 0). Both now skip
a vetoed turn, like the memory sync and review already did.
A pre_llm_call veto kept the typed text as the user row's content and put
the placeholder only in api_content, which only the main-loop wire replay
reads. Compaction (summary request and handoff), session_search, external
memory providers and the routed background-review digest all read content,
so the vetoed prompt reached a model at the next compaction or search.
- The placeholder is now the row's content and the persist override; the
typed text lives only in display_metadata.withheld_prompt, which the CLI
resume recap, TUI/Desktop session history and the dashboard render.
- A row the TUI/Desktop wrote at submit time is rewritten in place
(set_user_message_content gains an optional display_metadata, also on the
managed-worker store op).
- The hook now runs before turn-start compaction and a blocked turn skips
it: that summary request quotes recent user turns, this one included.
- Memory-provider transcript hand-offs drop the display-only key.
A pre_llm_call callback (Python plugin or shell hook) may now return
{"action": "block", "message": "..."} to veto the turn: no model call is made,
the message is the reply the user sees and the transcript keeps a normal
user -> assistant pair, and the result carries
turn_exit_reason=blocked_by_plugin_pre_llm_call. This is the supported seam for
DLP / privacy / policy plugins that previously had to patch core (#57364).
The vetoed prompt also stays on the host for that turn: no session titling call,
no external-memory prefetch or sync, no background memory review. Its user row
gets an api_content placeholder for the main-loop replay. That alone does not
keep the prompt out of later turns (compaction, session_search and memory
providers read the row's content); the next commit stores the placeholder as
the content.
First valid block wins; a Python block without a message is ignored (same as
pre_tool_call). Shell hooks accept both the Hermes {"action": "block"} and the
{"decision": "block", "reason": ...} shapes, mirroring pre_tool_call.
A kill that lands during the retry backoff (the attempt id is unchanged until the next
attempt starts) hit an attempt the worker already returned from, yet counted toward the
wedged-worker give-up: a healthy call was abandoned and its orphaned worker sent one more
request. With the cap at the stale timeout, the stale and cap checks also counted the same
silent window twice and the cap check abandoned again after the call ended, replacing the
stale error with the cap copy.
The worker now records the attempt it caught an error for; kills of that attempt are not
counted and the cap does not cut it. A stale kill restarts the cap clock, and the cap check
stops once the call is done.
A cap kill cancelled the attempt but skipped the same-attempt kill count that
stale kills use, so with the stale detector off a request parked outside the
socket read was re-cut every cap window and the turn never ended. Both kill
paths now share _note_attempt_kill: after _STALE_ABANDON_KILLS kills of one
attempt a worker thread is abandoned (error names agent.stream_max_lifetime)
and an inline call stops claiming liveness. Cap kills still never emit the
stale reconnect notice nor feed the stale breaker.
Drops the HERMES_STREAM_MAX_LIFETIME override (non-secret behaviour settings
belong in config.yaml) and its docs row; tests now set agent.stream_max_lifetime
in a temp HERMES_HOME config.yaml and read it through the real loader.
The monitor thread that runs the stale check, the lifetime cap and interrupt
polling died silently on an unexpected exception, leaving the stream
unwatched. Log it with a stack trace, and log the armed stale/cap values at
debug level so agent.log shows which limits a call ran under.
Co-authored-by: krzsda <krzysztof.siuda@pm.me>
A stream cut by agent.stream_max_lifetime was counted as a stale kill, so two
capped long replies latched HERMES_STREAM_STALE_GIVEUP and the next healthy
request was refused with nothing sent. The cut also surfaced as a transport
error ("stream attempt N was superseded", "the endpoint looks unreachable").
- cap kills are marked accounted in the stale breaker but never counted;
- the killed attempt's error becomes StreamLifetimeExceeded (a TimeoutError,
so still retried) naming the setting, and the exhausted notice uses it;
- docs say which transports the cap covers (Chat Completions and Anthropic
Messages; not Codex/Responses or Bedrock) and that it skips the breaker.
The stale-stream detector bounds the gap BETWEEN chunks and resets on every
chunk, so a stream that keeps sending data but never finishes (a gateway
trickling chunks, a runaway generation) is never cut and the turn sits there.
New opt-in agent.stream_max_lifetime (env HERMES_STREAM_MAX_LIFETIME), default
0 = off, so long reasoning streams keep today's behaviour unless the user sets
it. When set, the cap is charged from the start of the current stream attempt,
never resets on chunk arrival, restarts for each retry attempt, and is floored
at the effective stale timeout. Tripping it kills the attempt like a stale
kill: cancel the attempt, abort the request-local client, shut down its socket,
count it once in the cross-turn stale breaker; the retry loop or the
partial-delivery continuation takes over.
Logic lives in agent/stream_max_lifetime.py; the stream monitor calls it from
its poll loop. The Bedrock poll loop is not covered (chat_completion_helpers.py
may not grow).
Port of an upstream idea.
When Relay rewrites a tool call before Hermes' own pipeline runs,
tool_request middleware received the Relay-rewritten args as
original_args, while tool_execution middleware already got the model's
call (function_args). Pass function_args through as original_args so both
middleware kinds see the same pre-Relay snapshot.
Sequential chaining of request rewrites itself landed in f67d490f71
(#133159); this keeps only the remaining pre-Relay delta of #82092.
Review finding on #80788: the grounding rule listed only 'always' /
'from now on' / 'remember' as markers of a general preference, which a model
can read as a required keyword list and drop "stop putting emojis in
everything, I hate that". Name a stated like/dislike as general too. A one-off
"make that one shorter" is still not saved. +18 prompt tokens per memory review.
The memory review prompts gave no criterion for what counts as a saveable
fact, so the review fork saved guesses as durable memory: a one-off "make
that shorter" became "User prefers concise responses", and incidental
remarks became profile entries.
Add one store-neutral rule to the shared memory routing block (so both the
memory-only and combined prompts carry it; the skill prompt is untouched):
save only facts a user message or tool result supports, never infer traits
or preferences from indirect signals, never promote a one-off request to a
standing preference unless the user marked it general. Scoping it to
USER.md alone just moved the same guess into MEMORY.md in a live run.
+420 chars (~95 tokens) per memory/combined review run.
Review findings on #80873:
- _timeout_phase walked __context__ too, so an HTTP error raised inside an
`except ReadTimeout:` block (e.g. a 401) was reported as a timeout. Walk only
the explicit __cause__ chain (the SDK's `raise APITimeoutError from err`).
- PoolTimeout / WriteTimeout mean the provider never got to answer; they now
keep the existing summary instead of the "waiting for the provider" hint.
- The read-timeout hint prints providers.<agent.provider>.request_timeout_seconds
when called on an agent; class-level calls keep the <provider> placeholder.
A timeout that survived the retry loop surfaced as the SDK's bare text:
"Request timed out." (openai APITimeoutError) or "timed out" (raw httpx
ReadTimeout mid-stream). Neither said whether a connection was ever made or
which setting to raise.
agent/timeout_error_summary.py reads the phase from the most specific
exception in the cause chain (the openai SDK wraps connect timeouts in
APITimeoutError too) and returns one line per phase:
- connect: "Connection to the provider timed out before it was established
(check the base_url and network path)"
- read: "Request timed out waiting for the provider to respond (if the model
needs longer, raise providers.<provider>.request_timeout_seconds ...)"
Both keep the "timed out" wording that cron failure notices and the error
classifier match on. Non-timeout errors fall through unchanged.
ApiErrorSummaryMixin._summarize_api_error consults it after the offline check;
its signature and every caller are unchanged.
Port of an upstream idea.
The agent can write cache/ and runtime/, so a file there may be a link or a
forged record. Hermes now deletes a Bitwarden or 1Password cache in cache/, or
a Photon sidecar record in runtime/, on first use without reading it, and
reads and writes only the copy at the top of the profile home. All four stores
are regenerated on use.
- Remove utils.adopt_legacy_file and the paths built on it.
- home_data_layout: split SECRET_CACHE_STORES into SECRET_CACHE_FILES and
LEGACY_SECRET_CACHE_PATHS.
- Backups leave out the four top-level names; the old slashed entries never
matched a root entry.
- The dashboard Files API takes its hidden names from the shared list.
RedactingFormatter resolved a routed profile's redaction policy per
record from config, under the logging handler's lock. It now reads only
in-memory state: the live secret scope, and the policy recorded when that
profile's .env or config is loaded, or when log routing is set up for it
(resolve_profile_policy). Unknown means redact, the secure default.
This removes load_config_readonly_nowait() and the no-boot read scope.
RedactingFormatter reads a routed profile's redaction policy from config
while holding the logging handler's lock. A thread holding _CONFIG_LOCK
(for example one booting a remote profile) that logs then waits for the
handler lock: a lock-order cycle. On the booting thread itself the read
re-entered the boot and ConfigBackendUnavailable escaped the formatter.
load_config_readonly_nowait() returns None instead of waiting: when
_CONFIG_LOCK is held by another thread, or when the read would start a
remote boot fetch (config_backend.without_boot()). The formatter then
redacts (the secure default) and does not cache that answer.
The remote backend's lock-order tests move to their own file.
With the main model on the managed llama.cpp runtime and its server down
(Desktop closed and took it along, still loading, or switched off),
setup.runtime_check answered ok:false while setup.status said a provider
is configured. The onboarding gate wrote that down as "not configured" and
opened the provider sign-in overlay, and a send got an "Update API key"
card: the resolution failure was stamped auth_permanent.
The resolver now raises a typed LocalRuntimeUnavailableError. Both
setup.runtime_check backends answer it with error_code
local_runtime_unavailable, the onboarding gate keeps the app open and
shows a "Local model unavailable" notice with Open Local models, and the
turn failure carries reason local_runtime_unavailable on the endpoint
layer, so the card says the model server is unreachable and offers
Switch provider.
Review round on cron cancel / missed-run policy:
- Receipt recovery, the external-worker waiter and finish_completed_run
read only completed/failed as "the firer booked this attempt". A
cancelled agent run was replayed (job marked failed, repeat spent,
failure notice sent) and a cancelled detached worker was reported as a
worker that died without terminalizing. One FIRER_FINISHED_STATES set
now drives all four readers.
- live_inflight_execution skips the due scan's `missed` rows, so a
missed note booked while a long run is live no longer hides that run
from the dashboard.
- Stopping a ladder re-run passes ladder_rung, like every other terminal
path, so it does not spend a second repeat slot.
- A run whose claim vanished because the job was removed (marker
written, claim dropped) books `cancelled` with the reason at the
first claim check and on the post-run claim-loss path, not
"Fire claim ownership lost".
- request_cancel publishes a private temp file with link(), so
overlapping requests never share a temp path or overwrite the first
reason.
- Monitoring: cron_health knows `cancelled`/`missed` as terminal
statuses, and the shared cron-run metric reports `cancelled` instead
of `failed`.
- Dashboard history: a cancelled agent run's session row carries
"CANCELLED · <reason>".
- A capped missed count keeps its "counting stopped at 1000" note after
the catch-up branch books one fewer than it counted.
The Bitwarden and 1Password disk caches (bws_cache.json, bws_cache.enc.json,
op_cache.json) and the Photon sidecar runtime record (photon-sidecar.json) now
live directly in the profile home instead of cache/ and runtime/. A sandbox
that hides credential files by path can only hide them safely at the top of
the home: the agent can rename a folder it writes, such as cache/ or runtime/,
and read a hidden file below it at the new path.
The first read moves a copy from the old path with a rename, so the file keeps
its permissions. When both copies exist, Hermes removes the old one; when the
move fails, Hermes keeps reading and writing the old copy, so only one copy is
ever live. Clearing a cache or deleting the record removes both locations.
SECRET_CACHE_STORES in hermes_cli/home_data_layout.py lists these stores at
both locations, and every guard that keeps a list of credential stores uses
it: PROFILE_CREDENTIAL_PATHS (profile export and distribution), the file
tools' read and write denies, and the gateway's media-delivery deny. The
1Password cache was missing from all of them. The dashboard Files API blocks
the new basenames, backups leave the top-level stores out, and the flat-install
.gitignore ignores them.
A new test takes each store's path from its writer and checks that every guard
covers it at the current and the old location.