{"record":{"id":"20d9b0e5b38690d3","repo":"microsoft/semantic-kernel","slug":"encountered-unexpected-response-format-type-resp-20d9b0","errorCode":null,"errorMessage":"Encountered unexpected response_format type: {resp_type}. Allowed types are `json_object`  and `json_schema`.","messagePattern":"Encountered unexpected response_format type: (.+?)\\. Allowed types are `json_object`  and `json_schema`\\.","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/openai_responses_agent.py","lineNumber":782,"sourceCode":"        if response_format is None or response_format == \"auto\":\n            return None\n\n        # TODO(evmattso): improve typing in this method\n        if isinstance(response_format, dict):\n            resp_type = response_format.get(\"type\", None)\n\n            if resp_type == \"json_object\":\n                return {\"type\": \"json_object\"}\n            if resp_type == \"json_schema\":\n                json_schema = response_format.get(\"json_schema\")  # type: ignore\n                if not isinstance(json_schema, dict):\n                    raise AgentInitializationException(\n                        \"If response_format has type 'json_schema', 'json_schema' must be a valid dictionary.\"\n                    )\n                # We're assuming the response_format has already been provided in the correct format\n                return response_format  # type: ignore\n\n            raise AgentInitializationException(\n                f\"Encountered unexpected response_format type: {resp_type}. Allowed types are `json_object` \"\n                \" and `json_schema`.\"\n            )\n        if isinstance(response_format, type):\n            if issubclass(response_format, BaseModel):\n                interim_format = type_to_text_format_param(response_format)\n                if interim_format[\"type\"] != \"json_schema\":\n                    raise AgentInitializationException(\"Only 'json_schema' is allowed from that helper.\")\n                configured_format = {\n                    \"type\": \"json_schema\",\n                    \"name\": interim_format.get(\"name\", response_format.__name__),\n                    \"schema\": interim_format.get(\"schema\"),\n                    \"strict\": interim_format.get(\"strict\", True),\n                }\n            else:\n                # Build a schema from a plain Python class\n                generated_schema = KernelJsonSchemaBuilder.build(parameter_type=response_format, structured_output=True)\n                if generated_schema is None:","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/openai_responses_agent.py#L764-L800","documentation":"Raised by configure_response_format() when response_format is a dict whose 'type' value is neither 'json_object' nor 'json_schema'. The Responses Agent only supports those two structured formats via the dict path; any other type string (e.g. 'text', 'auto', 'json') is rejected.","triggerScenarios":"Passing response_format={'type': 'text'}, {'type': 'json'}, or any dict whose type field is an unrecognized string. The resp_type variable holds whatever was under the 'type' key.","commonSituations":"Porting a Chat Completions response_format that used 'text' or 'json_object' variants not supported by the Responses API, or setting type to a value from a different SDK version. The message echoes the offending resp_type.","solutions":["Use {'type': 'json_object'} or {'type': 'json_schema', ...} for structured output.","For plain text, pass None or 'auto' (handled at the top of the method) rather than {'type': 'text'}.","If you need a text format config, use the ResponseTextConfigParam path instead of a dict."],"exampleFix":"// before\ncfg = OpenAIResponsesAgent.configure_response_format({\"type\": \"text\"})\n\n// after\ncfg = OpenAIResponsesAgent.configure_response_format({\"type\": \"json_object\"})","handlingStrategy":"validation","validationCode":"allowed = {'json_object', 'json_schema'}\nif isinstance(response_format, dict):\n    assert response_format.get('type') in allowed or response_format.get('type') is None, 'unsupported type'","typeGuard":"def is_supported_dict_type(fmt: dict) -> bool:\n    return fmt.get('type') in ('json_object', 'json_schema')","tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentInitializationException\ntry:\n    cfg = OpenAIResponsesAgent.configure_response_format(fmt)\nexcept AgentInitializationException as e:\n    if 'unexpected response_format type' in str(e):\n        fmt['type'] = 'json_object'\n        cfg = OpenAIResponsesAgent.configure_response_format(fmt)\n    raise","preventionTips":["Use only 'json_object' or 'json_schema' as the dict type.","For plain text, pass None or 'auto' instead of {'type': 'text'}.","Validate the type field against the allowed set before calling."],"tags":["response-format","validation","json-schema"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}