antigravity-sdk-python icon indicating copy to clipboard operation
antigravity-sdk-python copied to clipboard

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

Open chasseuragace opened this issue 3 months ago • 4 comments

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().

chasseuragace avatar Aug 05 '26 02:08 chasseuragace

Hi I would like to work on this bug , can you assign it to me @chasseuragace

RounakKumarAgarwal avatar Aug 14 '26 11:08 RounakKumarAgarwal

Hi @RounakKumarAgarwal unfortunately we don't take PRs to this repo but super appreciate the energy!

NTaylorMullen avatar Aug 15 '26 05:08 NTaylorMullen

Please let me know how can I contribute engage here? @NTaylorMullen.

RounakKumarAgarwal avatar Aug 15 '26 07:08 RounakKumarAgarwal

Fixed in latest

NTaylorMullen avatar Sep 02 '26 16:09 NTaylorMullen