Use AgentTool::NAME const instead of name() method and hardcoded strings#48506
Merged
Use AgentTool::NAME const instead of name() method and hardcoded strings#48506
Conversation
Add const NAME: &'static str to the AgentTool trait, replacing the fn name() method with a default implementation that returns Self::NAME. This allows tool names to be used in const contexts (e.g. const arrays). Also adds ALL_TOOL_NAMES const array generated by the tools! macro, providing a single source of truth for all built-in tool names.
Remove the fn name() default method from the AgentTool trait. All call sites now use the NAME associated constant directly.
Replace hardcoded tool name string literals with Self::NAME.to_string() (or EditFileTool::NAME for streaming_edit_file_tool) in all ToolPermissionContext construction sites across tool implementations.
Replace hardcoded tool name strings with the corresponding NAME associated constants in: - has_tool() lookups (edit_file_tool, streaming_edit_file_tool) - Tool routing in Thread::enabled_tools (streaming_edit_file/edit_file) - Subagent telemetry ID - Eval tool-use filtering
Replace hardcoded "terminal" and "edit_file" string literals with TerminalTool::NAME and EditFileTool::NAME in the tool_permissions test module.
Replace hardcoded tool name string literals in tests/mod.rs with the corresponding NAME associated constants (TerminalTool::NAME, EditFileTool::NAME, FetchTool::NAME, etc.) in ToolPermissionContext, LanguageModelToolUse, settings inserts, and has_registered_tool calls.
Replace hardcoded "read_file" and "edit_file" string literals with ReadFileTool::NAME and EditFileTool::NAME in LanguageModelToolUse constructions, tools.insert() calls, and has_registered_tool() checks.
Fix cargo fmt violations in tests/mod.rs and replace ::name() calls with ::NAME in the eval crate's planets example.
Remove the supported_built_in_tool_names function, making ALL_TOOL_NAMES the single source of truth for built-in tool names. The one call site now filters ALL_TOOL_NAMES directly using tool_supports_provider() and the subagent feature flag check.
be757c9 to
6430055
Compare
naaiyy
added a commit
to Glass-HQ/Glass
that referenced
this pull request
Feb 16, 2026
Key changes: - Thermal state detection (zed-industries#45638) - GPUI detects system thermal state, throttles to ~60fps when overheating - Checkerboard shader for side-by-side diff (zed-industries#48417) - visual pattern for diff backgrounds - cosmic-text v0.17 (zed-industries#48504) - fixes font ligatures on Linux - Middle click tab close (zed-industries#44916) - on_aux_click/is_middle_click API additions - Soft wrap modes for wrap width (zed-industries#46422) - Tab switcher mode similar to vim/helix buffer picker (zed-industries#47079) - Multi_buffer optimization batch (zed-industries#48519) - TreeMap for diagnostics (zed-industries#48482) - performance improvement - Semantic token follow-up fixes (zed-industries#48485) - Claude Opus 4.6 and 1M context window model variants (zed-industries#48508) - Anthropic adaptive thinking types (zed-industries#48517) - Side-by-side diff: hunk gutter highlights restored, toolbar buttons for SplittableEditor - Shell quote bypass fix in terminal permission system (zed-industries#48436) - Project panel: Collapse All improvements (zed-industries#47328, zed-industries#48443) - Edit prediction: trailing newlines fix, cursor position in global coords - Properly discard tokens on language server stop (zed-industries#48490) - AgentTool::NAME const instead of hardcoded strings (zed-industries#48506) Conflict resolution: - collab/editor_tests.rs: deleted (collab removed) - vim (helix, motion, increment): deleted (vim removed) - GPUI (17 files): deleted from Glass (handled in Obsydian-HQ/gpui) - editor/items.rs: merged imports (added BufferId, kept Theme) - project_diff.rs: removed old native_button toggle (upstream uses toolbar buttons now) - lsp_store.rs: added SemanticTokenConfig, removed GlobalLogStore/LanguageServerKind - project_panel.rs: merged UI imports (added ContextMenuEntry, ScrollAxes) - Keymaps: took upstream JetBrains bindings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes the
fn name()default method from theAgentTooltrait (which just returnedSelf::NAME) and replaces all call sites with direct use of theNAMEassociated constant. This lets us use it as a single source of truth in macros that want to access it at compile time.This PR also replaces hardcoded tool name string literals throughout the codebase with the corresponding
NAMEconstants, so tool name references stay in sync if a tool is renamed.Intentionally not changed:
"Thinking"and"Subagent"(user-facing UI labels)#[serde(rename = "thinking")](wire format)assert_eq!(SubagentTool::NAME, "subagent")(replacing the literal would make it tautological)"mcp:srv:terminal"(not tool identifiers)Release Notes: