microsoft/autogen · error · UnsupportedKeywordError
Unsupported or missing type for field `{key}` in `{model_nam
Error message
Unsupported or missing type for field `{key}` in `{model_name}` What it means
Thrown by PydanticModelBuilder (json_schema_to_pydantic) when a JSON Schema property's type cannot be mapped to any Python/Pydantic type. _json_schema_to_model first tries $ref/anyOf/oneOf/enum/allOf/object-with-properties, then falls back to _extract_field_type; if that also returns None (e.g. the property has no 'type' key and no other recognized keyword, or a type not in TYPE_MAPPING such as 'null' as the sole type), UnsupportedKeywordError is raised. It means the schema you supplied (typically from a structured-output tool or an OpenAPI/tool definition) uses a construct this converter does not support.
Source
Thrown at python/packages/autogen-core/src/autogen_core/utils/_json_to_pydantic.py:347
field_type = Literal[tuple(value["enum"])]
elif "allOf" in value:
merged = {"type": "object", "properties": {}, "required": []}
for s in value["allOf"]:
part = self._resolve_ref(s["$ref"], root_schema) if "$ref" in s else s
merged["properties"].update(part.get("properties", {}))
merged["required"].extend(part.get("required", []))
for k, v in value.items():
if k not in {"allOf", "properties", "required"}:
merged[k] = v
merged["required"] = list(set(merged["required"]))
field_type = self._json_schema_to_model(merged, f"{model_name}_{key}", root_schema)
elif value.get("type") == "object" and "properties" in value:
field_type = self._json_schema_to_model(value, f"{model_name}_{key}", root_schema)
else:
field_type = self._extract_field_type(key, value, model_name, root_schema)
if field_type is None:
raise UnsupportedKeywordError(f"Unsupported or missing type for field `{key}` in `{model_name}`")
default_value = value.get("default")
is_required = key in required_fields
if not is_required and default_value is None:
field_type = Optional[field_type]
field_args = {
"default": default_value if not is_required else ...,
}
if "title" in value:
field_args["title"] = value["title"]
if "description" in value:
field_args["description"] = value["description"]
fields[key] = (
field_type,
_make_field(View on GitHub (pinned to 027ecf0a37)
Solutions
- Find the offending field: the message names the field `key` and model `model_name`; inspect that property in your schema.
- Add an explicit, supported "type" (string, integer, number, boolean, array, object) to the property, or replace the construct with anyOf/oneOf/$ref/enum which the converter handles.
- Replace a bare "type": "null" with an anyOf including null / a nullable sibling, or just make the field optional.
- If the schema comes from a tool definition, regenerate it (e.g. from a typed function via FunctionTool) instead of authoring it by hand.
- As a last resort, use a plain Pydantic model you define yourself instead of converting the schema.
Example fix
// before
{"type":"object","properties":{"meta":{"description":"opaque blob"}}}
// after
{"type":"object","properties":{"meta":{"type":"string","description":"opaque blob"}}} Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"string","integer","number","boolean","array","object"}
def schema_fields_supported(schema):
for key, prop in schema.get("properties", {}).items():
has_structural = any(k in prop for k in ("$ref","anyOf","oneOf","enum","allOf"))
if not has_structural and prop.get("type") not in SUPPORTED:
return False, key
return True, None Type guard
def is_supported_property(prop: dict) -> bool:
return any(k in prop for k in ("$ref","anyOf","oneOf","enum","allOf")) or prop.get("type") in {"string","integer","number","boolean","array","object"} Try / catch
try:
model = json_schema_to_pydantic(schema)
except UnsupportedKeywordError as e:
# message names field and model; fix schema or fall back to a hand-written model
... Prevention
- Generate schemas from typed functions (FunctionTool) rather than authoring JSON Schema by hand.
- Run a schema lint pass (every property has a known 'type' or $ref/anyOf/enum) before conversion.
- Avoid OpenAPI 3.1 'null' standalone types and JSON Schema 2020-12-only keywords.
When it happens
Trigger: Calling json_schema_to_pydantic (directly or via a tool/agent that generates Pydantic models from JSON Schema) with a schema whose property declares: no 'type' at all (e.g. only 'description'), an unsupported primitive type like "type": "null", a type string not in TYPE_MAPPING, or an object without 'properties' that also has no matching branch in _extract_field_type.
Common situations: Hand-written or LLM-generated JSON Schemas that omit 'type'; OpenAPI 3.1 schemas using 'null' as a standalone type; schemas using advanced JSON Schema 2020-12 keywords this converter ignores; feeding an arbitrary third-party API schema into a structured-output pipeline.
Related errors
- Either `json_schema` or `input_model` must be provided.
- Handoff name must be a string: {values['name']}
- Invalid agent type: {type}. Allowed values MUST match the re
- Invalid agent id: {agent_id}
- Agent description must be a string
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/867f64f7c8ef7c6c.
Report an issue: GitHub.