Skip to content

agent: Don't offer feature-flag-gated tools in agent profiles - #58581

Merged
yara-blue merged 5 commits into
zed-industries:mainfrom
rabbiveesh:fix-agent-profile-flag-gated-tools
Jun 8, 2026
Merged

agent: Don't offer feature-flag-gated tools in agent profiles#58581
yara-blue merged 5 commits into
zed-industries:mainfrom
rabbiveesh:fix-agent-profile-flag-gated-tools

Conversation

@rabbiveesh

Copy link
Copy Markdown
Contributor

Closes #56778

Problem

The agent-profile tool configuration lists every built-in tool from agent::ALL_TOOL_NAMES, filtering only by provider support (crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs). But Thread::enabled_tools additionally drops feature-flag-gated tools before they reach the model — the LSP tools (go_to_definition, find_references, get_code_actions, apply_code_action) behind LspToolFeatureFlag, rename_symbol behind RenameToolFeatureFlag, and create_thread / list_agents_and_models / update_plan / update_title behind their own flags.

The result: when a flag is off, a user can enable the tool in a profile, but the agent never receives it. The picker and the runtime gate disagreed.

Fix

Extract the feature-flag gating into a single shared predicate, agent::tool_feature_flag_enabled, and route both Thread::enabled_tools and the profile tool picker through it. The configuration UI can no longer offer a tool the agent would silently drop, and the two call sites can't drift apart. Also updated the "silent drop gates" comment in tools.rs to document this third gate.

This matches the behavior requested in the issue (don't list tools that can't be used). The alternative — showing them disabled with an explanation — is also possible; happy to switch if preferred.

