Skip to content

fix(title): use lineage fallback for generated titles - #26471

Closed
JackALaing wants to merge 1 commit into
NousResearch:mainfrom
JackALaing:fix/title-lineage-fallback
Closed

fix(title): use lineage fallback for generated titles#26471
JackALaing wants to merge 1 commit into
NousResearch:mainfrom
JackALaing:fix/title-lineage-fallback

Conversation

@JackALaing

Copy link
Copy Markdown

Summary

  • Use SessionDB.get_next_title_in_lineage() when an auto-generated session title collides with an existing title.
  • Apply the fallback title before firing title_callback, so listeners receive the persisted title rather than the rejected duplicate.
  • Add focused regression coverage for the successful fallback path and the failure path where no callback should fire.

Test Plan

  • python -m pytest tests/agent/test_title_generator.py -q
  • python -m py_compile agent/title_generator.py

Platforms Tested

  • macOS 26.4.1, arm64

Related / competing PRs

  • Searched GitHub issues/PRs for get_next_title_in_lineage, lineage fallback, generated titles, and title-generator uniqueness/conflict terms.
  • No open or merged PR found that supersedes this collision fallback.
  • Adjacent non-duplicate title-generator work found: PR #17797, PR #11280, PR #18839, PR #4946, PR #19137, PR #20338, PR #13211. These cover other auto-title paths such as reasoning output, timing, stale model reloads, or clean input selection.

Notes/Risks

  • This is limited to auto-generated titles. Manual /title conflicts still surface through the existing set_session_title() behavior.
  • Cross-platform impact: none expected. The change is pure Python session-title control flow and does not touch file I/O, process management, shell commands, gateway runtime, or terminal handling.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #26389 — both fix auto_title_session() failing to handle title collision by falling back to get_next_title_in_lineage(). Same root cause (ValueError from unique constraint not caught), same fix approach.

@alt-glitch alt-glitch added P3 Low — cosmetic, nice to have type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels May 15, 2026
@JackALaing

Copy link
Copy Markdown
Author

The main differences in this PR are:

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for covering the still-present duplicate-title path. Current main still calls set_session_title() directly in agent/title_generator.py:155 and swallows its ValueError at agent/title_generator.py:162-163, so the lineage fallback is needed.

Problems

  • The added persistence calls do not inspect their return values (agent/title_generator.py:123 in this PR, and the fallback call immediately below it). SessionDB.set_session_title() returns False when no session row was updated (hermes_state.py:2706-2753). In that case this PR would still call title_callback with a title that was not persisted, contrary to the callback guarantee described in the PR.

Suggested changes

  • Require successful return values from both writes before logging success or invoking the callback, and add tests for False on the initial and fallback writes.

Automated hermes-sweeper review.

Comment thread agent/title_generator.py
title_callback(title)
except Exception:
logger.debug("Auto-title callback failed", exc_info=True)
session_db.set_session_title(session_id, final_title)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

set_session_title() returns False when the session no longer exists (hermes_state.py:2706-2753). Check that result here and on the fallback write before invoking title_callback; otherwise consumers receive a title that was never persisted.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution — you were the first to submit the collision-retry idea (May 15), five weeks ahead of the implementation that ultimately landed, and you're credited in the merged PR body for it.

The fix landed via PR #66058, which salvaged #50575's version of the same retry: it generalizes the dedup to a _persist_session_title helper covering all auto-titled sessions (not just the collision case), hardens the cron scheduler's title write in the same pass, and shipped with broader test coverage. Your title_callback-fires-only-after-final-persist behavior is preserved in the merged code.

Closing as superseded — first-submitter credit is yours.

@teknium1 teknium1 closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants