{"record":{"id":"00d309c6eea47733","repo":"can1357/oh-my-pi","slug":"unknown-tool-unknown-length-1-s-in","errorCode":null,"errorMessage":"Unknown tool${unknown.length === 1 ? \"\" : \"s\"} in --tools: ${unknown.join(\", \")}. Valid tools: ${known.join(\", \")}.","messagePattern":"Unknown tool(.+?) in --tools: (.+?)\\. Valid tools: (.+?)\\.","errorType":"validation","errorClass":"CliUsageError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/args.ts","lineNumber":341,"sourceCode":"\tfor (const trustedPath of result.trustedExtensions ?? []) {\n\t\tif (trustedPath.length === 0) {\n\t\t\tthrow new CliUsageError(\"--trusted-extension requires a non-empty, non-flag value\");\n\t\t}\n\t\tif (!path.isAbsolute(trustedPath)) {\n\t\t\tthrow new CliUsageError(`--trusted-extension requires an absolute path: ${trustedPath}`);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/** Reject requested tool names absent from the fully discovered session registry. */\nexport function validateToolNames(requested: readonly string[] | undefined, known: readonly string[]): void {\n\tif (!requested) return;\n\tconst knownNames = new Set(known);\n\tconst unknown = requested.filter(name => !knownNames.has(name));\n\tif (unknown.length === 0) return;\n\tthrow new CliUsageError(\n\t\t`Unknown tool${unknown.length === 1 ? \"\" : \"s\"} in --tools: ${unknown.join(\", \")}. Valid tools: ${known.join(\", \")}.`,\n\t);\n}\n\n/**\n * Emit a stderr error listing the unrecognized flags and return `true` when\n * there were any. Caller is expected to exit with a non-zero status. Splitting\n * the print from the exit keeps the helper unit-testable without forking a\n * process (issue #2459).\n */\nexport function reportUnrecognizedFlags(\n\targs: Pick<Args, \"unrecognizedFlags\">,\n\twrite: (text: string) => void = text => process.stderr.write(text),\n): boolean {\n\tif (args.unrecognizedFlags.length === 0) return false;\n\tconst flags = args.unrecognizedFlags;\n\tconst plural = flags.length === 1 ? \"\" : \"s\";\n\twrite(`${chalk.red(`Error: unknown flag${plural}: ${flags.join(\", \")}`)}\\n`);","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/args.ts#L323-L359","documentation":"validateToolNames filters the requested --tools names against the fully discovered session tool registry and throws a CliUsageError listing the unrecognized names plus all valid tool names, when any requested tool does not exist.","triggerScenarios":"Passing `--tools` with one or more names absent from the registry: typos (read vs read_file), renamed tools after an upgrade, or tools only present via extensions/MCP that are not loaded in this session.","commonSituations":"Upgrading omp where a tool was renamed; writing scripts against another machine's tool set; referencing MCP-provided tools before the MCP server is configured.","solutions":["Fix the tool names listed as unknown, using the 'Valid tools:' list in the message.","Run with --tools omitted (or list tools via the CLI) to see the current registry.","If the tool comes from an extension/MCP server, ensure that server is enabled in this session.","Pin the omp version in scripts so tool names match the documented set."],"exampleFix":"// before\nomp --tools read,edit,bash_it\n// after\nomp --tools read,edit,bash","handlingStrategy":"validation","validationCode":"// discover the registry first, then filter before invoking\nconst known = await discoverToolNames(); // e.g. from session registry\nconst requested = [\"read\", \"edit\", \"bash_it\"];\nconst bad = requested.filter(n => !known.includes(n));\nif (bad.length) throw new Error(`Remove unknown tools: ${bad.join(\", \")}`);","typeGuard":"null","tryCatchPattern":"try {\n  await runRootCommand(argv);\n} catch (err) {\n  if (err instanceof CliUsageError && err.message.startsWith(\"Unknown tool\")) {\n    console.error(err.message); // lists valid tools\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Copy tool names from the 'Valid tools:' output rather than from memory or old docs.","Pin the omp version in scripts so renames don't break them.","Enable the extension/MCP server that provides non-builtin tools before restricting --tools."],"tags":["cli","validation","tools","naming"],"backgroundTag":"unknown-identifier","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}