Skip to content

Feature: Dynamic model selection via ACP configOptions + Discord slash command #477

@chaodu-agent

Description

@chaodu-agent

Summary

Add a /model Discord slash command that dynamically lists available models from the ACP agent backend (e.g. Kiro CLI) and lets users switch models via an interactive Discord Select Menu — all driven by the ACP configOptions protocol.

Motivation

Currently, OpenAB binds to a single agent backend configured in config.toml. There is no way for users to discover or switch models at runtime from Discord. The ACP spec already defines session/configOptions with category: "model" for exactly this purpose — OpenAB just needs to bridge it to Discord UI.

Proposed Flow

User types /model in Discord
        ↓
OpenAB reads configOptions from the current ACP session
  (category: "model" → list of available models)
        ↓
OpenAB renders a Discord Select Menu with the model options
        ↓
User picks a model (e.g. "opus-4")
        ↓
OpenAB sends session/set_config_option to the ACP agent
  { configId: "model", value: "opus-4" }
        ↓
Agent confirms → OpenAB updates the Discord message
  "✅ Switched to Opus 4"

Implementation Details

1. Discord Slash Command Registration

Register /model as a guild command on bot startup (EventHandler::ready):

guild_id.set_commands(&ctx.http, vec![
    CreateCommand::new("model")
        .description("Select the AI model for this session")
]).await?;

2. ACP configOptions Parsing

After session/create, parse the configOptions array from the response and cache options with category: "model".

3. Discord Select Menu

Convert ACP configOptions into a Discord StringSelectMenu:

  • Each ConfigOptionValue → one select menu option
  • currentValue → default selection
  • custom_idacp_config_{configOption.id}

4. Interaction Handler

On interaction_create for component interactions with custom_id starting with acp_config_:

  1. interaction.defer_update()
  2. Send session/set_config_option via ACP JSON-RPC
  3. Update the Discord message with confirmation

5. Agent-Initiated Updates

Handle config_option_update notifications from the agent (e.g. model fallback due to rate limits) and optionally notify the Discord thread.

Extensibility

The same mechanism can be reused for other ACP config categories:

Slash Command ACP Category Purpose
/model model Switch AI model
/mode mode Switch session mode (ask/code)
/thinking thought_level Set reasoning level

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions