Commit Graph
1955 Commits
Author SHA1 Message Date
Rod Boev 6cb55b5df8 Keep session cache invalidation signals live across the routes extraction 2026-06-26 18:36:07 +00:00
Rod Boev 47485b3a82 Preserve route-level cache overrides after helper extraction 2026-06-26 18:36:07 +00:00
Rod Boev 1bffabbfec refactor(routes): extract session-list cache helpers from api/routes.py (#1907) 2026-06-26 18:36:07 +00:00
Rod Boev 781223fa18 fix(agent): keep real checkouts ahead of pip-style lookalikes (#4700) 2026-06-26 17:15:03 +00:00
Rod Boev b4dadc9939 fix(#4700): recognize nested pip-style agent roots 2026-06-26 17:15:03 +00:00
Rod Boev b5d462812c fix(#4700): recognize pip-style agent roots for cron imports 2026-06-26 17:15:02 +00:00
nesquena-hermesandfranksong2702 f8c4d50950 harden(#4991): session_id max() tiebreaker + membership-completeness doc (Opus gate findings)
Co-authored-by: franksong2702 <franksong2702@users.noreply.github.com>
2026-06-26 16:40:27 +00:00
Frank SongandPaperclip d68760b288 Prove continuation index completeness before trusting it
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-26 16:27:40 +00:00
Frank SongandPaperclip eda4c50cf5 Handle stale compression continuation index fallback
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-26 16:27:40 +00:00
Frank Song 0f87757a47 Use session index for compression continuations 2026-06-26 16:27:40 +00:00
nesquena-hermes 903dabd29b fix(providers): strip Anthropic env values so whitespace-only OAuth tokens don't false-positive (#4995 gate finding) 2026-06-26 15:44:15 +00:00
Rod Boev 06902d8038 fix(providers): detect Anthropic OAuth credentials in WebUI parity paths (#4770) 2026-06-26 15:34:59 +00:00
Rod Boev f36a427872 fix(models): make session-index rebuild thread ownership explicit (#3894) 2026-06-26 15:13:41 +00:00
Frank SongandPaperclip f15f178b5e Guard state db prefix keys with tool calls
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-26 10:43:28 +00:00
Frank SongandPaperclip 7a38b09af1 Fix lint for state db prefix key guard
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-26 10:43:28 +00:00
Frank SongandPaperclip fd81b6cb08 Guard state db tail reads by prefix keys
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-26 10:43:28 +00:00
Frank Song dc9d6275cb Address state db tail-window coordinate guards 2026-06-26 10:43:27 +00:00
Frank Song 91f7e7f816 Address state db tail window review 2026-06-26 10:43:27 +00:00
Frank Song 8bd31891e3 Bound state.db reads for paginated session loads 2026-06-26 10:43:27 +00:00
nesquena-hermes 2f7c5f01ee fix(#4973): replace per-request diagnostics Timer with a process-global watchdog thread
A threading.Timer per RequestDiagnostics spawns one OS thread per request, held
alive until finish() cancels it. Under sustained /api/sessions poll load this
exhausts the per-process thread cap (RuntimeError: can't start new thread) and
the server stops accepting connections. Replace with a single lazy-init
watchdog daemon thread that scans pending diags every ~1s; public API
unchanged. Caps timeout-tracking at 1 thread/process regardless of request rate.
2026-06-26 07:58:13 +00:00
nesquena-hermesandb3nw 74cee77738 fix(approval): stale local approval card clears instead of dead-ending (#4948 local variant, #4771 follow-up)
On the default local in-process backend, an approval card whose stream
ended while still pending (cancel/fork/provider-error/completion) left the
agent queue entry dropped and the _pending mirror reconciled away. Clicking
Approve/Deny then sent an approval_id that matched nothing, so the handler
returned a bare {ok:false}; since #4771 the frontend surfaces that as
'Approval response not accepted.' with a stuck card (reported by
@santastabber on v0.51.666 and b3nw).

Distinguish a genuinely stale card (no pending approval for the session ->
benign {ok:true, stale_cleared:true} so the UI clears the orphan) from a
stale-id click made while a DIFFERENT approval is live (still ok:false so it
can never resolve the wrong command -- #527 guard preserved). Frontend
clears the orphan card on stale_cleared even if the displayed id drifted.

Co-authored-by: b3nw <b3nw@users.noreply.github.com>
2026-06-26 06:46:22 +00:00
Rod Boev 3979ea6023 fix(sidebar): restrict cron pre-aggregation to missing-index scans 2026-06-26 03:06:40 +00:00
Rod Boev 810707d47a fix(sidebar): gate cron pre-aggregation to large scans 2026-06-26 03:06:40 +00:00
Rod Boev eb10cecf0b fix(sidebar): keep cron candidate ordering scoped 2026-06-26 03:06:40 +00:00
Rod Boev 709086a29b docs(sidebar): update the index-prime rationale 2026-06-26 03:06:40 +00:00
Rod Boev 814fe56150 perf(#4842): pre-aggregate latest-message ordering for cold CLI scans 2026-06-26 03:06:40 +00:00
Rod Boev 97b551c528 fix(cli): restore all-profiles session scans after the cache rework (#4842) 2026-06-26 02:43:11 +00:00
Rod Boev 0301c8f8d2 fix(cli): keep CLI cache followers from hanging or dropping rows (#4842) 2026-06-26 02:43:11 +00:00
Rod Boev 8f0ede0e8b Make cache invalidation atomic across rebuild stores 2026-06-26 02:43:11 +00:00
Rod Boev 5b29b97993 Keep the retry path valid under ruff 2026-06-26 02:43:11 +00:00
Rod Boev 9130edbc31 Keep CLI cache rebuilds singleflight across invalidation 2026-06-26 02:43:11 +00:00
Rod Boev 6a5a514e8c Keep the review branch publishable 2026-06-26 02:43:11 +00:00
Rod Boev c1bb1a42e9 fix(#4842): stop lock-held CLI cache rebuild stalls during streaming 2026-06-26 02:43:10 +00:00
Frank Song 5b0e409d3b Handle equal-timestamp tool-call tail ordering 2026-06-26 02:18:18 +00:00
Frank Song 7e8834d8ca Fix tool-call tail ordering in session merge 2026-06-26 02:18:18 +00:00
Rod Boev 61ea7360a0 fix(#4536): reject openai-codex provider before empty-model early return 2026-06-26 01:46:57 +00:00
Rod Boev 2f2d36d4eb fix(#4536): gate service tier on effective send model, not saved default 2026-06-26 01:46:57 +00:00
Rod Boev 4d64c18832 fix(#4536): block Codex models from priority service tier 2026-06-26 01:46:57 +00:00
Rod Boev 6f9d23eb48 fix(#4536): gate service tier to real OpenAI model ids 2026-06-26 01:46:57 +00:00
Rod Boev a340c69b08 fix(#4536): clear stale service tier on model switch 2026-06-26 01:46:57 +00:00
Rod Boev 24cf7069a6 fix(#4536): persist OpenAI priority tier in main model settings 2026-06-26 01:46:57 +00:00
Frank Song fda5a241b2 Fix sidebar reconciliation review issues 2026-06-26 00:36:15 +00:00
Frank Song 0e2214b6bd Fix WebUI state.db session reconciliation 2026-06-26 00:34:58 +00:00
Frank Song 6079b7ba24 Address compaction marker and redaction review 2026-06-26 00:12:09 +00:00
Frank Song 9f0864ea82 Fix compaction marker writeback and code redaction 2026-06-26 00:12:09 +00:00
nesquena-hermes bac8108b38 fix(#4771): don't 409 local approvals as "gateway run unavailable"
#4771 added an explicit relay-failure 409 (code: gateway_run_unavailable)
to /api/approval/respond so a gateway approval whose run is gone keeps its
card actionable instead of silently failing. But the 409 was emitted
regardless of backend.

On the DEFAULT local in-process backend, every guarded command parks an
entry in tools.approval._gateway_queues (via _await_gateway_decision), and
the local streaming notify callback mirrors it into _pending tagged with
_GATEWAY_MIRROR_FLAG. There is no gateway run and no _STREAM_RUN_IDS entry
by design. _gateway_pending_approval_without_run_id() therefore returned
True for that purely local approval, so the handler 409'd
("active run unavailable") and refused to resolve an approval that resolves
perfectly well locally. Local-backend users hit this on every approval
click (reported by b3nw on Discord; independently filed as #4948 by
claw-io, which also notes the local-runtime trigger).

Fix: gate the 409 on the WebUI actually running the gateway chat backend
(webui_gateway_chat_enabled). Local approvals fall through to the local
resolution path; the legitimate #4771 gateway behaviour is unchanged.

Tests:
- New tests/test_issue4771_local_approval_regression.py drives the real
  _handle_approval_respond handler and asserts: local backend -> 200 +
  agent thread unblocked; gateway backend -> 409 preserved. These fail
  before the fix (409) and pass after.
- The two existing #4771 tests that asserted the 409 are updated to pin
  HERMES_WEBUI_CHAT_BACKEND=gateway at respond time, since the 409 is now
  gateway-deployment behaviour.

Reported-by: b3nw
Reported-by: claw-io (#4948)
2026-06-25 22:21:56 +00:00
nesquena-hermes 7791370d49 docs(#4908): correct cache-invalidation comment per Opus gate — TTL is the backstop for externally-driven changes
Opus SHIP-WITH-FIXES (no code change required): the comment/docstring overstated
that the session-list-change listener covers ALL structural mutations. In-app
mutations fire it, but externally-driven changes (scheduled cron completion,
external CLI writes) don't — for those the 30s streaming TTL is the load-bearing
backstop (≤30s bounded, self-healing lag). Comment-only accuracy fix; logic
unchanged (both gates: perf fix correct, freeze effective, staleness bounded).
2026-06-25 21:57:36 +00:00
nesquena-hermes b87a605306 perf(#4842): freeze the CLI/cron sidebar cache key during streaming
/api/sessions re-ran the expensive CLI/cron session projection on every
poll while a turn was streaming — a major cause of the multi-second sidebar
latency + 100% CPU on cron-heavy installs (continuing #4672/#4808/#4889).

Root cause: the CLI/cron projection is gated by _CLI_SESSIONS_CACHE, whose
key folds in _sqlite_file_stat_cache_key -> _sqlite_content_fingerprint
(MAX(rowid) FROM messages). During a live turn the gateway writes a message
row per streamed delta, so that fingerprint advances on essentially every
~5s poll — busting the cache and re-running the full candidate-join +
projection (and the lineage-metadata pass) on every poll, contending for the
same SQLite/global lock the streaming worker holds.

The route-level session-list cache already froze its key during streaming
(#4808 _session_list_cache_streaming_freeze_marker), but that freeze never
reached this inner CLI-sessions cache, so the heavy CLI/cron query still
re-ran whenever the outer cache validated.

Fix: while any stream is active, the CLI-sessions cache key folds in the same
stable streaming-freeze marker (keyed only on the set of active stream ids)
instead of the volatile content fingerprint, and the cache TTL widens to a
streaming window. The projection is reused across polls mid-stream and
rebuilt at most once per window. The instant a stream starts/stops the marker
changes, so freshly-finished rows surface promptly. Structural mutations
(cron completion, new/renamed/archived sessions, attention) now also clear
the CLI cache via the existing session-list-changed listener — those signals
never fire per streamed token, which is what makes the freeze safe.

Idle behavior is byte-identical (freeze only engages with active streams).
Applies to both the active-profile and all-profiles cache paths.

Adds tests/test_issue4842_cli_sessions_streaming_freeze.py (6 tests): marker
idle/stable/changes semantics, the core 'key stable across message writes
while streaming' guarantee, idle key still advances with the fingerprint,
streaming TTL > idle TTL, and the structural-mutation listener clears the
CLI cache.
2026-06-25 21:57:36 +00:00
nesquena-hermes 0562bdbd31 fix(#4933): one-click extension install works with no env (bootstrap managed default root)
Settings -> Extensions offered an Install button even when extensions were
unconfigured, then dead-ended on 'Extensions not configured' because
install_extension required HERMES_WEBUI_EXTENSION_DIR to be set to an existing
directory. Default to a WebUI-managed root under STATE_DIR/extensions and
bootstrap it on first install so install just works with zero config; the env
var remains an optional override (never auto-created). Gallery-installed
extensions already auto-load via the runtime manifest, so the extension loads
on the next app-shell render with no further setup.

- api/extensions.py: _default_extension_root + _writable_extension_root;
  _extension_root/_extension_root_status fall back to the managed default;
  install_extension bootstraps via _writable_extension_root; dir-unavailable
  warning only fires for an explicitly-set-but-broken env path.
- tests: update disabled-by-default expectations (configured=True, valid=False
  pre-install) + new regression proving install bootstraps + auto-loads with
  no env.
- docs/EXTENSIONS.md: document zero-config one-click install + env now optional.
- CHANGELOG [Unreleased].
2026-06-25 18:45:09 +00:00
nesquena-hermes bd6e57fb42 fix(#4928): don't cap tool-call content args to 120 chars
Tool-call args were truncated to 120 chars at three sites (_truncate_tool_args,
the live _tool_args_snapshot in api/streaming.py, and _toolArgsSnapshot in
static/ui.js). For incidental args that's fine, but content/diff-bearing keys
(command/cmd/script/code/patch/diff/old_string/new_string/content/path/
file_path) feed the rendered tool card AND the diff reconstruction in
recovery-rebuilt sessions, so the cap silently corrupted long commands/paths and
produced broken/empty diffs. Exempt those keys with a much larger cap
(_TOOL_ARG_CONTENT_CAP = _TOOL_RESULT_SNIPPET_MAX = 4000) at every site, keyed by
key name; incidental args keep the 120 cap; storage stays bounded. Part of #4925.
2026-06-25 18:18:17 +00:00