feat(runtime): add default-off RuntimeAdapter seam - #2424
Michaelyklam wants to merge 1 commit into
Conversation
|
I checked this against the current #1925 map and the merged #2416 Slice 2 seam contract. LGTM for the first code seam:
Verification from an isolated PR worktree: No #1925 blocker from me. I would keep the next slice after this just as narrow: either adapter-backed observation/status wiring or one control-specific migration, not runner/sidecar execution ownership yet. |
|
@nesquena Ready for independent review when you have a moment. CI is green; staging this for the next batch release once approved. |
nesquena
left a comment
There was a problem hiding this comment.
Review — end-to-end ✅ (clean APPROVE, no fix pushed)
What this ships
First concrete Slice 2 implementation of the RuntimeAdapter seam, immediately following the RFC contract merged in PR #2416.
api/runtime_adapter.py(+223 new):RuntimeAdapterprotocol + 5 frozen dataclass payload types + 2 mode helpers (runtime_adapter_mode,runtime_adapter_enabled) +LegacyJournalRuntimeAdapterfacade.api/routes.py(+49/-9):/api/chat/startforks onruntime_adapter_enabled(); flag-off path is byte-identical to pre-PR; flag-on path wraps the same_start_chat_stream_for_sessioncall in adapter shape.tests/test_runtime_adapter_seam.py(+121 new, 5 tests).CHANGELOG.md(+4).
Refs #1925, builds on #2283 (run-journal) and #2416 (seam contract). CI green on 3.11/3.12/3.13.
Traced against upstream hermes-agent
Pulled a fresh tarball. No cross-tool surface — the adapter facade delegates entirely to existing WebUI handlers (_start_chat_stream_for_session) and reads from the existing api/run_journal (#2283). No agent-side API change, no config.yaml schema change.
End-to-end trace
Mode parsing at api/runtime_adapter.py:177-181 — strict allow-list:
def runtime_adapter_mode(environ: dict[str, str] | None = None) -> str:
source = os.environ if environ is None else environ
raw = str(source.get(_RUNTIME_ADAPTER_ENV, _RUNTIME_ADAPTER_DIRECT) or "").strip().lower()
return raw if raw in _VALID_RUNTIME_ADAPTER_MODES else _RUNTIME_ADAPTER_DIRECTDefaults safely to legacy-direct for: env-unset, empty string, whitespace, typos (journal, sidecar, anything outside {legacy-direct, legacy-journal}). Case-insensitive (.lower()), whitespace-trimmed (.strip()), optional environ for testability.
Route fork at api/routes.py:7734-7783 — same call surface, two branches:
from api.runtime_adapter import (LegacyJournalRuntimeAdapter, StartRunRequest, runtime_adapter_enabled)
if runtime_adapter_enabled():
def _legacy_start_run(request: StartRunRequest) -> dict:
return _start_chat_stream_for_session(s, msg=request.message, ...)
adapter = LegacyJournalRuntimeAdapter(start_run_delegate=_legacy_start_run)
result = adapter.start_run(StartRunRequest(...))
response = dict(result.payload)
response.setdefault("stream_id", result.stream_id) # fallback chain
...
else:
response = _start_chat_stream_for_session(s, msg=msg, ...) # IDENTICAL to pre-PRThe else branch is byte-identical to the pre-PR direct path (verified line-by-line). Default-off semantic is preserved exactly.
setdefault fallback chain at lines 67-71: the wrapper merges result.payload first (which is the dict returned by _legacy_start_run), then setdefaults for stream_id/session_id/run_id/status/active_controls. setdefault only fills missing keys, so the delegate's response shape is preserved.
LegacyJournalRuntimeAdapter at api/runtime_adapter.py:209-314 — protocol-translator facade:
start_runrequires astart_run_delegatecallable. ReturnsRunStartResultwrapping the delegate's dict output.observe_runreads fromapi.run_journal.read_run_eventswith cursor → after-seq translation. Pure reader.get_runcombineslive_stream_lookup(caller-injected predicate) with journal summary. Pure reader.cancel_run,respond_approval,respond_clarifyeach require a callable delegate; without one, returnControlResult(accepted=False, status="unsupported", safe_message="..."). No queue, no callback registry.
RFC non-goal compliance — the adapter module owns:
- ✅ Zero module-level locks
- ✅ Zero module-level dicts (no agent cache, no cancellation registry, no callback queue)
- ✅ Zero module-level threads
- ✅ Zero module-level queues
Verified via reflection: [n for n in dir(api.runtime_adapter) if 'lock|dict|thread|queue' in n.lower()] returns empty lists for every category. The PR honors the RFC's explicit non-goals from #2416.
Other audit — things that are correct already
Security
os.environread is the only external input. No user-controlled data flows into mode selection._cursor_to_after_seqparses a string withint()inside atry/except (TypeError, ValueError)→ defaults to 0 (safe — replays from beginning). Cursor comes from journal (server-controlled), but defensive coding is good.- No new file writes, no new sockets, no new subprocesses. Pure in-process facade.
Auth gate
/api/chat/startcontinues to flow through existing handler chain. The fork happens AFTER the existing auth + workspace resolution atroutes.py:7700-7730. No bypass.
Default-off invariant
- Test 1
test_runtime_adapter_interface_and_legacy_journal_methods_existpins:runtime_adapter_mode({}) == "legacy-direct",runtime_adapter_enabled({}) is False,mode({"...": "sidecar"}) == "legacy-direct". Unknown values silently default to safe. - Test 5 pins the route uses
runtime_adapter_enabled()(not inline env check) AND retains the direct_start_chat_stream_for_session(call. Negative assertion:"HERMES_WEBUI_RUNTIME_ADAPTER" not in start_body— catches future drift where someone replaces the helper withos.environ.get(...).
Reversibility
- Flip the env var back to
legacy-direct(or unset it entirely) → next request takes the else branch → byte-identical to pre-PR behavior. No data migration, no schema change, no session-file format change. Operationally boring revert per the RFC.
Per-request adapter construction
adapter = LegacyJournalRuntimeAdapter(start_run_delegate=_legacy_start_run)constructed inside the handler. No module-level singleton, no caching. Adapter is stateless; GC'd after handler returns. Pattern is correct.
Local import inside handler
from api.runtime_adapter import ...is a local import inside_handle_chat_start. First call imports; subsequent calls hitsys.modulescache. The module has no expensive top-level work (just dataclass definitions and constants). Negligible overhead.
Behavioural harness
=== Mode parsing (8/8 ✓) ===
env unset → legacy-direct, enabled=False
env="" → legacy-direct, enabled=False
env="legacy-direct" → legacy-direct, enabled=False
env="legacy-journal" → legacy-journal, enabled=True
env="LEGACY-JOURNAL" → legacy-journal, enabled=True (case-insensitive)
env="journal" → legacy-direct, enabled=False (typo guard)
env="sidecar" → legacy-direct, enabled=False (unknown guard)
env=" legacy-journal " → legacy-journal, enabled=True (whitespace trim)
=== start_run passthrough ===
✓ delegate called once with the request object
✓ run_id=abc-123, stream_id=abc-123, session_id=s1
✓ extra_field preserved in payload (no key loss)
✓ default active_controls populated when delegate omits
=== Missing-delegate failure modes ===
✓ start_run without delegate → NotImplementedError (loud, fail-fast)
✓ cancel_run without delegate → ControlResult(accepted=False, status="unsupported")
✓ respond_approval without delegate → ControlResult(accepted=False, status="unsupported")
✓ respond_clarify without delegate → ControlResult(accepted=False, status="unsupported")
=== No new persistent state ===
✓ module-level locks/dicts/threads/queues: all empty (RFC non-goal honored)
Edge-case trace
| Scenario | Expected | Actual |
|---|---|---|
| Env var unset | direct path (byte-identical to pre-PR) | ✅ harness + test |
| Env var = "legacy-journal" | adapter path | ✅ test 5 |
| Env var = typo / unknown | direct path | ✅ harness |
| Env var = whitespace-padded | trimmed and matched | ✅ harness |
| Adapter without start_delegate | NotImplementedError | ✅ harness |
| Adapter without cancel_delegate | ControlResult(unsupported) | ✅ harness |
| Adapter response missing stream_id | falls back to result.run_id |
✅ setdefault chain |
| Adapter response with extra payload fields | preserved (dict merge) | ✅ harness |
| Mid-process env flip | next request picks up new mode | ✅ no caching |
| Existing run_journal API | unchanged | ✅ read-only consumer |
Existing _start_chat_stream_for_session |
unchanged | ✅ delegate calls verbatim |
| Cross-tool: CLI hits same routes | unaffected (default off) | ✅ |
Tests
- PR-targeted: 5/5 pass (
tests/test_runtime_adapter_seam.py). - Full local suite (Python 3.14): 5683 passed, 63 skipped, 3 xpassed, 0 failed.
- CI: 3.11/3.12/3.13 all green.
- Behavioural harness: 8/8 mode-parsing scenarios + 4/4 passthrough/failure-mode scenarios + RFC non-goal compliance verified.
Minor observations (non-blocking)
runtime_adapter_enabled()readsos.environper call. Mid-process env flips take effect on the next request. Useful for live rollback; could cause diagnostic confusion if the env state diverges from initial boot. A smallprint()orlogger.infoon flag detection would help operators. Not blocking.response.setdefault("stream_id", result.stream_id)is the right shape becauseresult.payloadisdict(self._start_run_delegate(request) or {})— so the delegate's keys are already inresponse.setdefaultonly fills if absent. Defensive against future delegate-shape drift.active_controls = payload.get("active_controls")thenif not isinstance(active_controls, list): active_controls = ["cancel"] if stream_id else []— sensible default. Matches the RFC's "controls are present even before they're migrated" stance.- CHANGELOG entry says
**PR #TBD**— pre-merge placeholder, idiomatic per project convention (release agent stamps final number). Same pattern as PR #2416. _handle_chat_startis the only route forked./api/chat/stream,/api/chat/cancel,/api/chat/approval,/api/chat/clarifystill use the direct path even when the flag is enabled. That's intentional — Slice 2 scope says only start is wrapped; full observe/cancel/approval/clarify migration is Slice 3. The PR description correctly calls this out.
Recommendation
Approved. Tight Slice 2 implementation that honors every non-goal from the #2416 RFC: protocol-translator only, no new state owned by the adapter, byte-identical default-off path, strict env-flag allow-list. Test pins both the interface AND the route shape (with negative assertion against inline env checks). Behavioural harness confirms all parsing edge cases and RFC non-goal compliance.
✅ Parked at approval — ready for the release agent's merge/tag pipeline.
…dapter seam (HERMES_WEBUI_RUNTIME_ADAPTER=legacy-journal) by @Michaelyklam (refs nesquena#1925) Co-authored-by: Michael Lam <michael@example.local>
|
Shipped in v0.51.81 (Release BE, stage-374) — thanks @Michaelyklam! Squash-merged via stage commit Release notes:
Pre-release gate:
Release: https://github.com/nesquena/hermes-webui/releases/tag/v0.51.81 v0.51.82 follow-up filed: #2435 — tighten /api/chat/start response shape parity when adapter flag is on |
… 0.51.82) (#528) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/nesquena/hermes-webui](https://github.com/nesquena/hermes-webui) | patch | `0.51.75` → `0.51.82` | --- ### Release Notes <details> <summary>nesquena/hermes-webui (ghcr.io/nesquena/hermes-webui)</summary> ### [`v0.51.82`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05182--2026-05-17--Release-BF-stage-375--2-PR-batch--table-renderer-pipe-protection--Catppuccin-appearance-skin) [Compare Source](nesquena/hermes-webui@v0.51.81...v0.51.82) ##### Added - **PR [#​2432](nesquena/hermes-webui#2432 by [@​Michaelyklam](https://github.com/Michaelyklam) (closes [#​2426](nesquena/hermes-webui#2426)) — Add a Catppuccin skin to Appearance settings. The single opt-in skin maps light mode to Catppuccin Latte and dark mode to Catppuccin Mocha, using Mauve as the accent while preserving the existing theme/skin persistence and no-build-step architecture. ##### Fixed - **PR [#​2428](nesquena/hermes-webui#2428 by [@​bengdan](https://github.com/bengdan) — Protect pipes inside parens / brackets / braces from naive `split('|')` in the Markdown table renderer. Cells like `` `(a|b)` ``, `` `Union[int|float]` ``, `` `(a|b|c)` ``, and `` `Union[int|float|str]` `` now stay in a single column instead of mis-splitting. The fix uses an iterative `_protectPipes` loop so all pipes inside one bracket pair are caught, not just the first. Also adds a `$...$` guard so a KaTeX inline-math span straddling `|` column separators is left alone instead of being stashed as math. Stage-fix on the contributor branch (a) swapped the literal `}` glyphs in the regex character classes for `\x7d` hex escapes (semantically identical, but the JS source no longer carries bare close-brace glyphs that confused the brace-counting `extractFunc` in `tests/test_renderer_js_behaviour.py`); (b) dropped a stray apostrophe stop that would have mis-split `('a'|'b')`-style string-literal unions; (c) dropped angle brackets `<` / `>` from the protected-bracket set, after Opus advisor flagged that `| x < 5 | y > 10 |` would otherwise collapse into a single cell (comparison-operator usage dominates content-grouping usage in real LLM table output); and (d) added `tests/test_issue2428_table_pipe_protection.py` with 12 regression cases covering single-pipe, multi-pipe-in-brackets, apostrophes-with-pipes, the KaTeX-in-table guard, and the angle-bracket comparison-operator case. ### [`v0.51.81`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05181--2026-05-17--Release-BE-stage-374--6-PR-batch--cost-history-POSIX-lock--prompt-cache-tokens--Plugins-panel-i18n--pending-placeholder-chat--journal-replay-partial-recovery--default-off-RuntimeAdapter-Slice-2-seam) [Compare Source](nesquena/hermes-webui@v0.51.80...v0.51.81) ##### Added - **PR [#​2424](nesquena/hermes-webui#2424 by [@​Michaelyklam](https://github.com/Michaelyklam) (refs [#​1925](nesquena/hermes-webui#1925)) — Add the default-off `RuntimeAdapter` Slice 2 seam. `HERMES_WEBUI_RUNTIME_ADAPTER=legacy-journal` now routes chat start through a `LegacyJournalRuntimeAdapter` facade over the existing legacy streaming path, while the default remains `legacy-direct`. The new adapter interface/payload classes expose start/observe/status/cancel/approval/clarify methods and delegate controls to existing handlers without introducing a runner, sidecar, new process-local queues, cached agents, cancellation registries, or callback registries. - **PR [#​2421](nesquena/hermes-webui#2421 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2419](nesquena/hermes-webui#2419)) — Surface provider prompt-cache read/write tokens in WebUI usage displays. Cache-miss cost issues are now visible in the context tooltip and per-turn usage footer; counters carry through session persistence, SSE usage payloads, and live snapshots so deltas remain accurate across the active turn. - **PR [#​2425](nesquena/hermes-webui#2425 by [@​mccxj](https://github.com/mccxj) — Wire Settings → Plugins panel into the existing i18n system. Panel title, description, empty state, and per-plugin labels (hooks, enabled/disabled, load failures) now respect the user's language preference; 10 new keys ship in English with `TODO: translate` placeholders in 9 additional locales. ##### Fixed - **PR [#​2418](nesquena/hermes-webui#2418 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2402](nesquena/hermes-webui#2402)) — OpenRouter cost-history snapshot updates now take a provider-specific POSIX file lock around the read-modify-write cycle, preserving the existing process-local lock while preventing lost snapshot updates if WebUI is deployed with multiple worker processes sharing one Hermes home/state directory. - **PR [#​2431](nesquena/hermes-webui#2431 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2429](nesquena/hermes-webui#2429)) — Chat sends now render the assistant-side pending `Thinking…` placeholder immediately after the user turn is echoed, before `/api/chat/start` returns a stream id or the first SSE event arrives. The existing stale-stream guard remains in place for ordinary reasoning updates — only the explicit pre-stream placeholder path is allowed through. - **PR [#​2427](nesquena/hermes-webui#2427 by [@​franksong2702](https://github.com/franksong2702) (fixes [#​2423](nesquena/hermes-webui#2423)) — Recover already-journaled visible assistant text and tool cards when a WebUI process restart interrupts an in-flight browser-originated turn. The stale-stream repair path now materializes run-journal output before the explicit interrupted marker instead of collapsing the turn to "no agent output was recovered." ##### Documentation - **PR [#​2416](nesquena/hermes-webui#2416 by [@​Michaelyklam](https://github.com/Michaelyklam) (refs [#​1925](nesquena/hermes-webui#1925)) — Expand the runtime-adapter RFC with the concrete Slice 2 adapter-seam contract: minimal `RuntimeAdapter` methods, payload fields, `legacy-direct` / `legacy-journal` feature-flag rollback path, legacy-backend mapping, explicit non-goals, and adapter-seam acceptance tests. Keeps the next step scoped to a reversible protocol-translator boundary over the journaled legacy path, not a runner/sidecar or execution-ownership move. ### [`v0.51.80`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05180--2026-05-17--Release-BD-stage-373--2-PR-batch--provider-config-flag-filter--stale-compaction-greeting-heuristic) [Compare Source](nesquena/hermes-webui@v0.51.79...v0.51.80) ##### Fixed - **PR [#​2415](nesquena/hermes-webui#2415 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2399](nesquena/hermes-webui#2399)) — `providers.only_configured` and other scalar flags under the top-level `providers:` config mapping no longer appear as fake provider groups in the model picker. Provider detection now only seeds picker groups from known provider ids/aliases or dict-shaped provider configs, so filtering flags cannot render as `Only-Configured`. The gating contract is documented inline in `api/config.py` (within the existing `_PROVIDER_MODELS`/`_PROVIDER_DISPLAY` membership block) so the test\_issue604 source-scan stays satisfied. - **PR [#​2417](nesquena/hermes-webui#2417 by [@​nesquena-hermes](https://github.com/nesquena-hermes) (co-authored by [@​franksong2702](https://github.com/franksong2702), supersedes [#​2309](nesquena/hermes-webui#2309), closes [#​2308](nesquena/hermes-webui#2308)) — Compressed sessions with hidden "resume active task" context no longer treat a short fresh greeting (`hi`, `hello`, plus 6 CJK greetings) as implicit permission to continue an old agent task. Explicit continuation prompts (`continue`, `resume`, plus 4 CJK continuation phrases) still keep the compacted task context. The new helpers (`_normalize_fresh_chat_text`, `_is_casual_fresh_chat_message`, `_has_task_resume_compaction_marker`, `_context_messages_for_new_turn`) require BOTH the compaction phrase AND a task-resume keyword in the SAME message before treating it as a stale-task marker (precision-preserving guard). Length cap of 24 chars + workspace-prefix normalization + exact greeting-set match prevent false positives. CJK greetings/continuation terms are stored as Python `\u`-escape sequences so `api/streaming.py` passes the `test_title_sanitization::test_title_generation_source_has_no_cjk_literals` English-only-source invariant; runtime values are unchanged. Stage-372 Opus advisor pass caught two CJK codepoint typos (`嘖→嗨`, `哈喂→哈喽`) in the maintainer rebase and corrected them; new regression test `test_all_cjk_greetings_drop_stale_compaction_context` pins all 6 CJK greetings against future codepoint drift with `U+XXXX` failure messages. ### [`v0.51.79`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05179--2026-05-16--Release-BC-stage-372--5-PR-batch--text-mode-image-history-fix--Activity-group-compression-boundary--named-custom-provider-routing--quota-chip-Settings-toggle--RFC-docs) [Compare Source](nesquena/hermes-webui@v0.51.78...v0.51.79) ##### Added - **PR [#​2413](nesquena/hermes-webui#2413 (self-built follow-up to v0.51.78's [#​2082](nesquena/hermes-webui#2082), closes the quota-chip default-on regression) — New "Show provider quota chip in composer" checkbox in Settings → Preferences, default off. When disabled (the new default), the chip is hidden at all viewports and the `/api/provider/quota` fetch is skipped entirely. When enabled, the existing `@media (max-width:1399.98px)` gate from stage-371 still restricts the chip to wide desktops only. Per Nathan's directive 2026-05-16 immediately after stage-371 shipped — users get explicit agency over an ambient composer-chrome element. Wired through `api/config.py` `_SETTINGS_DEFAULTS`, `static/boot.js`, `static/panels.js` round-trip, `static/ui.js` short-circuit-when-disabled, `static/index.html` Settings field, and 11 locales in `static/i18n.js`. ##### Fixed - **PR [#​2406](nesquena/hermes-webui#2406 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2398](nesquena/hermes-webui#2398)) — The fallback synchronous `POST /api/chat` route now passes the active WebUI config into the conversation-history sanitizer, so text-mode providers do not receive historical native `image_url` content parts when direct API callers use the legacy chat endpoint. This brings the sync route in line with the streaming chat path fixed for [#​2297](nesquena/hermes-webui#2297). - **PR [#​2408](nesquena/hermes-webui#2408 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2404](nesquena/hermes-webui#2404)) — Auto-compression cards now close the current live Activity burst before rendering, so post-compression tools start a fresh `Activity` row instead of joining the pre-compression tool group across a real timeline/context boundary. Adds a `closeCurrentLiveActivityGroup()` helper that clears the `data-live-activity-current` marker before `appendLiveCompressionCard()` inserts the compression card. Resolves the DEFER from stage-370 Opus advisor review of PR [#​2390](nesquena/hermes-webui#2390). - **PR [#​2411](nesquena/hermes-webui#2411 by [@​Michaelyklam](https://github.com/Michaelyklam) (fixes [#​2405](nesquena/hermes-webui#2405)) — Named `custom:*` providers no longer lose vendor-prefixed model selections when the static model picker has not hydrated that model yet. The frontend now treats named custom providers as routable aggregators for both mismatch-warning suppression and missing-dropdown fallback, and live-fetched models keep explicit `@custom:name:` provider context so selections persist instead of snapping back to the configured default. ##### Documentation - **PR [#​2407](nesquena/hermes-webui#2407 by [@​Michaelyklam](https://github.com/Michaelyklam) — Document the [#​1925](nesquena/hermes-webui#1925) runtime-adapter gate update: Slice 1 run-journal replay has now passed a 100-trial synthetic replay/restart validation pass on current `origin/master`, [#​2313](nesquena/hermes-webui#2313 selected-session chat SSE cap is shipped, and Slice 2 is ready for a reversible adapter-seam planning PR without moving execution ownership yet. ##### Test infrastructure - New regression test `tests/test_quota_chip_settings_toggle.py` (6 cases) pins the quota-chip toggle invariants: Settings field present with i18n labels, `show_quota_chip` default-`False` in `_SETTINGS_DEFAULTS` + `_SETTINGS_BOOL_KEYS`, render/refresh both short-circuit when disabled (no wasted API calls), boot initializes `window._showQuotaChip` from settings + default-false on settings-fetch failure, full panels.js round-trip, 11 locale strings present. ### [`v0.51.78`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05178--2026-05-16--Release-BB-stage-371--stuck-PR-sweep-salvage--RTL-chat--ambient-quota-chip-with-composer-clutter-gate) [Compare Source](nesquena/hermes-webui@v0.51.77...v0.51.78) ##### Added - **PR [#​2409](nesquena/hermes-webui#2409 (maintainer follow-up from 2026-05-16 stuck-PR sweep, co-authored by [@​malulian](https://github.com/malulian) and [@​ai-ag2026](https://github.com/ai-ag2026), closes [#​1721](nesquena/hermes-webui#1721) and [#​2082](nesquena/hermes-webui#2082)) — Two stalled contributor PRs absorbed into one self-built release after Telegram UX approval across mobile/laptop/desktop/wide viewports. - **Right-to-left chat layout (salvaged from [#​1721](nesquena/hermes-webui#1721) by [@​malulian](https://github.com/malulian))** — New Settings → Preferences toggle, default off, flips the chat-area direction for Arabic and Hebrew users. Honors [@​aronprins](https://github.com/aronprins)' design review on PR [#​1721](nesquena/hermes-webui#1721) (May 13 2026): drops the contributor's composer footer toggle button to keep composer real estate clean. Implementation includes a flash-prevention bootstrap `<script>` in `<head>` (applies `chat-content-rtl` class synchronously before any chat content paints), scoped CSS that only flips `.msg-row`, `.msg-body` tables, `.tool-call-group-summary`, and the composer `textarea#msg` — the sidebar, workspace panel, settings panel, and any other UI element stay left-to-right. Code blocks (`pre`, `code`, `kbd`, `samp`, `tt`, `.hljs`, `.code-block`) and tool-call group bodies force `direction:ltr; text-align:left; unicode-bidi:isolate` even under RTL, because Arabic and Hebrew developers still write English code, command lines, and JSON the same way English developers do (visually verified with embedded Python in an Arabic SSE conversation). Localized in 11 locales (en, it, ja, ru, es, de, zh-CN, zh-TW, pt, ko, fr). - **Ambient provider quota chip (overridden from [#​2082](nesquena/hermes-webui#2082) by [@​ai-ag2026](https://github.com/ai-ag2026))** — New green pill chip in the composer footer that surfaces the active provider's remaining quota (OpenRouter credit balance shaped as `$X.YZ`, or account-limit-shaped providers as `N%`), with click-through to Settings → Providers. Fetches `/api/provider/quota` on boot and on tab visibility return. Hidden below 1400px viewport via `@media (max-width:1400px) { display:none !important }` because the composer footer at 1280px laptop and 1440px standard desktop was already tight and the chip squeezed adjacent chips (model picker truncated from `Claude Sonnet 4 7` to `Claude Sonnet 4`, workspace dropdown lost text). Mobile users find quota through the dedicated mobile-config drawer; laptop users follow the chip's click-target into Settings → Providers anyway. The chip's value proposition (ambient quota visibility) is preserved on wide displays where there's genuine composer room without trading off existing chip readability. ##### Test infrastructure - New regression test `tests/test_pr1721_rtl_salvage.py` (8 cases) pins the RTL salvage invariants: Settings field + i18n keys present, no composer footer button (negative assertion encoding [@​aronprins](https://github.com/aronprins)' design objection), bootstrap script runs synchronously in `<head>` before paint, CSS scoped to chat only (negative tests against `.sidebar`, `.settings-panel`, `.workspace-panel`, `html`, `body` rules), code blocks force LTR under RTL, tool-call bodies force LTR under RTL, panels.js load/save round-trip, `rtl` in `api/config.py` DEFAULTS and writable-key allow-list, 11 locale strings present. ### [`v0.51.77`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05177--2026-05-16--Release-BA-stage-370--1-PR-follow-up--live-Activity-grouping-boundary-fix) [Compare Source](nesquena/hermes-webui@v0.51.76...v0.51.77) ##### Fixed - **PR [#​2390](nesquena/hermes-webui#2390 by [@​franksong2702](https://github.com/franksong2702) (refs [#​2376](nesquena/hermes-webui#2376), [#​2344](nesquena/hermes-webui#2344), [#​2347](nesquena/hermes-webui#2347), [#​2377](nesquena/hermes-webui#2377)) — Live progress Activity grouping no longer degrades consecutive tool calls into repeated `Activity: 1 tool` rows. The frontend was using one reset helper for two different jobs — resetting where the next assistant text segment should render, and closing the current live Activity group — but those are not the same operation. Tool starts now only reset the next-text-segment anchor; the live Activity group closes only when the model emits a visible `interim_assistant` progress update (the actual timeline boundary). The flow stays: ```text Thinking card visible progress note Activity: N related tools visible progress note Activity: N related tools final answer ``` Adds a WebUI-only ephemeral progress contract in `api/streaming.py` that asks multi-step tool-heavy turns to emit concise visible progress notes in the user's language, while explicitly forbidding exposure of hidden reasoning, chain-of-thought, scratchpads, secrets, raw logs, or long tool output. Any selected personality prompt is preserved. New regressions cover the progress-contract reach-through, the interim-assistant split boundary, and the consecutive-tools-in-one-Activity-row invariant. ### [`v0.51.76`](https://github.com/nesquena/hermes-webui/blob/HEAD/CHANGELOG.md#v05176--2026-05-16--Release-AZ-stage-369--4-PR-safe-lane-batch--live-timeline-preservation--OpenRouter-cost-history--chat-stream-cap--credential-pool-cache) [Compare Source](nesquena/hermes-webui@v0.51.75...v0.51.76) ##### Added - **PR [#​2195](nesquena/hermes-webui#2195 by [@​Michaelyklam](https://github.com/Michaelyklam) (refs [#​692](nesquena/hermes-webui#692)) — OpenRouter cost history backend. New `GET /api/providers/openrouter/cost_history` endpoint backed by daily snapshots from OpenRouter's `/auth/key` cumulative spend. Process-local lock around the snapshot read-modify-write critical section so concurrent dashboard refreshes or multiple tabs cannot overwrite newer reads with stale ones. Delta computation handles cumulative-counter resets (key rotation, OpenRouter-side reset) by starting a fresh series and using the current value as that day's delta rather than emitting negative spend. Backend-only slice; the 7-day daily cost chart UI is a separate follow-up. ##### Fixed - **PR [#​2347](nesquena/hermes-webui#2347 by [@​franksong2702](https://github.com/franksong2702) (fixes [#​2344](nesquena/hermes-webui#2344)) — Preserve live agent timeline across session switches. Previously, switching away from an active stream and returning rebuilt the turn from the persisted `INFLIGHT` tail, which is enough to reconnect the stream but is not a full-fidelity DOM timeline — Thinking/tool grouping flattened, interim assistant text moved away from its surrounding context, auto-compression cards could project twice. The restore path now snapshots the live assistant turn DOM during the active stream and, on return, loads the persisted transcript first then merges the live snapshot back in so the on-screen scene is preserved as the user left it. Stamping `row.dataset.sessionId` at turn creation prevents the new live-turn sites from re-triggering the lossy rebuild path. - **PR [#​2393](nesquena/hermes-webui#2393 by [@​Michaelyklam](https://github.com/Michaelyklam) (refs [#​2313](nesquena/hermes-webui#2313)) — Cap live chat stream transports to the selected conversation. Previously, keeping many sessions open accumulated one long-lived `/api/chat/stream` EventSource per session. New `closeOtherLiveStreams(activeSid)` helper in `static/messages.js`; `attachLiveStream()` now reuses an existing same-session transport first, closes other sessions' chat SSE transports, then opens or replaces the selected session's stream. Background sessions still reattach normally when the user selects them — only the SSE transport is pruned, not the server-side stream ownership. New regression test pins the ordering (reuse first, prune background streams next, replace active transport last). - **PR [#​2396](nesquena/hermes-webui#2396 by [@​starship-s](https://github.com/starship-s) — Preserve session agents for credential pools. The per-session `AIAgent` cache signature previously mixed stable agent identity with the volatile resolved API key, so credential-pool providers (where each request can resolve a different runtime token even when provider/model config is unchanged) missed the cache every turn and rebuilt the agent — losing warmed cross-turn state such as memory-provider prefetch results for providers like Hindsight. New credential-aware cache-signature helper uses a stable sentinel for credential-pool routes while preserving hashed API-key identity for non-pool routes; reused cached agents refresh runtime credentials in place; `AIAgent._primary_runtime` stays aligned after refresh so fallback/transport recovery cannot resurrect an old token; agents still in fallback-active state rebuild rather than mutate to avoid mixed primary/fallback runtime state. Static non-pool API keys still participate in the cache signature so explicit credential changes continue to invalidate. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/528
…dapter seam (HERMES_WEBUI_RUNTIME_ADAPTER=legacy-journal) by @Michaelyklam (refs nesquena#1925) Co-authored-by: Michael Lam <michael@example.local>
…dapter seam (HERMES_WEBUI_RUNTIME_ADAPTER=legacy-journal) by @Michaelyklam (refs nesquena#1925) Co-authored-by: Michael Lam <michael@example.local>
Thinking Path
RuntimeAdapterseam over the still-legacy journaled path — not a runner, sidecar, control migration, or execution-ownership move.STREAMS/CANCEL_FLAGS/ cachedAIAgent/ approval/clarify queues under new names, so this PR keeps the adapter as a protocol translator with injected legacy delegates.legacy-direct; the new path is opt-in withHERMES_WEBUI_RUNTIME_ADAPTER=legacy-journal.What Changed
api/runtime_adapter.pywith:RuntimeAdapterprotocolStartRunRequest,RunStartResult,RunEventStream,RunStatus, andControlResultpayload classesruntime_adapter_mode()/runtime_adapter_enabled()defaulting safely tolegacy-directLegacyJournalRuntimeAdapterfacade over the existing legacy streaming path and run journal/api/chat/startthrough the adapter only whenHERMES_WEBUI_RUNTIME_ADAPTER=legacy-journal; otherwise it uses the exact existing direct_start_chat_stream_for_session(...)path.Refs #1925.
Why It Matters
This is the first code seam after the accepted Slice 2 contract. It gives the WebUI a concrete adapter boundary to test and review while preserving the current execution backend and avoiding a parallel runtime. Future slices can migrate controls or runner ownership behind this boundary, but this PR deliberately does not move those responsibilities yet.
Verification
Risks / Follow-ups
cancel_run,respond_approval, andrespond_clarifyare present as delegated legacy controls only; their ownership migration remains deferred to later control-specific slices.Model Used
OpenAI Codex / GPT-5.5 via Hermes Agent, with shell, file edit, GitHub CLI, and local pytest verification.