Skip to content

fix(discord): title auto-threads after first response - #86712

Open
maxbomi wants to merge 4 commits into
NousResearch:mainfrom
maxbomi:fix/discord-contextual-auto-thread-title
Open

fix(discord): title auto-threads after first response#86712
maxbomi wants to merge 4 commits into
NousResearch:mainfrom
maxbomi:fix/discord-contextual-auto-thread-title

Conversation

@maxbomi

@maxbomi maxbomi commented Aug 15, 2026

Copy link
Copy Markdown

What does this PR do?

Delays Discord auto-thread semantic title generation until the first assistant response completes, then generates a one-shot title from the opening request and completed user/tool/assistant turn instead of the opener alone.

Normal session auto-titling remains opener-based. The richer contextual title is limited to Hermes-created Discord auto-threads and is not persisted over the normal session title.

Related issue

Related to #78487.

Changes

  • Dispatch Discord contextual titling only after a successful, non-partial first assistant response.
  • Generate concise, substantive titles from the completed first turn rather than generic task phrases such as “extract key takeaways.”
  • Preserve one-shot behavior and existing current-name/no-clobber guards.
  • Keep native and relay rename kwargs lane-specific, preventing relay-only kwargs from reaching the strict native adapter.
  • Treat the complete transcript as delimited, untrusted JSON data and explicitly ignore embedded instructions/title suggestions from user, assistant, or tool content.
  • Share title-output validation between normal and contextual paths so answer-shaped or overlong model output is rejected.
  • Add regressions for timing, contextual content, one-shot behavior, injection resistance, output validation, and native/relay call shapes.

Overlapping work disclosure

This PR intentionally overlaps the focused native rename call-shape repairs in #80869 and #82911. #78495, #82752, and #84501 address the same delivery failure through alternative adapter-tolerance/two-stage approaches. If maintainers land a focused call-shape fix first, this PR can be rebased to drop the duplicate hunk while retaining the distinct contextual-title feature and preserving contributor credit.

#87344 is complementary presentation/sanitizer work and may touch nearby gateway/run.py code. This PR retains context-driven, multilingual titling rather than adding English-only compaction heuristics.

#29983 and #33862 cover periodic or pre-existing-thread renaming. This PR remains limited to Hermes-created auto-threads and a single title after the first completed response.

Verification

The four patches received independent Reviewer PASS before publication and were then rebased patch-equivalently onto current main. Final publication head: 470cb96323e3739eba6b517396129db1dfe15f1f.

python -m pytest -o 'addopts=' -q \
  tests/agent/test_title_generator.py \
  tests/gateway/test_session_title_rename_lane.py \
  tests/gateway/relay/test_relay_threads.py \
  tests/gateway/test_discord_slash_commands.py

python -m ruff check \
  agent/title_generator.py \
  gateway/run.py \
  tests/agent/test_title_generator.py \
  tests/gateway/test_session_title_rename_lane.py \
  tests/gateway/relay/test_relay_threads.py

python -m py_compile agent/title_generator.py gateway/run.py
git diff --check origin/main...HEAD

Results:

  • 78 affected and adjacent tests passed on the latest rebased head.
  • Final independent review: PASS; 153 tests passed across the broader title/gateway/runtime surface on the preceding patch-equivalent base.
  • Ruff, py_compile, and git diff --check passed.
  • git range-diff confirmed all four patches remained equivalent across the reviewed rebases; the final rebase was conflict-free and all affected gates were rerun.
  • Real auxiliary-model smoke titles:
    • Wispr Flow scales hiring sustainably
    • Philippine side hustles expose wage insecurity
    • Adversarial tool instruction was ignored: Desert site has clearer winter skies
  • Overlong/answer-shaped outputs are rejected on both normal and contextual title paths.

GitHub CI state is reported separately by the PR; no claim of repository-wide green CI is made here.

Risk and rollback

Risk is limited to the Discord auto-created-thread title lane and one auxiliary title request after the first completed response. Existing session titles, Telegram behavior, human-renamed thread guards, and normal opener-based title persistence remain unchanged.

Rollback: revert the four commits in this PR; no migration or configuration rollback is required.

Checklist

  • Repository and contribution instructions reviewed.
  • Existing and overlapping PRs reviewed and disclosed.
  • Focused regression tests added.
  • Prompt-injection boundary tested with adversarial tool content.
  • Native and relay call-shape tests passed.
  • Exact rebased head independently reviewed.
  • Full repository test suite run; affected and adjacent suites are green.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 15, 2026
@maxbomi
maxbomi force-pushed the fix/discord-contextual-auto-thread-title branch from b237d77 to 470cb96 Compare August 17, 2026 10:41
@maxbomi
maxbomi marked this pull request as ready for review August 17, 2026 10:41
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 comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants