Skip to content

fix(title): runtime validator stops stale background titling from reloading unloaded models (salvage #19137) - #66078

Merged
teknium1 merged 1 commit into
mainfrom
salvage/19137-runtime-validator
Jul 17, 2026
Merged

fix(title): runtime validator stops stale background titling from reloading unloaded models (salvage #19137)#66078
teknium1 merged 1 commit into
mainfrom
salvage/19137-runtime-validator

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Background title generation can no longer reload a model the runtime already unloaded: a runtime_validator callback now runs right before the titler's LLM request and silently skips it when the session's model/provider changed after the thread was spawned. Fixes #19027 (Ollama strict_single_load users: a model switch evicted the old model, then the stale background title request pulled it straight back into GPU memory).

Surgical reapply of #19137 by @Thatgfsj — the original branch was 8k+ commits stale (predates pinned-language prompts, the atomic-write helper, and the moved TUI/ACP call sites), so the semantic diff was reapplied onto current main with --author preserving contributor authorship. Stacked on #66062 (salvage #62983) since both touch the same call sites.

Changes

  • agent/title_generator.py: runtime_validator: Callable[[], bool] threaded through maybe_auto_titleauto_title_sessiongenerate_title; checked immediately before call_llm. Fail-open: a raising validator logs and proceeds (@Thatgfsj)
  • cli.py, gateway/run.py, tui_gateway/server.py, acp_adapter/server.py: each call site snapshots model/provider at spawn and passes a comparison lambda (@Thatgfsj, re-wired to current call sites)
  • Tests: validator skip/allow/fail-open + forwarding through the thread spawn

Validation

Scenario Before After
Model switched between response and titler firing HTTP request sent → unloaded model reloads request skipped, thread exits quietly (E2E: simulated switch, call_llm never invoked)
Runtime unchanged title generated unchanged (E2E control)
Validator raises fail-open, title generated
3 affected suites 465 pass via run_tests.sh

Closes #19027. Original PR #19137 will be closed with credit.

Infographic

runtime-validator-stale-title

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment

Scope: +135/-1, title runtime validator salvage

Notes

  • Fix: runtime validator stops stale background titling from reloading unloaded models.
  • Salvage of #19137.
  • No security concerns.
  • Clean fix, LGTM.

Reviewed by Hermes Agent

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) comp/acp Agent Communication Protocol adapter labels Jul 17, 2026
@teknium1
teknium1 force-pushed the salvage/62983-title-runtime branch 2 times, most recently from e7f8f11 to ee65fc6 Compare July 17, 2026 05:44
Base automatically changed from salvage/62983-title-runtime to main July 17, 2026 05:54
…unloaded Ollama models

Add a runtime_validator callback to generate_title() / auto_title_session()
/ maybe_auto_title(). Callers snapshot the session's model+provider when
spawning the background titler; the validator runs right before the LLM
request and skips it silently when the live runtime no longer matches —
so a stale title request can't reload a model that strict_single_load
already evicted after a user model switch. Fail-open: a raising validator
never disables titling.

Wired at all four call sites (cli, gateway, tui_gateway, acp_adapter).

Surgical reapply of PR #19137 (base was 8k+ commits stale; the original
patch predates the pinned-language prompts, the atomic-write helper, and
the moved TUI/ACP call sites). Original work by @Thatgfsj. Closes #19027.
@teknium1
teknium1 force-pushed the salvage/19137-runtime-validator branch from 1416517 to 0c6df26 Compare July 17, 2026 05:57
@teknium1
teknium1 merged commit ef1c622 into main Jul 17, 2026
33 checks passed
@teknium1
teknium1 deleted the salvage/19137-runtime-validator branch July 17, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/acp Agent Communication Protocol adapter comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Fix: stale title generation request reloads unloaded Ollama model after model switch

3 participants