Problem/Motivation

A mode (ai_agent_mode config entity) is keyed to a parent agent. When two AI Assistants are backed by the same parent agent, every mode is offered in both assistants' chats, so a mode written for one assistant's job shows up in the other. There is no way to say "offer this mode for this assistant only". The existing surfaces field does not help: it is a free list of surface IDs that most surfaces do not filter on.

Steps to reproduce

  1. Install AI Agent Modes with the AI Assistant API and AI Chatbot.
  2. Create two AI Assistants backed by the same parent agent.
  3. Save a mode for that parent agent.
  4. Open both assistants' chats: the same mode is offered in both, with no way to limit it to one.

Proposed resolution

Add an optional assistants list to the mode entity: the AI Assistants the mode is offered for. Empty (the default) means every assistant, so existing modes are unchanged. A non-empty list means those assistants only, and the mode is withheld where there is no assistant at all (the Drupal Canvas AI panel is driven by the canvas_ai_orchestrator agent, not by an assistant). Unlike surfaces, every surface passes the assistant along, so this is real filtering.

What the change covers:

  • ai_agent_mode entity: new assistants property in config_export, getAssistants(), appliesToAssistant(), plus the config schema.
  • ModeManagerInterface::listModes($parent_agent_id, $surface, $assistant_id) gains the assistant filter.
  • Admin: an AI Assistants checkboxes field on the mode add/edit form (only rendered when the site has assistants), and an AI Assistants column on the Modes listing showing "Any assistant" when open.
  • Surfaces all pass the assistant: the AI Assistant chat form (#assistant on the ai_agent_mode_select element), the AI Chatbot DeepChat block (drupalSettings.aiAgentModesChatbot.assistant, script sends ?assistant=<id>), the selector block (its configured AI Assistant), and GET /ai-agent-modes/options/{agent}?assistant=<id> (the response also echoes assistant).
  • Tests: a kernel test case for the assistant filtering, an updated chatbot hooks unit test, and a new webship-js BDD feature tests/features/drupal/05-01-02-assistant-limited-modes.feature.
  • Docs: managing modes, developing with modes, troubleshooting, choosing a mode, README.

AI-Generated: Yes. Per the Policy on the use of AI when contributing to Drupal, this issue summary and the forthcoming patch were drafted with AI assistance.

Remaining tasks

  • ✅ File an issue about this project
  • ❌ Addition/Change/Update/Fix to this project
  • ❌ Testing to ensure no regression
  • ❌ Automated unit/functional testing coverage
  • ❌ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ❌ Update Release Notes
  • ❌ Release

User interface changes

  • Yes: new AI Assistants field on the mode add/edit form, new AI Assistants column on the Modes listing.

API changes

  • Yes, additive: AiAgentModeInterface::getAssistants() and ::appliesToAssistant(); a third $assistant_id argument on ModeManagerInterface::listModes() (optional, defaults to NULL); a new #assistant property on the ai_agent_mode_select element; a new optional assistant query parameter and response key on the options endpoint.

Data model changes

  • Yes, additive: assistants sequence on ai_agent_modes.ai_agent_mode.*. Defaults to empty, so existing modes keep behaving exactly as before. No update hook needed.

Release notes snippet

  • A mode can now be offered for selected AI Assistants only, so two assistants sharing one parent agent can each offer the modes that belong to their job. Naming no assistant, the default, keeps offering the mode everywhere.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Status: Active » Fixed
Issue tags: +ai_agent_modes-1.0.0-alpha4

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.