Skip to content

[codex] Add Discord read tools - #4677

Open
orangebread wants to merge 2 commits into
NousResearch:mainfrom
orangebread:feat/discord-read-tools
Open

[codex] Add Discord read tools#4677
orangebread wants to merge 2 commits into
NousResearch:mainfrom
orangebread:feat/discord-read-tools

Conversation

@orangebread

@orangebread orangebread commented Apr 3, 2026

Copy link
Copy Markdown

Summary

Adds three read-only Discord tools scoped by explicit allowlists:

  • discord_list_channels
  • discord_read_history
  • discord_search_messages

The implementation uses Discord HTTP API v10, auto-allows the current Discord session target when appropriate, includes active thread discovery and thread-aware name resolution, enforces hard safety bounds on history/search windows, and returns message permalinks when possible.

Why

Hermes could write to Discord through the gateway but had no safe, bounded way to inspect Discord context from tools. This change adds production-scoped read access without pretending to provide unrestricted server-wide search.

Impact

  • New discord_read toolset and core-tool registrations
  • Config/env support for:
    • DISCORD_READ_ALLOWED_GUILDS
    • DISCORD_READ_ALLOWED_CHANNELS
    • DISCORD_READ_INCLUDE_DMS
  • Deterministic Discord channel/thread resolution in the gateway directory
  • Docs and tests covering allowlists, current-session access, thread discovery, and result limits
  • Branch updated with current main and conflict resolution completed

Validation

Passed:

  • python -m pytest tests/tools/test_discord_read_tool.py -q
  • python -m pytest tests/gateway/test_channel_directory.py -q
  • python -m pytest tests/gateway/test_session.py -q
  • python -m pytest tests/gateway/test_config.py -q
  • python -m pytest tests/gateway/test_api_server_toolset.py -q
  • python -m pytest tests/test_toolsets.py -q
  • python -m pytest tests/tools/test_discord_read_tool.py tests/gateway/test_channel_directory.py tests/gateway/test_session.py tests/gateway/test_config.py tests/gateway/test_api_server_toolset.py tests/test_toolsets.py -q
    • Result: 129 passed

Full suite status in this environment after merging current main:

  • python -m pytest tests/ -q
    • Branch result: 7 failed, 7801 passed, 188 skipped, 1 xpassed
    • Current origin/main result: 6 failed, 7791 passed, 188 skipped, 1 xpassed

Known baseline failures on current origin/main:

  • tests/hermes_cli/test_tools_config.py::test_first_install_nous_auto_configures_managed_defaults
  • tests/tools/test_transcription.py::TestGetProvider::test_explicit_local_no_cloud_fallback
  • tests/tools/test_transcription.py::TestGetProvider::test_local_nothing_available
  • tests/tools/test_file_read_guards.py::TestConfigOverride::test_custom_config_raises_limit
  • tests/tools/test_file_read_guards.py::TestCharacterCountGuard::test_content_under_limit_passes
  • tests/tools/test_file_read_guards.py::TestCharacterCountGuard::test_oversized_read_rejected

Additional flaky failure observed both on this branch and when run directly on origin/main:

  • tests/gateway/test_approve_deny_commands.py::TestBlockingApprovalE2E::test_parallel_mixed_approve_deny

Environment note:

  • Validation used the shared venv with the repo installed editable from this branch.

@orangebread
orangebread marked this pull request as ready for review April 3, 2026 07:24
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have platform/discord Discord bot adapter comp/tools Tool registry, model_tools, toolsets labels May 1, 2026

@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 the bounded, read-only design and the coverage around current-session access and thread discovery.

Problems

  • Current main already has REST-backed Discord message retrieval and channel listing: tools/discord_tool.py:511-526 implements fetch_messages, and tools/discord_tool.py:382-384 implements list_channels. Current main intentionally keeps discord and discord_admin off _HERMES_CORE_TOOLS (toolsets.py:453-459; tests/tools/test_discord_tool.py:661-676). Adding three parallel schemas to the core bundle in this PR duplicates that surface and expands it to non-Discord platform bundles.
  • hermes_cli/config.py:924-944 and website/docs/user-guide/messaging/discord.md:277-280 make read scope a user-facing .env configuration. AGENTS.md:102-106 requires behavioral settings to be documented in config.yaml instead.

Suggested changes

  • Re-scope the bounded search/current-session work onto the existing Discord toolsets rather than adding core tools.
  • Keep discord.read.* as the documented configuration path and remove the new .env setup surface.

Automated hermes-sweeper review.

Comment thread toolsets.py
# Cross-platform messaging (gated on gateway running via check_fn)
"send_message",
# Discord read-only access (gated on Discord bot config)
"discord_list_channels", "discord_read_history", "discord_search_messages",

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.

Please do not add these Discord-specific schemas to _HERMES_CORE_TOOLS. Current main deliberately keeps the existing discord and discord_admin REST tools on hermes-discord only (toolsets.py:453-459; tests/tools/test_discord_tool.py:661-676). Re-scope the bounded read behavior onto that established Discord surface instead of exposing parallel tools to every platform bundle.

Comment thread hermes_cli/config.py
"password": False,
"category": "messaging",
},
"DISCORD_READ_ALLOWED_GUILDS": {

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.

These are non-secret behavioral allowlist settings. Please retain discord.read.* in config.yaml as the user-facing interface and remove these entries from .env setup; AGENTS.md requires behavioral settings to be documented in config rather than .env.

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants