Skip to content

[Agent Builder] Agent does not 'forget' deleted tools that are re-created with the same name#253110

Merged
ashatova merged 29 commits intoelastic:mainfrom
ashatova:ab-update-deleted-tool
Feb 19, 2026
Merged

[Agent Builder] Agent does not 'forget' deleted tools that are re-created with the same name#253110
ashatova merged 29 commits intoelastic:mainfrom
ashatova:ab-update-deleted-tool

Conversation

@ashatova
Copy link
Copy Markdown
Contributor

@ashatova ashatova commented Feb 13, 2026

Closes: https://github.com/elastic/search-team/issues/12339

Summary

When deleting a tool that is still used by agents, the API returns 409 with the list of agents. The UI shows a confirmation modal; "Yes, remove and delete" calls delete again with force: true (removes the tool from those agents, then deletes it).

Changes

  • Public DELETE route: Optional force query (default false). If false and any agent uses the tool → 409 with code: 'TOOL_USED_BY_AGENTS' and agents: [{ id, name }, ...]. If true - remove refs from agents, then delete.
  • Common: TOOL_USED_BY_AGENTS_ERROR_CODE and AgentRef for the 409 response shape.
  • Agents service: getAgentsUsingTools(params) (check-only) and existing removeToolRefsFromAgents; runToolRefCleanup overloads for typing.
  • Public API: delete({ toolId, force }) and bulkDelete(toolIds, { force }).
  • UI: use_delete_tools detects 409, stores usedByAgents, shows force-confirm modal; tools_provider renders the modal and i18n.
  • Tests: Agents service tests for getAgentsUsingTools and removeToolRefsFromAgents (including error propagation).

@ashatova ashatova marked this pull request as ready for review February 16, 2026 09:52
@ashatova ashatova requested a review from a team as a code owner February 16, 2026 09:52
@ashatova ashatova added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:agent-builder labels Feb 16, 2026
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod Bot requested a review from a team as a code owner February 16, 2026 10:06
Comment thread x-pack/platform/plugins/shared/agent_builder/server/routes/internal/tools.ts Outdated
Comment thread x-pack/platform/plugins/shared/agent_builder/server/routes/tools.ts
@joemcelroy
Copy link
Copy Markdown
Member

Could you also add FTRs for this please? This has alot of moving parts, would be great to have some coverage here.

Copy link
Copy Markdown
Member

@leemthompo leemthompo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed couple minor copy/API docs things :)

Comment thread x-pack/platform/plugins/shared/agent_builder/server/routes/tools.ts Outdated
Comment thread x-pack/platform/plugins/shared/agent_builder/public/application/utils/i18n.ts Outdated
@ashatova ashatova requested a review from a team as a code owner February 18, 2026 14:46
Copy link
Copy Markdown
Member

@florent-leborgne florent-leborgne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for docs & copy

Copy link
Copy Markdown
Member

@leemthompo leemthompo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Feb 18, 2026

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
agentBuilder 569.4KB 571.5KB +2.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
agentBuilder 87.4KB 87.5KB +95.0B

History

@ashatova ashatova enabled auto-merge (squash) February 19, 2026 12:48
@ashatova ashatova merged commit bdbf269 into elastic:main Feb 19, 2026
16 checks passed
ersin-erdal pushed a commit to ersin-erdal/kibana that referenced this pull request Feb 19, 2026
…ated with the same name (elastic#253110)

Closes: elastic/search-team#12339

## Summary

When deleting a tool that is still used by agents, the API returns
**409** with the list of agents. The UI shows a confirmation modal;
"Yes, remove and delete" calls delete again with **`force: true`**
(removes the tool from those agents, then deletes it).

## Changes

- **Public DELETE route:** Optional **`force`** query (default `false`).
If `false` and any agent uses the tool → 409 with `code:
'TOOL_USED_BY_AGENTS'` and `agents: [{ id, name }, ...]`. If `true` -
remove refs from agents, then delete.
- **Common:** **`TOOL_USED_BY_AGENTS_ERROR_CODE`** and **`AgentRef`**
for the 409 response shape.
- **Agents service:** **`getAgentsUsingTools(params)`** (check-only) and
existing **`removeToolRefsFromAgents`**; **`runToolRefCleanup`**
overloads for typing.
- **Public API:** **`delete({ toolId, force })`** and
**`bulkDelete(toolIds, { force })`**.
- **UI:** **`use_delete_tools`** detects 409, stores **`usedByAgents`**,
shows force-confirm modal; **tools_provider** renders the modal and
i18n.
- **Tests:** Agents service tests for **`getAgentsUsingTools`** and
**`removeToolRefsFromAgents`** (including error propagation).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:agent-builder v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants