Skip to content

Gemini rejects tool schemas with required fields referencing undefined properties #569

Description

@buger

Bug

When ProbeAgent sends tool definitions to Gemini, Gemini returns a 400 error if any tool's required array references a property not defined in properties:

GenerateContentRequest.tools[0].function_declarations[9].parameters.required[0]: property is not defined

This happens because external MCP server tools (e.g. Jira/Atlassian) can emit schemas where required lists properties that aren't in properties. Anthropic and OpenAI accept these silently, but Gemini enforces strict JSON Schema validation.

Error details

{
  "error": {
    "code": 400,
    "message": "* GenerateContentRequest.tools[0].function_declarations[9].parameters.required[0]: property is not defined\n",
    "status": "INVALID_ARGUMENT"
  }
}

This causes AI_NoOutputGeneratedError: No output generated and the entire request fails.

Suggested fix

Before sending tool definitions to Gemini (and ideally for all providers), sanitize each tool's JSON Schema:

// For each tool definition's inputSchema:
if (Array.isArray(schema.required) && schema.properties) {
  const defined = new Set(Object.keys(schema.properties));
  schema.required = schema.required.filter(r => defined.has(r));
}

This is similar to the existing fix for Gemini rejecting array schemas without items — just another Gemini-specific strictness that other providers don't enforce.

Context

ProbeAgent already handles one Gemini schema quirk (arrays without items). This is the same category — a schema normalization step needed because Gemini validates schemas more strictly than other providers. The fix should be applied wherever tool definitions are prepared for the provider API call.

Environment

  • @probelabs/probe: 0.6.0-rc319
  • Provider: Gemini (gemini-3.5-flash)
  • MCP tools source: Jira/Atlassian MCP server (mcp-atlassian)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions