Skip to content

feat(discord): add rename_thread action to discord_tool - #46397

Open
cruzanstx wants to merge 1 commit into
NousResearch:mainfrom
cruzanstx:feat/discord-rename-thread-action
Open

feat(discord): add rename_thread action to discord_tool#46397
cruzanstx wants to merge 1 commit into
NousResearch:mainfrom
cruzanstx:feat/discord-rename-thread-action

Conversation

@cruzanstx

Copy link
Copy Markdown
Contributor

Summary

Fixes #46396 — adds a rename_thread action to discord_tool so agents asked to rename a thread in Discord have a first-class primitive instead of shelling out to curl.

The REST shape (PATCH /channels/{id} with {"name": ...}) is the same call that would rename a regular text channel, so the action probes the target's type first via GET /channels/{id} and refuses with a structured error if it isn't one of the thread types (10/11/12). That defense-in-depth prevents an agent asked "rename this thread" from inadvertently renaming a top-level channel sharing a similar-looking snowflake.

Classified as a core action (alongside fetch_messages, search_members, create_thread) rather than admin, since renaming is metadata-only and bots already need MANAGE_THREADS or thread ownership for the PATCH to succeed Discord-side.

Implementation

  • _rename_thread() function next to _create_thread() in tools/discord_tool.py
  • Registered in _ACTIONS, _ACTION_MANIFEST, _REQUIRED_PARAMS, _CORE_ACTION_NAMES
  • Schema enums for the discord core handler now include rename_thread; admin handler unchanged

Test plan

  • 5 new tests in tests/tools/test_discord_tool.py::TestRenameThread: public thread (type 11), private thread (12), announcement thread (10), refusal on text channel (0), refusal on forum (15)
  • Existing TestRegistration::test_core_schema_actions / test_admin_schema_actions updated to include rename_thread in the core set
  • Full test_discord_tool.py suite passes: 95 of 95
  • Live-verified against a real Discord guild: created a thread → called discord_core(action='rename_thread', ...) → Discord API confirmed the new name

Generated with Claude Code via Happy

The discord_tool surface exposed 15 server-management actions but no way
to rename a thread. The REST primitive is the same `PATCH /channels/{id}`
that renames a regular channel, so the action validates that the target
is a thread type (10/11/12) before issuing the PATCH — preventing an
agent asked to "rename this thread" from accidentally renaming a top-
level text/voice/forum channel sharing a similar-looking ID.

Action shape mirrors create_thread: classified core (read/participate),
not admin, since renaming is metadata-only and bot accounts already
need MANAGE_THREADS or thread ownership for it to succeed.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

@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: Approved

Adds rename_thread action to the Discord tool, allowing the model to rename an existing Discord thread via PATCH /channels/{id}.

What was changed

  • tools/discord_tool.py: new _rename_thread() function + added to _ACTIONS, _CORE_ACTION_NAMES, schema docs and parameters
  • Tests: 5 new test cases (public thread, private thread, announcement thread, refuses text channel, refuses forum channel)

Looks Good

  • Defense-in-depth: probes channel type before PATCH; refuses non-thread channels (type != 10/11/12)
  • Clear error messages when rejecting targets with actionable guidance
  • Tests cover all thread types and the two rejection cases
  • Action is part of core Discord tool (not admin-only), which is appropriate since renaming is a common user operation
  • Schema and documentation updated consistently

Reviewed by Hermes Agent

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter labels Jun 15, 2026
@cruzanstx

Copy link
Copy Markdown
Contributor Author

Bump — this PR was approved a month ago but never merged, and I think it's being masked by a triage mix-up.

#63330 was just closed as "already implemented and merged in #60187", but #60187 is a different feature: it's the gateway-internal auto-title path (adapter.rename_thread in plugins/platforms/discord/adapter.py), which only fires on threads Hermes just auto-created and is guarded by only_if_current_name, so it no-ops on anything a human touched. It is not callable by the agent.

The gap this PR fixes still exists on v0.18.2: ask the bot in any Discord thread to "rename this thread to X" and it has no primitive — it either gives up or shells out to curl with the bot token in context. (#46396 repro is still accurate.)

FWIW I applied this exact change locally on 0.18.2 (_rename_thread with the GET type-probe refusing non-10/11/12 channels, registered in _ACTIONS/manifest/required-params as a core action): works end-to-end, and the full discord tool test file passes with the two registration sets in tests/tools/test_discord_tool.py updated to include the new action — that test churn is the only thing this branch may be missing.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Discord tool addition. The premise remains valid on current main: tools/discord_tool.py:633-697 has no rename_thread action in the dispatch map, core action set, manifest, or required-parameter map. The existing adapter.rename_thread is a separate auto-title path: gateway/run.py:13778-13792 restricts it to the auto-created-thread lane and passes only_if_current_name, while plugins/platforms/discord/adapter.py:5401-5437 intentionally avoids renamed or pre-existing threads.

The proposed GET type probe before PATCH, non-thread refusal coverage, and core-schema registration match the reported need. GitHub reports this branch mergeable against current main.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 14, 2026
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 P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

discord_tool has no rename_thread action — agents asked to rename a thread can't

4 participants