{"record":{"id":"946efd1cd8c003b7","repo":"microsoft/autogen","slug":"structured-output-is-not-currently-supported-in-sk","errorCode":null,"errorMessage":"structured output is not currently supported in SKChatCompletionAdapter","messagePattern":"structured output is not currently supported in SKChatCompletionAdapter","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/semantic_kernel/_sk_chat_completion_adapter.py","lineNumber":475,"sourceCode":"\n        2) `\"prompt_execution_settings\"` (optional):\n            An instance of a :class:`PromptExecutionSettings` subclass corresponding to the\n            underlying Semantic Kernel client (e.g., `AzureChatPromptExecutionSettings`,\n            `GoogleAIChatPromptExecutionSettings`). If not provided, the adapter's default\n            prompt settings will be used.\n\n        Args:\n            messages: The list of LLM messages to send.\n            tools: The tools that may be invoked during the chat.\n            json_output: Whether the model is expected to return JSON.\n            extra_create_args: Additional arguments to control the chat completion behavior.\n            cancellation_token: Token allowing cancellation of the request.\n\n        Returns:\n            CreateResult: The result of the chat completion.\n        \"\"\"\n        if isinstance(json_output, type) and issubclass(json_output, BaseModel):\n            raise ValueError(\"structured output is not currently supported in SKChatCompletionAdapter\")\n\n        # Handle tool_choice parameter\n        if tool_choice != \"auto\":\n            warnings.warn(\n                \"tool_choice parameter is specified but may not be fully supported by SKChatCompletionAdapter.\",\n                stacklevel=2,\n            )\n\n        kernel = self._get_kernel(extra_create_args)\n\n        chat_history = self._convert_to_chat_history(messages)\n        user_settings = self._get_prompt_settings(extra_create_args)\n        settings = self._build_execution_settings(user_settings, tools)\n\n        # Sync tools with kernel\n        self._sync_tools_with_kernel(kernel, tools)\n\n        result = await self._sk_client.get_chat_message_contents(chat_history, settings=settings, kernel=kernel)","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/semantic_kernel/_sk_chat_completion_adapter.py#L457-L493","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass json_output=True instead of a Pydantic type, then parse/validate the JSON yourself with MyModel.model_validate_json(text)","Switch to OpenAIChatCompletionClient if native structured output is required","Instruct the schema in the prompt and validate the reply with Pydantic as a post-step"],"exampleFix":"# before\nresult = await adapter.create([msg], json_output=MyModel)  # ValueError\n\n# after\nresult = await adapter.create([msg], json_output=True)\ninstance = MyModel.model_validate_json(result.content)","handlingStrategy":"validation","validationCode":"import inspect\n\nif json_output is not None and inspect.isclass(json_output):\n    # SK adapter cannot take a Pydantic type; degrade to json mode + manual validation\n    use_structured = False\n    json_mode = True\nelse:\n    json_mode = bool(json_output)","typeGuard":"def sk_supports_json_output(json_output) -> bool:\n    \"\"\"SKChatCompletionAdapter accepts only bool json_output, never a type.\"\"\"\n    return not (isinstance(json_output, type))","tryCatchPattern":"try:\n    result = await adapter.create(messages, json_output=MyModel)\nexcept ValueError as e:\n    if \"structured output\" in str(e):\n        result = await adapter.create(messages, json_output=True)\n        instance = MyModel.model_validate_json(result.content)\n    else:\n        raise","preventionTips":["Feature-check adapters: only OpenAIChatCompletionClient accepts typed json_output","Keep a parse-and-validate helper next to any SK adapter call site","When porting between model clients, audit uses of typed json_output first"],"tags":["semantic-kernel","structured-output","pydantic","unsupported-feature"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}