Describe the bug
Sometimes complex pydantic models in reasoners and skills and multiple arguments can cause the inputs paramters to become a simple dict, forcing pydantic model coercion.
And a side note: sometimes the parameters being put inside TYPE_CHECK blocks also builds properly but crash during deployment.
Steps to reproduce
Using parameters like:
item: PydanticModel1 | PydanticModel2 | None = None
items: list[PydanticModel1] | list[PydanticModel2] | None = None
maybe_empty_sequence: Sequence[PydanticModel1 | None] = []
In most cases, those fall through and crash during runtime. Nested JSON under the input can cause this as well.
Using the new RUFF 0.16 UP rules might have to do with this since it prefers using list[model] | None instead of Optional[List[model]] on newer python versions
Expected behavior
Inputs and outputs always recursively validate if they are a pydantic model, inputs are ensured to be an instance of the model / dataclass. Outputs survives roundrip losslessly
Screenshots / Logs
Environment
- Control plane version: 0.1.127
- SDK version (if applicable): 0.1.130
- Deployment environment (local, docker, kubernetes, etc.):
Additional context
Another side note: ruff allows to place decorators (flake8-type-checking) in runtime-evaluated-decorators and exempt-modules. Not sure if this can be set at the AF SDK level that will be inherited or it needs to be set manually for every project
Describe the bug
Sometimes complex pydantic models in reasoners and skills and multiple arguments can cause the inputs paramters to become a simple
dict, forcing pydantic model coercion.And a side note: sometimes the parameters being put inside
TYPE_CHECKblocks also builds properly but crash during deployment.Steps to reproduce
Using parameters like:
item: PydanticModel1 | PydanticModel2 | None = Noneitems: list[PydanticModel1] | list[PydanticModel2] | None = Nonemaybe_empty_sequence: Sequence[PydanticModel1 | None] = []In most cases, those fall through and crash during runtime. Nested JSON under the
inputcan cause this as well.Using the new RUFF 0.16 UP rules might have to do with this since it prefers using
list[model] | Noneinstead ofOptional[List[model]]on newer python versionsExpected behavior
Inputs and outputs always recursively validate if they are a pydantic model, inputs are ensured to be an instance of the model / dataclass. Outputs survives roundrip losslessly
Screenshots / Logs
Environment
Additional context
Another side note: ruff allows to place decorators (flake8-type-checking) in
runtime-evaluated-decoratorsandexempt-modules. Not sure if this can be set at the AF SDK level that will be inherited or it needs to be set manually for every project