Release v0.26.2#864
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryFixes a Literal→Enum regression in
Confidence Score: 3/5The Literal-choices fix is correct and well-tested, but The core pipelex/cogt/content_generation/schema_to_model_factory.py — specifically the Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant SchemaToModelFactory
participant datamodel_codegen as datamodel-code-generator
participant exec_ns as exec namespace
participant Pydantic
Caller->>SchemaToModelFactory: make_from_json_schema(schema, class_name)
SchemaToModelFactory->>SchemaToModelFactory: _reject_unsafe_schema_extensions(schema)
SchemaToModelFactory->>datamodel_codegen: generate(schema, enum_field_as_literal=LiteralType.All)
Note over datamodel_codegen: enum strings stay as Literal
datamodel_codegen-->>SchemaToModelFactory: source_code (Python str)
SchemaToModelFactory->>exec_ns: exec(source_code, restricted_builtins)
exec_ns-->>SchemaToModelFactory: namespace with user types and RootModel base class
SchemaToModelFactory->>SchemaToModelFactory: filter all_user_types
SchemaToModelFactory->>Pydantic: model_rebuild each BaseModel with Literal in namespace
Pydantic-->>SchemaToModelFactory: resolved annotations
SchemaToModelFactory-->>Caller: reconstructed class with kajson_class_source
|
Release v0.26.2
Bumps version from
0.26.1to0.26.2.Changelog
[v0.26.2] - 2026-05-06
Fixed
choicesfields no longer fail validation with'EnumName.MEMBER_NAME'errors. A concept declared withchoices = [...]produces aLiteral[...]field on the dynamic Pydantic class. That schema is round-tripped throughSchemaToModelFactory.make_from_json_schema(used to rebuild dynamic models on Temporal workers and to feed structured-output schemas to LLM providers). Previously the round-trip silently re-emitted the field as a plain PythonEnumclass — e.g.Literal["Strong Match", "Good Match", "Partial Match", "Poor Match"]becameclass Recommendation(Enum): Poor_Match = "Poor Match"; .... LLMs filling that schema then returned the enum's Python repr ("Recommendation.Poor_Match") instead of the literal string ("Poor Match"), which failed Pydantic validation against the original choice set with errors likeInvalid choice errors: 'recommendation': got 'Recommendation.Poor_Match', expected one of 'Strong Match', 'Good Match', 'Partial Match' or 'Poor Match'._generate_source_from_schemanow passesenum_field_as_literal=LiteralType.Alltodatamodel-code-generator, soenum: [strings]schema nodes round-trip asLiteral[...]instead of being regenerated asEnumclasses._exec_source_to_typesnow also exposesLiteralin the rebuild namespace somodel_rebuildresolves the deferred annotations.Summary by cubic
Ensures
choicesfields stayLiteral[...]when rebuilding models from JSON Schema and supportsRootModel[Literal[...]]shapes to prevent'EnumName.MEMBER_NAME'validation errors. Releases v0.26.2.enum_field_as_literal=LiteralType.Allwithdatamodel-code-generatorsoenum: [strings]round-trip asLiteral[...](not generatedEnum) and serialize as plain strings.Literaland skipping baseRootModelwhen collecting types, ensuring dynamic models rebuild and round-trip correctly.Written for commit 974b3b3. Summary will update on new commits.