Skip to content

[BUG] GeminiModel doesn't support the structured_output implementation #1121

@dpolistwm

Description

@dpolistwm

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.14.0

Python Version

3.12.3

Operating System

Ubuntu 24.04.2 LTS

Installation Method

pip

Steps to Reproduce

class IntencaoDoUsuarioSchema(BaseModel):
    intencaoDoUsuario: str
    output: str
    buscaBemSucedida: bool | None

gemini_model = GeminiModel(
            model_id=os.getenv("GEMINI_MODEL_ID"),
            params = {
                "max_output_tokens": 40000
            }
        )

agent = Agent(
                name="strands-ai-trek",
                model=gemini_model, 
                prompt="<<PROMPT HERE>>")

agent.structured_output(IntencaoDoUsuarioSchema, "Do you have my data?")

Expected Behavior

The response using the provided Pydantic schema

Actual Behavior

Error: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': "The GenerateContentRequest proto is invalid:\n * tools[0].tool_type: required one_of 'tool_type' must have one initialized field", 'status': 'INVALID_ARGUMENT'}}

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    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