Skip to content

Explicit uppercase for tool calls breaks with local LLMs, that expect lowercase values #158

Description

@chasseuragace

Environment

  • SDK version: 0.1.9
  • Python version: 3.10.20
  • OS / platform: macOS ARM64 (darwin)
  • Install method: pip install google-antigravity

Description

FunctionDeclaration.from_callable_with_api_option(...) emits JSON Schema with uppercase enum values for type fields ("OBJECT", "STRING", etc.). OpenAI-compatible endpoints require lowercase ("object", "string"). This breaks all custom Python tools when using LocalOpenAIAgentConfig with an OpenAI-compatible local server (Ollama, LM Studio, etc.).

Steps to Reproduce

  1. Install google-antigravity via pip.
  2. Run a local OpenAI-compatible server, e.g. LM Studio at http://127.0.0.1:1234.
  3. Create a simple custom tool:
    def get_temperature(location: str) -> str:
        return f"The temperature in {location} is 72°F."
  4. Configure the agent:
    config = LocalOpenAIAgentConfig(
        model="google/gemma-4-e2b",
        base_url="http://127.0.0.1:1234",
        tools=[get_temperature],
    )
  5. Send a prompt that triggers the tool: "What's the temperature in Mountain View?"

Expected Behavior

The agent calls get_temperature with {"location": "Mountain View"} and returns the result.

Actual Behavior

The local LLM server returns HTTP 400:

{
  "error": [
    {
      "code": "invalid_union_discriminator",
      "options": ["object"],
      "path": [2, "function", "parameters", "type"],
      "message": "Invalid discriminator value. Expected 'object'"
    }
  ]
}

The SDK then surfaces: model output error: model output must contain either output text or tool calls, these cannot both be empty, please try again

Additional Context

  • The broken schema originates in google/antigravity/connections/local/local_connection.py:199-213 (callable_to_tool_proto).
  • decl.parameters.model_dump(exclude_none=True) preserves genai_types.Type enum values as uppercase strings.
  • Workaround: wrap tools in ToolWithSchema with an explicit lowercase JSON Schema.
  • Local patch applied in source tree: recursive _normalize_schema_types() converts genai_types.Type values to lowercase before json.dumps().

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions