{"record":{"id":"e91b422a810e1f4b","repo":"microsoft/semantic-kernel","slug":"model-id-required-when-creating-a-new-openai-respo","errorCode":null,"errorMessage":"model.id required when creating a new OpenAI Responses Agent.","messagePattern":"model\\.id required when creating a new OpenAI Responses Agent\\.","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/open_ai/openai_responses_agent.py","lineNumber":560,"sourceCode":"            raise AgentInitializationException(\"Missing required 'client' in OpenAIResponsesAgent._from_dict()\")\n\n        spec = AgentSpec.model_validate(data)\n\n        if \"settings\" in kwargs:\n            kwargs.pop(\"settings\")\n\n        args = data.pop(\"arguments\", None)\n        arguments = None\n        if args:\n            arguments = KernelArguments(**args)\n\n        # Handle arguments from kwargs, merging with any arguments from data\n        if \"arguments\" in kwargs and kwargs[\"arguments\"] is not None:\n            incoming_args = kwargs[\"arguments\"]\n            arguments = arguments | incoming_args if arguments is not None else incoming_args\n\n        if not (spec.model and spec.model.id):\n            raise AgentInitializationException(\"model.id required when creating a new OpenAI Responses Agent.\")\n\n        # Build tool definitions & resources\n        tool_objs = [_build_tool(t, kernel) for t in spec.tools if t.type != \"function\"]\n\n        return cls(\n            name=spec.name,\n            description=spec.description,\n            instruction_role=spec.instructions,\n            ai_model_id=spec.model.id,\n            client=client,\n            arguments=arguments,\n            kernel=kernel,\n            prompt_template_config=prompt_template_config,\n            tools=tool_objs,\n            **kwargs,\n        )\n\n    @classmethod","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/open_ai/openai_responses_agent.py#L542-L578","documentation":"Raised by _from_dict() when the validated AgentSpec has no model or no model.id. A declarative Responses Agent spec must name the model it will use, since there is no env-var fallback in this deserialization path. The check is `if not (spec.model and spec.model.id)`.","triggerScenarios":"Loading a YAML/JSON declarative spec whose top-level model field is missing, null, or whose model object lacks an id. The AgentSpec.model_validate(data) succeeds but the model sub-object is empty.","commonSituations":"Hand-writing a spec file and omitting the model section, a templating step that failed to fill model.id, or an older spec schema that placed the model id elsewhere. Distinct from the env-var path: from_dict() does not fall back to OPENAI_RESPONSES_MODEL_ID.","solutions":["Add a model.id to the spec, e.g. model: { id: 'gpt-4o' }.","Validate the spec dict before calling from_dict(): assert data.get('model', {}).get('id').","If the model is dynamic, inject it into the data dict before deserialization: data.setdefault('model', {})['id'] = 'gpt-4o'.","Check your spec-generation/template step is populating model.id."],"exampleFix":"// before\nspec = {\"name\": \"my-agent\", \"instructions\": \"...\"}\nagent = OpenAIResponsesAgent.from_dict(spec, kernel=kernel, client=client)\n\n// after\nspec = {\"name\": \"my-agent\", \"instructions\": \"...\", \"model\": {\"id\": \"gpt-4o\"}}\nagent = OpenAIResponsesAgent.from_dict(spec, kernel=kernel, client=client)","handlingStrategy":"validation","validationCode":"model_id = (data.get('model') or {}).get('id')\nif not model_id:\n    data.setdefault('model', {})['id'] = 'gpt-4o'\nagent = OpenAIResponsesAgent.from_dict(data, kernel=kernel, client=client)","typeGuard":"def spec_has_model_id(data: dict) -> bool:\n    return bool((data.get('model') or {}).get('id'))","tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentInitializationException\ntry:\n    agent = OpenAIResponsesAgent.from_dict(data, kernel=kernel, client=client)\nexcept AgentInitializationException as e:\n    if 'model.id' in str(e):\n        data.setdefault('model', {})['id'] = 'gpt-4o'\n        agent = OpenAIResponsesAgent.from_dict(data, kernel=kernel, client=client)\n    raise","preventionTips":["Always include a model.id in declarative spec files.","Validate the spec dict for model.id before calling from_dict().","Have your spec template/generator fail loudly when model.id is missing."],"tags":["declarative-spec","model-id","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}