Skip to content

Using Gemini - Still getting error when setting strict_json to false #881

@adiberk

Description

@adiberk

Please read this first

I believe I read everything

Describe the bug

I want to use gemini for something and unfortunately gemini has a whole issue with enabling strict json and tool calling at same time.
So to fix this I am trying to either set output type to None or set it to str. In either case I still get this

return AgentOutputSchema(agent.output_type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/virtualenv/.venv/lib/python3.11/site-packages/agents/agent_output.py", line 116, in __init__
raise UserError(a
    gents.exceptions.UserError: Strict JSON schema is enabled, but the output type is not valid. Either make the output type strict, or pass output_schema_strict=False to your Agent()

Even when I try using the AgentOutputSchema. and set stric_json to false I still ge tthis error. I am a bit frustrated that I can't figure this out.

Just a note: I figure I wanted to try and get passed the gemini issue by adding a guardrail whenever I am using a gemini model with a BaseModel output AND with tool calls. IN that case the guardrail will handle the transformation and validation. Which I think will give me what I want. But before I can test that, I need to get passed this error

Debug information

  • Agents SDK version: (e.g. v0.0.17)
  • Python version (e.g. Python 3.11)

Repro steps

Use gemini model with a "required" tool use. Set output type to something (str, None) and get this error. Obviously if you set it to base model - it definitely won't work.

Expected behavior

I should be able to get passed this error

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