Python: build_model_schema puts pydantic constraint objects into field descriptions (breaks tool payload JSON)
Author: ManoharPaturiCreated Sep 13, 2026Updated Sep 13, 2026
Labelspythontriage
Description
KernelJsonSchemaBuilder.build_model_schema() puts FieldInfo.metadata[0] into the field's description when a pydantic v2 field has constraints. In pydantic v2, metadata[0] is a constraint object (Ge(ge=0.0)), not a description, so:
- the real
Field(..., description=...)is lost from the tool schema - the resulting schema dict contains a
Geobject and fails JSON serialization withTypeError: Object of type Ge is not JSON serializable, breaking function-calling payloads for OpenAI-compatible connectors
Regression introduced by #6469.
Reproduction
from pydantic import BaseModel, Field
import json
from semantic_kernel.schema.kernel_json_schema_builder import KernelJsonSchemaBuilder
class Params(BaseModel):
top_p: float = Field(default=0.9, ge=0.0, le=1.0, description="nucleus sampling")
json.dumps(KernelJsonSchemaBuilder.build_model_schema(Params)["properties"]["top_p"])
# TypeError: Object of type Ge is not JSON serializableExpected behavior
Constraint-only metadata is ignored for descriptions; field_info.description is used when present, so the schema stays JSON-serializable.
Environment
semantic-kernel python main (ca40aa72), pydantic v2, Python 3.12
Source: microsoft/semantic-kernel