Description
PropertySchema.to_json_schema() renames kind → type (and now strips empty enum arrays) only in its top-level properties loop; it does not recurse into nested schemas. For an array property, the nested items schema keeps "kind" and its empty "enum", producing JSON Schema that OpenAI rejects ("schema must have a 'type' key").
Current implementation on main (_models.py#L240-L259 @ 7c6b1e975f75) — the loop touches each prop but never descends into prop["items"] (or nested object properties).
Suggested fix: make the rename + cleanup recursive over items and nested properties. (The top-level empty-enum strip added since 1.0.0b260528 covers half of the old behavior; the nested case is what remains.)
Code Sample
from agent_framework_declarative._models import PropertySchema
schema = PropertySchema.from_dict({
"properties": {
"issues": {"kind": "array", "items": {"kind": "string"}},
}
})
print(schema.to_json_schema())
Actual output — identical on 1.0.0rc2 (latest) and 1.0.0b260528 (nested items unconverted):
{'examples': [], 'strict': False, 'properties': {'issues': {'items': {'kind': 'string', 'enum': []}, 'type': 'array'}}, 'type': 'object'}
Expected:
{'type': 'object', 'properties': {'issues': {'type': 'array', 'items': {'type': 'string'}}}}
Error Messages / Stack Traces
When the resulting schema is sent to OpenAI as a structured-output response_format:
openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid schema ... 'items' must have a 'type' key", 'type': 'invalid_request_error'}}
Package Versions
agent-framework-declarative==1.0.0rc2 (latest; also reproduced on 1.0.0b260528; non-recursive loop present on main @ 7c6b1e9)
Python Version
3.13
Additional Context
Workaround we use in production: declarative agents whose output schema needs arrays use prompt-instructed JSON instead of outputSchema.
Description
PropertySchema.to_json_schema()renameskind→type(and now strips emptyenumarrays) only in its top-level properties loop; it does not recurse into nested schemas. For an array property, the nesteditemsschema keeps"kind"and its empty"enum", producing JSON Schema that OpenAI rejects ("schema must have a 'type' key").Current implementation on main (
_models.py#L240-L259@7c6b1e975f75) — the loop touches eachpropbut never descends intoprop["items"](or nested objectproperties).Suggested fix: make the rename + cleanup recursive over
itemsand nestedproperties. (The top-level empty-enumstrip added since 1.0.0b260528 covers half of the old behavior; the nested case is what remains.)Code Sample
Actual output — identical on 1.0.0rc2 (latest) and 1.0.0b260528 (nested
itemsunconverted):{'examples': [], 'strict': False, 'properties': {'issues': {'items': {'kind': 'string', 'enum': []}, 'type': 'array'}}, 'type': 'object'}Expected:
{'type': 'object', 'properties': {'issues': {'type': 'array', 'items': {'type': 'string'}}}}Error Messages / Stack Traces
When the resulting schema is sent to OpenAI as a structured-output
response_format:Package Versions
agent-framework-declarative==1.0.0rc2 (latest; also reproduced on 1.0.0b260528; non-recursive loop present on main @ 7c6b1e9)
Python Version
3.13
Additional Context
Workaround we use in production: declarative agents whose output schema needs arrays use prompt-instructed JSON instead of
outputSchema.