Skip to content

Release: sync session titles to state.db (#6892) - #6960

Merged
nesquena-hermes merged 5 commits into
masterfrom
release/stage-6892-1786560706
Aug 12, 2026
Merged

nesquena-hermes merged 5 commits into
masterfrom
release/stage-6892-1786560706

Conversation

@nesquena-hermes

Copy link
Copy Markdown
Collaborator

Release stage for #6892 — sync auto-generated session titles to hermes-agent state.db.

Original PR: #6892 by @liuguangyong93 (Co-authored on the stage branch).

What

Background title generation wrote the auto-title only to the WebUI session sidecar, not to hermes-agent's state.db, so hermes sessions list showed blank titles for WebUI sessions. This bridges the title into state.db after generation and on adaptive refresh.

Gate (full current gate)

  • Codex adversarial review: SAFE TO SHIP — no regression risk. Real-DB probes confirmed generated-title persistence, cli/gateway source preservation (INSERT-OR-IGNORE, conflict path never updates source), manual-rename no-overwrite (provenance rank: user > llm), refresh no-op, and two-thread concurrency safety.
  • Full suite: 14290 passed, 0 failed.
  • Coverage gap closed on the stage branch (Codex SHOULD-FIX Portability #1): the PR's only test change mocked the new write to a no-op, so I added tests/test_issue6892_sync_title_coverage.py — three real-SessionDB tests proving generated-title persistence, manual-rename no-overwrite, and source preservation. Additive test-only, no behavior change to the fix.

Follow-up (not blocking — pre-existing behavior, Codex SHOULD-FIX #2)

If two sessions generate the same title, state.db's uniqueness rule leaves the second blank. This predates this PR (not a release regression). A follow-up should catch ValueError and retry via get_next_title_in_lineage. Filing separately.

Backend reliability fix — no visible UI change, so no screenshot gate needed.

Closes #6892.

liuguangyong93 and others added 5 commits August 12, 2026 14:48
… WebUI titles

Background title generation (`_run_background_title_update` and
`_run_background_title_refresh`) writes the title to the WebUI sidecar
JSON but never syncs it back to hermes-agent's `state.db`. This causes
`hermes sessions list` to show blank titles for all WebUI-originated
sessions.

The existing `sync_session_usage` path is gated by the `sync_to_insights`
setting (default: off) and executes before the background title thread
completes, so it cannot cover this case.

Fix: add `sync_session_title()` to `state_sync.py` — an unconditional
(not gated by `sync_to_insights`) title-only sync — and call it from both
title generation paths immediately after persisting the title to the
sidecar.
Neutralize the new `sync_session_title` call in
`test_cleared_title_allows_initial_auto_generation` to prevent state.db
side effects from leaking into shared test state, matching the existing
pattern of mocking collaborators in this test.
Address gate-review blockers from nesquena-hermes:

1. Wrong title-authority API: replace `db.set_session_title()` with
   `db.set_auto_title_if_empty()` so auto-generated titles never
   overwrite a manual rename (set_session_title writes with 'user'
   authority; set_auto_title_if_empty only populates NULL titles).

2. Null profile fallback: pass `or 'default'` at both streaming.py
   call sites so background title workers (which lack request TLS)
   always resolve to the correct state.db instead of falling through
   to the process-global active profile.
… tests

Codex round-1 SHOULD-FIX: the PR's only test change mocked the new write to a
no-op. Add real-SessionDB tests proving generated-title persistence, manual-rename
no-overwrite, and cli/gateway source preservation on ensure_session. Additive
test-only; no behavior change to the contributor's fix.

Co-authored-by: liuguangyong93 <liuguangyong93@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This release-stage PR synchronizes WebUI-generated session titles into hermes-agent’s state database while preserving manual-title provenance and existing session sources.

  • Adds a fail-soft sync_session_title bridge using set_auto_title_if_empty.
  • Invokes synchronization after initial title generation and adaptive refresh.
  • Adds real-SessionDB coverage for persistence, manual-rename protection, and source preservation.
  • Documents the fix in the release changelog.

Confidence Score: 5/5

The PR appears safe to merge, with the new persistence path preserving manual titles and existing session-source metadata.

The title bridge uses the existing SessionDB conditional-title contract, resolves the session profile explicitly, fails softly when state.db is unavailable, and has direct database coverage for its key persistence invariants.

Important Files Changed

Filename Overview
api/state_sync.py Adds an idempotent, fail-soft title synchronization helper that preserves existing title provenance and session source.
api/streaming.py Calls the new synchronization helper after successful initial title generation and adaptive refresh using the session profile.
tests/test_issue6892_sync_title_coverage.py Exercises the real SessionDB contract for generated-title persistence, manual-title protection, and existing-source preservation.
tests/test_3230_preserve_manual_session_title.py Isolates the existing manual-title test from the newly introduced state.db side effect.
CHANGELOG.md Adds the release note describing title synchronization and provenance-preserving behavior.

Sequence Diagram

sequenceDiagram
  participant Worker as Background title worker
  participant Sidecar as WebUI session
  participant Sync as sync_session_title
  participant DB as hermes-agent state.db
  participant CLI as hermes sessions list
  Worker->>Sidecar: Save generated title
  Worker->>Sync: session_id, title, profile
  Sync->>DB: "ensure_session(source="webui")"
  Sync->>DB: set_auto_title_if_empty(title)
  Note over DB: Existing user or LLM title remains unchanged
  CLI->>DB: Read session titles
  DB-->>CLI: Generated title
Loading

Reviews (1): Last reviewed commit: "docs(changelog): stamp #6892 + add direc..." | Re-trigger Greptile

@nesquena-hermes
nesquena-hermes merged commit 8fb95b4 into master Aug 12, 2026
24 checks passed
@nesquena-hermes
nesquena-hermes deleted the release/stage-6892-1786560706 branch August 12, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants