feat(discord): searchable /model autocomplete - #57796
Closed
FixItFoundry wants to merge 1 commit into
Closed
Conversation
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
marked this pull request as ready for review
July 3, 2026 15:28
teknium1
reviewed
Jul 15, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
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:4010calls the synchronous catalog helper from the async autocomplete callback. That helper callslist_authenticated_providersat PR line 3932. Current gateway/modeldeliberately usesawait 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()withawait 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-719provides a decorator-capture pattern.
This is an automated hermes-sweeper review.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds type-to-filter autocomplete to the Discord
/modelslash 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 fromlist_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_modelcallback 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/modelcommand.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.