Testing

  • Added lsp_tools_are_gated_by_their_feature_flag in crates/agent/src/tools.rs.
  • cargo test -p agent, cargo clippy -p agent, and cargo fmt are clean.
  • (agent_ui doesn't build in my local environment due to an unrelated webrtc-sys C++ toolchain issue; the agent_ui change is a one-line filter addition mirroring the adjacent provider-support check — relying on CI to confirm.)

Release Notes:

  • Fixed feature-flag-gated tools (such as the LSP tools) being listed in agent profile configuration when they could not actually be used by the agent.

The agent-profile tool picker listed every built-in tool from
`ALL_TOOL_NAMES`, filtering only by provider support. But
`Thread::enabled_tools` additionally drops feature-flag-gated tools
(the LSP tools, `rename_symbol`, `create_thread`, `update_plan`,
`update_title`) unless their flag is active. Users could enable those
tools in a profile, yet the agent never received them.

Extract the flag gating into a single shared predicate,
`tool_feature_flag_enabled`, and route both `enabled_tools` and the
profile tool picker through it, so the configuration UI can never offer
a tool the agent would silently drop.

Fixes zed-industries#56778

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 4, 2026
@rabbiveesh
rabbiveesh marked this pull request as ready for review June 4, 2026 19:42
@rabbiveesh

Copy link
Copy Markdown
Contributor Author

Note to maintainers - if you'd prefer the canonical list of feature flags to live elsewhere, i can move them; this seems good to me in a vaccum but you have more context

@yara-blue yara-blue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One note otherwise good, thanks!

Comment thread crates/agent/src/tools.rs Outdated
@yara-blue yara-blue self-assigned this Jun 5, 2026
@rabbiveesh
rabbiveesh requested a review from yara-blue June 5, 2026 09:35
@yara-blue
yara-blue enabled auto-merge June 5, 2026 11:01
@yara-blue
yara-blue disabled auto-merge June 5, 2026 12:45
@yara-blue

Copy link
Copy Markdown
Contributor

Super minor test failure. Could you fix that?

@rabbiveesh

Copy link
Copy Markdown
Contributor Author

Ya gladly; 😀

@yara-blue
yara-blue enabled auto-merge June 8, 2026 09:09
@yara-blue
yara-blue added this pull request to the merge queue Jun 8, 2026
Merged via the queue into zed-industries:main with commit 88e5c6d Jun 8, 2026
32 checks passed
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 8, 2026
…dustries#58581)

Closes zed-industries#56778

## Problem

The agent-profile tool configuration lists every built-in tool from
`agent::ALL_TOOL_NAMES`, filtering only by provider support
(`crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs`).
But `Thread::enabled_tools` additionally drops feature-flag-gated tools
before they reach the model — the LSP tools (`go_to_definition`,
`find_references`, `get_code_actions`, `apply_code_action`) behind
`LspToolFeatureFlag`, `rename_symbol` behind `RenameToolFeatureFlag`,
and `create_thread` / `list_agents_and_models` / `update_plan` /
`update_title` behind their own flags.

The result: when a flag is off, a user can enable the tool in a profile,
but the agent never receives it. The picker and the runtime gate
disagreed.

## Fix

Extract the feature-flag gating into a single shared predicate,
`agent::tool_feature_flag_enabled`, and route **both**
`Thread::enabled_tools` and the profile tool picker through it. The
configuration UI can no longer offer a tool the agent would silently
drop, and the two call sites can't drift apart. Also updated the "silent
drop gates" comment in `tools.rs` to document this third gate.

This matches the behavior requested in the issue (don't list tools that
can't be used). The alternative — showing them disabled with an
explanation — is also possible; happy to switch if preferred.

## Testing

- Added `lsp_tools_are_gated_by_their_feature_flag` in
`crates/agent/src/tools.rs`.
- `cargo test -p agent`, `cargo clippy -p agent`, and `cargo fmt` are
clean.
- (`agent_ui` doesn't build in my local environment due to an unrelated
`webrtc-sys` C++ toolchain issue; the `agent_ui` change is a one-line
filter addition mirroring the adjacent provider-support check — relying
on CI to confirm.)

Release Notes:

- Fixed feature-flag-gated tools (such as the LSP tools) being listed in
agent profile configuration when they could not actually be used by the
agent.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…dustries#58581)

Closes zed-industries#56778

## Problem

The agent-profile tool configuration lists every built-in tool from
`agent::ALL_TOOL_NAMES`, filtering only by provider support
(`crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs`).
But `Thread::enabled_tools` additionally drops feature-flag-gated tools
before they reach the model — the LSP tools (`go_to_definition`,
`find_references`, `get_code_actions`, `apply_code_action`) behind
`LspToolFeatureFlag`, `rename_symbol` behind `RenameToolFeatureFlag`,
and `create_thread` / `list_agents_and_models` / `update_plan` /
`update_title` behind their own flags.

The result: when a flag is off, a user can enable the tool in a profile,
but the agent never receives it. The picker and the runtime gate
disagreed.

## Fix

Extract the feature-flag gating into a single shared predicate,
`agent::tool_feature_flag_enabled`, and route **both**
`Thread::enabled_tools` and the profile tool picker through it. The
configuration UI can no longer offer a tool the agent would silently
drop, and the two call sites can't drift apart. Also updated the "silent
drop gates" comment in `tools.rs` to document this third gate.

This matches the behavior requested in the issue (don't list tools that
can't be used). The alternative — showing them disabled with an
explanation — is also possible; happy to switch if preferred.

## Testing

- Added `lsp_tools_are_gated_by_their_feature_flag` in
`crates/agent/src/tools.rs`.
- `cargo test -p agent`, `cargo clippy -p agent`, and `cargo fmt` are
clean.
- (`agent_ui` doesn't build in my local environment due to an unrelated
`webrtc-sys` C++ toolchain issue; the `agent_ui` change is a one-line
filter addition mirroring the adjacent provider-support check — relying
on CI to confirm.)

Release Notes:

- Fixed feature-flag-gated tools (such as the LSP tools) being listed in
agent profile configuration when they could not actually be used by the
agent.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yara-blue yara-blue removed their assignment Aug 3, 2026
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…dustries#58581)

Closes zed-industries#56778

## Problem

The agent-profile tool configuration lists every built-in tool from
`agent::ALL_TOOL_NAMES`, filtering only by provider support
(`crates/agent_ui/src/agent_configuration/manage_profiles_modal.rs`).
But `Thread::enabled_tools` additionally drops feature-flag-gated tools
before they reach the model — the LSP tools (`go_to_definition`,
`find_references`, `get_code_actions`, `apply_code_action`) behind
`LspToolFeatureFlag`, `rename_symbol` behind `RenameToolFeatureFlag`,
and `create_thread` / `list_agents_and_models` / `update_plan` /
`update_title` behind their own flags.

The result: when a flag is off, a user can enable the tool in a profile,
but the agent never receives it. The picker and the runtime gate
disagreed.

## Fix

Extract the feature-flag gating into a single shared predicate,
`agent::tool_feature_flag_enabled`, and route **both**
`Thread::enabled_tools` and the profile tool picker through it. The
configuration UI can no longer offer a tool the agent would silently
drop, and the two call sites can't drift apart. Also updated the "silent
drop gates" comment in `tools.rs` to document this third gate.

This matches the behavior requested in the issue (don't list tools that
can't be used). The alternative — showing them disabled with an
explanation — is also possible; happy to switch if preferred.

## Testing

- Added `lsp_tools_are_gated_by_their_feature_flag` in
`crates/agent/src/tools.rs`.
- `cargo test -p agent`, `cargo clippy -p agent`, and `cargo fmt` are
clean.
- (`agent_ui` doesn't build in my local environment due to an unrelated
`webrtc-sys` C++ toolchain issue; the `agent_ui` change is a one-line
filter addition mirroring the adjacent provider-support check — relying
on CI to confirm.)

Release Notes:

- Fixed feature-flag-gated tools (such as the LSP tools) being listed in
agent profile configuration when they could not actually be used by the
agent.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP tools listed in agent profiles can't be used by agents

2 participants