Crash and error when trying to remove the last tool from Agent
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3563628. -->
Reported by: [yautja_cetanu](https://www.drupal.org/user/626050)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>- Create an Agent<br>
- I was using the Tool API (But also a mixutre of Tool API tools and normal tools)<br>
- Add Tools<br>
- Remove them<br>
- Remove the last one<br>
- Click save<br>
- Get crash<br>
- Can go back into the Agent and see the tool is still there, and can add another one, and then remove it (as long as one still remains).</p>
<p>Error:</p>
<p><code>Drupal\Component\Plugin\Exception\PluginNotFoundException: The "1" plugin does not exist. Valid plugin IDs for Drupal\ai\Service\FunctionCalling\FunctionCallPluginManager are: ai_agent:html_to_markdown, action_plugin:eca_error_message, action_plugin:eca_warning_message, action_plugin:node_make_unsticky_action, action_plugin:node_make_sticky_action, action_plugin:node_unpromote_action, action_plugin:node_promote_action, action_plugin:user_remove_role_action, action_plugin:user_add_role_action, action_plugin:user_block_user_action, action_plugin:user_unblock_user_action, action_plugin:action_send_email_action, action_plugin:entity:unpublish_action:block_content, action_plugin:entity:unpublish_action:comment, action_plugin:entity:unpublish_action:menu_link_content, action_plugin:entity:unpublish_action:node, action_plugin:entity:unpublish_action:path_alias, action_plugin:entity:unpublish_action:taxonomy_term, action_plugin:action_goto_action, action_plugin:entity:publish_action:block_content, action_plugin:entity:publish_action:comment, action_plugin:entity:publish_action:menu_link_content, action_plugin:entity:publish_action:node, action_plugin:entity:publish_action:path_alias, action_plugin:entity:publish_action:taxonomy_term, action_plugin:entity:save_action:block_content, action_plugin:entity:save_action:comment, action_plugin:entity:save_action:file, action_plugin:entity:save_action:menu_link_content, action_plugin:entity:save_action:node, action_plugin:entity:save_action:taxonomy_term, action_plugin:entity:save_action:user, action_plugin:entity:save_action:workspace, action_plugin:action_message_action, ai_agent:list_field_display_types, ai_agent:get_current_content_entity_values, ai_agent:get_field_display_form, ai_agent:manipulate_field_config, ai_agent:get_config_schema, ai_agent:get_field_values_and_context, ai_agent:edit_content_type, ai_agent:get_field_config, ai_agent:list_taxonomy_term, ai_agent:get_entity_field_information, ai_agent:agent_ckeditor_output, ai_agent:list_field_types, ai_agent:create_content_type, ai_agent:get_field_storage_form, ai_agent:manipulate_field_display_form, ai_agent:content_entity_field_values_list, ai_agent:content_entity_field_value, ai_agent:create_agent_config_tools_enabled, ai_agent:content_entity_seeder, ai_agent:create_field_storage_config, ai_agent:list_entity_types, ai_agent:vision, ai_agent:list_content_entities, ai_agent:modify_vocabulary, ai_agent:get_field_storage, ai_agent:get_entity_type_field_storage, ai_agent:get_content_type_info, ai_agent:modify_taxonomy_term, ai_agent:get_field_config_form, ai_agent:preparing_response, ai_agent:list_config_entities, ai_agent:list_bundles, ai_search:rag_search, tool:entity_delete, tool:entity_load_by_property, tool:entity_field_values, tool:entity_list, tool:entity_save, tool:field_set_value, tool:entity_revision_add, tool:entity_stub, tool:entity_field_value_definitions, tool:entity_load_by_id, tool:entity_translation_get, tool:entity_bundle_list, tool:field_add, tool:field_storage_delete, tool:field_storage_update, tool:field_storage_add, tool:entity_bundle_add, tool:field_type_definitions, tool:field_delete, tool:entity_type_list, tool:entity_bundle_update, tool:entity_bundle_field_definitions, tool:entity_bundle_delete, tool:field_update, tool:entity_bundle_definition, tool:send_email, tool:system_status, tool:log_message, tool:display_message, tool:user_add_role, tool:user_remove_role, tool:user_unblock, tool:user_block, ai_agents::ai_agent::field_type_agent, ai_agents::ai_agent::taxonomy_agent, ai_agents::ai_agent::node_content_type_agent, ai_agents::ai_agent::agent_bundle_lister, ai_agents::ai_agent::bundle_lister_assistant, ai_agents::ai_agent::content_type_agent_triage, ai_agents::ai_agent::field_agent_triage, ai_agents::ai_agent::taxonomy_agent_config in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).</code></p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue