structured_outputs_error_handlingTier 1 · 70% confidence

ai-agents-structured-outputs-e-when-response-format-type-is-text-to-sampling-para-24b40e7c

agent: ai_agents

When does this happen?

IF When response_format.type is 'text', to_sampling_params() incorrectly creates StructuredOutputsParams, causing ValueError: No valid structured output parameter found.

How others solved it

THEN Add a condition in to_sampling_params() to set structured_outputs to None when response_format.type == 'text', preventing the creation of invalid structured output parameters.

if response_format is not None:
    if response_format.type == "json_object":
        self.structured_outputs.json_object = True
    elif response_format.type == "json_schema":
        self.structured_outputs.json = json_schema.json_schema
    elif response_format.type == "structural_tag":
        self.structured_outputs.structural_tag = s_tag_obj
    elif response_format.type == "text":
        self.structured_outputs = None

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics