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
Ge object and fails JSON serialization with TypeError: 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 serializable
Expected 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
Description
KernelJsonSchemaBuilder.build_model_schema()putsFieldInfo.metadata[0]into the field'sdescriptionwhen a pydantic v2 field has constraints. In pydantic v2,metadata[0]is a constraint object (Ge(ge=0.0)), not a description, so:Field(..., description=...)is lost from the tool schemaGeobject and fails JSON serialization withTypeError: Object of type Ge is not JSON serializable, breaking function-calling payloads for OpenAI-compatible connectorsRegression introduced by #6469.
Reproduction
Expected behavior
Constraint-only metadata is ignored for descriptions;
field_info.descriptionis used when present, so the schema stays JSON-serializable.Environment
semantic-kernel python main (
ca40aa72), pydantic v2, Python 3.12