Skip to content

feat(discord): searchable /model autocomplete - #57796

Closed
FixItFoundry wants to merge 1 commit into
NousResearch:mainfrom
FixItFoundry:feat/discord-model-search-autocomplete
Closed

feat(discord): searchable /model autocomplete#57796
FixItFoundry wants to merge 1 commit into
NousResearch:mainfrom
FixItFoundry:feat/discord-model-search-autocomplete

Conversation

@FixItFoundry

@FixItFoundry FixItFoundry commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Adds type-to-filter autocomplete to the Discord /model slash command, so users can search the full set of authenticated models instead of scrolling a capped select menu.

Why

/model's picker is a Discord select menu, which Discord caps at 25 options (and the current picker surfaces only the first ~50). Once several providers are authenticated — each with dozens of models — the picker becomes impractical: no search, and most models aren't even shown.

How

  • _model_autocomplete_entries() builds a flat (label, value) catalog from list_authenticated_providers() (the same source the picker uses), uncapped, with the current provider ranked first. Cached ~120s since autocomplete fires on every keystroke; the underlying read is served from the on-disk provider-model cache.
  • _autocomplete_model callback filters by the typed substring and returns up to Discord's 25-choice limit. It reuses the existing slash authorization (_evaluate_slash_authorization) so the catalog isn't leaked to unauthorized users, and it never raises — any failure yields an empty suggestion list.
  • @app_commands.autocomplete(name=...) wired onto the /model command.

Compatibility

Fully backward compatible. The stock select-menu picker remains as the fallback (empty query / no autocomplete client), and every failure path degrades to an empty suggestion list, so command registration and handling are unaffected.

Testing

Verified across multiple agents and pulls all models from all wired providers. Typing filters live; an empty query surfaces the current provider's models first; unauthorized users get no suggestions.

The /model slash command offered only a select-menu picker capped at
Discord's 25-option limit with no way to filter — impractical once many
providers/models are authenticated. Add a type-to-filter autocomplete on
the name argument that searches the full authenticated-provider catalog
(current provider ranked first), returning the top 25 matches per
keystroke. The stock picker remains as a fallback, and any failure yields
an empty suggestion list so command registration/handling never breaks.
@FixItFoundry
FixItFoundry marked this pull request as ready for review July 3, 2026 15:28
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/discord Discord bot adapter labels Jul 3, 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 addressing a real Discord /model usability gap; current main still has a plain string-only /model command at plugins/platforms/discord/adapter.py:4082-4085 and the picker caps its selects at 25 entries (plugins/platforms/discord/adapter.py:7251-7255, 7274-7297).

Problems

  • Blocking: plugins/platforms/discord/adapter.py:4010 calls the synchronous catalog helper from the async autocomplete callback. That helper calls list_authenticated_providers at PR line 3932. Current gateway /model deliberately uses await asyncio.to_thread(...) for this category of listing (gateway/slash_commands.py:1514-1526) because a stale cache can take the synchronous HTTP path; the regression test documents prior 120–150-second gateway freezes (tests/gateway/test_model_command_async_offload.py:4-19).

Suggested changes

  • Offload _model_autocomplete_entries() with await asyncio.to_thread(...) before filtering the returned entries.
  • Add regression coverage for decorator registration, authorization returning [], filtering/capping, and the non-blocking listing boundary. tests/gateway/test_discord_slash_auth.py:673-719 provides a decorator-capture pattern.

This is an automated hermes-sweeper review.

Comment thread plugins/platforms/discord/adapter.py
@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@FixItFoundry
FixItFoundry changed the base branch from main to hermes/hermes-40531417 July 15, 2026 21:36
@FixItFoundry
FixItFoundry changed the base branch from hermes/hermes-40531417 to main July 15, 2026 21:37
@FixItFoundry

Copy link
Copy Markdown
Contributor Author

I recently changed my GitHub username from jessecasco to FixItFoundry. The workflow run for this commit was flagged/blocked by the CI security policy since the namespace changed, so it might need manual approval to run.

@FixItFoundry FixItFoundry closed this by deleting the head repository Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins 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-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