continuedev/continue · warning

Failed to convert tool to gemini function definition. Skippi

Error message

Failed to convert tool to gemini function definition. Skipping: ${JSON.stringify(tool, null, 2)}

What it means

In _convertBody, each OpenAI tool definition is converted to a Gemini function declaration via convertOpenAIToolToGeminiFunction. If a tool's schema cannot be converted (throws), the individual tool is skipped with this warning — including a JSON dump of the tool — and the remaining tools still get sent.

Source

Thrown at packages/openai-adapters/src/apis/Gemini.ts:264

      // if there is a system message, reformat it for Gemini API
      ...(sysMsg &&
        !isV1API && {
          systemInstruction: { parts: [{ text: sysMsg.content }] },
        }),
    };

    if (!isV1API) {
      // Convert and add tools if present
      if (oaiBody.tools?.length) {
        // Choosing to map all tools to the functionDeclarations of one tool
        // Rather than map each tool to its own tool + functionDeclaration
        // Same difference
        const functions: GeminiToolFunctionDeclaration[] = [];
        oaiBody.tools.forEach((tool) => {
          try {
            functions.push(convertOpenAIToolToGeminiFunction(tool));
          } catch (e) {
            console.warn(
              `Failed to convert tool to gemini function definition. Skipping: ${JSON.stringify(tool, null, 2)}`,
            );
          }
        });

        if (functions.length) {
          finalBody.tools = [
            {
              functionDeclarations: functions,
            },
          ];
        }
      }
    }

    return finalBody;
  }

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Inspect the logged JSON dump to identify which tool failed
  2. Simplify the parameters JSON Schema to Gemini's supported subset (type: object, properties, required, enum; avoid $ref/allOf/oneOf at top level)
  3. Ensure each tool has a valid name and a parameters object of JSON Schema type "object"
  4. Test each tool with convertOpenAIToolToGeminiFunction in isolation before batching

Example fix

// before
{ type: "function", function: { name: "f", parameters: { anyOf: [{type:"string"},{type:"number"}] } } }

// after
{ type: "function", function: { name: "f", parameters: { type: "object", properties: { v: { type: "string" } } } } }
Defensive patterns

Strategy: validation

Validate before calling

const t = tool.function;
if (!t?.name || t.parameters?.type !== "object") {
  throw new Error(`Tool ${t?.name} has an unsupported schema for Gemini`);
}

Type guard

const isGeminiSafeTool = (t: any): boolean =>
  t?.type === "function" &&
  typeof t.function?.name === "string" &&
  (t.function.parameters === undefined || t.function.parameters?.type === "object");

Prevention

When it happens

Trigger: Passing tools with JSON Schemas Gemini rejects: unsupported JSON Schema keywords/complex types, a function with no valid parameters schema, or a malformed tool object missing name/parameters.

Common situations: Forwarding OpenAI-format tool definitions (draft-07 style with $ref/oneOf/allOf or nested required) to Gemini; generating tools from Zod/TypeBox without sanitizing to Gemini's strict subset.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/f2ee2b2b47f5c9ac. Report an issue: GitHub.