microsoft/autogen · error · ValueError

structured output is not currently supported in SKChatComple

Error message

structured output is not currently supported in SKChatCompletionAdapter

What it means

Thrown by SKChatCompletionAdapter.create when json_output is a Pydantic BaseModel subclass (autogen's structured-output mode). The adapter only supports the boolean json_output flag; it has no plumbing to hand a response schema to Semantic Kernel, so structured output is explicitly rejected rather than silently ignored.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/models/semantic_kernel/_sk_chat_completion_adapter.py:475

        2) `"prompt_execution_settings"` (optional):
            An instance of a :class:`PromptExecutionSettings` subclass corresponding to the
            underlying Semantic Kernel client (e.g., `AzureChatPromptExecutionSettings`,
            `GoogleAIChatPromptExecutionSettings`). If not provided, the adapter's default
            prompt settings will be used.

        Args:
            messages: The list of LLM messages to send.
            tools: The tools that may be invoked during the chat.
            json_output: Whether the model is expected to return JSON.
            extra_create_args: Additional arguments to control the chat completion behavior.
            cancellation_token: Token allowing cancellation of the request.

        Returns:
            CreateResult: The result of the chat completion.
        """
        if isinstance(json_output, type) and issubclass(json_output, BaseModel):
            raise ValueError("structured output is not currently supported in SKChatCompletionAdapter")

        # Handle tool_choice parameter
        if tool_choice != "auto":
            warnings.warn(
                "tool_choice parameter is specified but may not be fully supported by SKChatCompletionAdapter.",
                stacklevel=2,
            )

        kernel = self._get_kernel(extra_create_args)

        chat_history = self._convert_to_chat_history(messages)
        user_settings = self._get_prompt_settings(extra_create_args)
        settings = self._build_execution_settings(user_settings, tools)

        # Sync tools with kernel
        self._sync_tools_with_kernel(kernel, tools)

        result = await self._sk_client.get_chat_message_contents(chat_history, settings=settings, kernel=kernel)

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Pass json_output=True instead of a Pydantic type, then parse/validate the JSON yourself with MyModel.model_validate_json(text)
  2. Switch to OpenAIChatCompletionClient if native structured output is required
  3. Instruct the schema in the prompt and validate the reply with Pydantic as a post-step

Example fix

# before
result = await adapter.create([msg], json_output=MyModel)  # ValueError

# after
result = await adapter.create([msg], json_output=True)
instance = MyModel.model_validate_json(result.content)
Defensive patterns

Strategy: validation

Validate before calling

import inspect

if json_output is not None and inspect.isclass(json_output):
    # SK adapter cannot take a Pydantic type; degrade to json mode + manual validation
    use_structured = False
    json_mode = True
else:
    json_mode = bool(json_output)

Type guard

def sk_supports_json_output(json_output) -> bool:
    """SKChatCompletionAdapter accepts only bool json_output, never a type."""
    return not (isinstance(json_output, type))

Try / catch

try:
    result = await adapter.create(messages, json_output=MyModel)
except ValueError as e:
    if "structured output" in str(e):
        result = await adapter.create(messages, json_output=True)
        instance = MyModel.model_validate_json(result.content)
    else:
        raise

Prevention

When it happens

Trigger: Calling adapter.create([msg], json_output=MyPydanticModel) — i.e. passing a type where issubclass(json_output, BaseModel) is true. Boolean json_output=True/False is fine; only typed structured output raises.

Common situations: Porting code from OpenAIChatCompletionClient (which supports typed json_output) to the SK adapter; agent frameworks automatically passing a response model for structured tasks; assuming feature parity between the OpenAI and SK clients.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/946efd1cd8c003b7. Report an issue: GitHub.