{"record":{"id":"37aa38e1947814c6","repo":"vllm-project/vllm","slug":"duplicate-tool-name-name","errorCode":null,"errorMessage":"duplicate tool name `{name}`","messagePattern":"duplicate tool name `(.+?)`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"rust/src/chat/src/error.rs","lineNumber":74,"sourceCode":"    HarmonyParserOverrideUnsupported {\n        kind: &'static str,\n        selection: String,\n    },\n    #[error(\"harmony output parsing failed\")]\n    HarmonyOutputParsing {\n        #[source]\n        error: BoxedError,\n    },\n    #[error(\n        \"this model's maximum context length is {max_model_len} tokens, \\\n         but the prompt contains {prompt_len} input tokens\"\n    )]\n    PromptTooLong { max_model_len: u32, prompt_len: u32 },\n    #[error(\"chat request stream `{request_id}` closed before terminal output\")]\n    StreamClosedBeforeTerminalOutput { request_id: String },\n    #[error(\"tool call stream state is inconsistent: {message}\")]\n    ToolCallStreamInvariant { message: String },\n    #[error(\"duplicate tool name `{name}`\")]\n    DuplicateToolName { name: String },\n    #[error(\"tool_choice requires at least one available tool\")]\n    ToolChoiceRequiresTools,\n    #[error(\"tool_choice function `{name}` was not found in the available tools\")]\n    ToolChoiceFunctionNotFound { name: String },\n    #[error(\"failed to build structural tag: {message}\")]\n    StructuralTag { message: String },\n    #[error(transparent)]\n    Text(#[from] vllm_text::Error),\n    #[error(transparent)]\n    Tokenizer(#[from] vllm_tokenizer::TokenizerError),\n}\n\npub type Result<T> = std::result::Result<T, Error>;\n\nimpl Error {\n    /// Whether this error represents invalid user request parameters.\n    pub fn is_request_validation_error(&self) -> bool {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/chat/src/error.rs#L56-L92","documentation":"Request validation error raised at `request.rs:497` when the `tools` array contains two tool definitions with the same function name. Tool names are the dispatch key for `tool_choice` and for matching `tool_call_id`s, so duplicates are rejected up front. Classified as a user request error (`error.rs:95`).","triggerScenarios":"POSTing a chat completion with `tools: [{function:{name:\"search\"}}, {function:{name:\"search\"}}]`; common when programmatically merging tool lists from multiple modules without dedup.","commonSituations":"Combining tool registries from several plugins that each define `get_time` or `search`; renaming one tool but forgetting call sites that construct the list; copy-pasted tool JSON.","solutions":["Dedupe the tools array by function name before sending (keep last or error in client code).","Namespace tool names per module (`fs_read_file` vs `db_read_file`) when merging registries.","Add a unit test / lint that asserts uniqueness of tool names in your tool-registry builder."],"exampleFix":"// before\nlet tools = [fs_tools(), db_tools()]; // both contain \"read\"\n\n// after\nlet tools = dedup_by_name([fs_tools(), db_tools()])?;","handlingStrategy":"validation","validationCode":"let mut seen = HashSet::new();\nfor tool in &tools {\n    if !seen.insert(tool.function.name.as_str()) {\n        return Err(format!(\"duplicate tool name: {}\", tool.function.name));\n    }\n}","typeGuard":"fn has_unique_tool_names(tools: &[Tool]) -> bool {\n    let mut seen = std::collections::HashSet::new();\n    tools.iter().all(|t| seen.insert(t.function.name.as_str()))\n}","tryCatchPattern":"match result {\n    Err(vllm_chat::Error::DuplicateToolName { name }) => {\n        respond_bad_request(format!(\"duplicate tool name `{name}`\"))\n    }\n    other => other?,\n}","preventionTips":["Dedupe-by-name in the tool registry builder, not at request time.","Namespace tool names per plugin/module to avoid collisions by construction.","Assert uniqueness in unit tests over the static tool list."],"tags":["rust","tools","validation","chat","duplicate"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}