Skip to content

fix(discord): gate relay-only thread rename kwargs - #82911

Open
quocanh261997 wants to merge 1 commit into
NousResearch:mainfrom
quocanh261997:fix/discord-rename-thread-bug
Open

quocanh261997 wants to merge 1 commit into
NousResearch:mainfrom
quocanh261997:fix/discord-rename-thread-bug

Conversation

@quocanh261997

Copy link
Copy Markdown
Contributor

What does this PR do?

Restores native Discord auto-thread semantic renames by passing each adapter only the keyword arguments its lane supports.

The shared gateway caller previously sent relay-only prefer_connector_created and parent_chat_id arguments to the native Discord adapter. Its strict rename_thread signature rejected those arguments with TypeError; the surrounding best-effort handler logged only at DEBUG, so the thread kept its placeholder title without an INFO-level result.

This change keeps one polymorphic invocation while building lane-specific kwargs:

  • Native Discord receives only its existing only_if_current_name no-clobber guard.
  • Relay receives prefer_connector_created=True and the parent-channel discriminator.
  • Escaped TypeError contract failures are visible at WARNING; other cosmetic failures remain DEBUG-only.

This follows the call-site-gating direction discussed in #80869, but keeps the invocation single and adds one focused boundary regression to the existing title-rename test module. #78495 is the alternative adapter-tolerance approach.

Related Issue

Fixes #78487

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/run.py: gate native and relay rename kwargs at the shared call site and surface unexpected TypeError contract failures.
  • tests/gateway/test_session_title_rename_lane.py: cover the real gateway-to-native boundary with a signature-strict adapter stub.

How to Test

  1. Run the focused gateway modules:
    .venv/bin/python -m pytest -q \
      tests/gateway/test_session_title_rename_lane.py \
      tests/gateway/test_discord_slash_commands.py \
      tests/gateway/relay/test_relay_threads.py
  2. Run static checks:
    .venv/bin/python -m py_compile gateway/run.py tests/gateway/test_session_title_rename_lane.py
    .venv/bin/python -m ruff check gateway/run.py tests/gateway/test_session_title_rename_lane.py
    git diff --check
  3. For live acceptance, restart the gateway, trigger a native Discord auto-thread, and confirm discord auto-thread rename result: ... applied=True appears at INFO and the semantic title replaces the placeholder.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS, deterministic gateway tests; live Discord acceptance remains pending

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A; behavior and protocol are unchanged
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — pure Python call-shape fix
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Screenshots / Logs

34 passed, 2 unrelated websockets deprecation warnings
All checks passed! (Ruff)
py_compile: passed
git diff --check: passed

Live Discord acceptance was not performed as part of this deterministic test pass.

@quocanh261997
quocanh261997 marked this pull request as ready for review August 10, 2026 03:43
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter P2 Medium — degraded but workaround exists labels Aug 10, 2026
@rungmc357

Copy link
Copy Markdown
Contributor

I refreshed this fix against current upstream while preserving Michael Nguyen's authorship rather than reopening duplicate #81389.

Current candidate: rungmc357@2d185fa

Verification on the current repository test harness:

  • scripts/run_tests.sh tests/gateway/test_session_title_rename_lane.py tests/gateway/test_discord_slash_commands.py tests/gateway/relay/test_relay_threads.py tests/gateway/test_fast_command.py tests/agent/test_title_generator.py — 73 passed
  • scoped Ruff and py_compile — passed
  • git diff --check — passed
  • clean merge-tree against latest upstream main — passed (the one upstream advance during validation touched unrelated paths)

We also reproduced the failure again on a live native Discord lane on 2026-08-18: semantic title generation and the rename-dispatch INFO line both succeeded, but no rename-result or adapter-success line followed and the placeholder remained. Current upstream still passes the relay-only kwargs into the strict native adapter.

The call-site gating in this PR remains the right contract: relay receives prefer_connector_created / parent_chat_id; native receives only only_if_current_name.

@iyurinok

Copy link
Copy Markdown

+1 from a production native Discord gateway.

This is the implementation we want merged for #78487: call-site gating, strict native signature, TypeError promoted to WARNING. Confirmed the bug is still present on current main (rename_thread(..., prefer_connector_created=..., parent_chat_id=...) against native only_if_current_name only).

Please merge this and close the duplicate cluster (#80869, #78495).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/discord Discord bot adapter type/bug Something isn't working

Projects

None yet

4 participants