Repository navigation
Description
Summary
OpenAIActivities.invoke_model accepts output_schema: AgentOutputSchemaBase | None. AgentOutputSchemaBase is an abstract OpenAI Agents class and is not a suitable Activity transport type for PydanticDataConverter.
With cadence-python-client==0.4.1 and OpenAI Agents 0.24.0, the Worker can fail while decoding the first model Activity input. A JSON null still causes Pydantic to construct a schema for the complete union, which raises PydanticSchemaGenerationError before the Activity or provider request runs. Non-null OpenAI schema objects also contain behavior that should remain in the Workflow rather than cross the Activity boundary.
Expected behavior
The OpenAI integration should transport null, plain-text, and structured-output metadata across the Activity boundary without weakening validation in the generic Pydantic converter. Provider request formatting must remain unchanged, and output validation must continue to run in the Workflow with the original OpenAI schema.
Resolution
Convert AgentOutputSchemaBase into a concrete, serializable CadenceOutputSchema in CadenceModel before scheduling the Activity. Transport only the metadata needed by the provider request:
- output type name;
- plain-text flag;
- JSON schema, when applicable; and
- strict JSON-schema flag.
PydanticDataConverter remains unchanged. The Activity uses the transported metadata for the provider request, while the Workflow retains the original schema for output validation.
Acceptance criteria
- Round-trip all 11
invoke_modelarguments withoutput_schema=None. - Round-trip a non-null structured output schema.
- Exercise the actual
CadenceModelto Activity conversion path. - Exercise the worker-side Activity boundary with a credential-free mocked model and tool.
- Preserve Responses API and Chat Completions request formatting in strict and non-strict modes.
- Keep strict validation unchanged for unsupported non-null arbitrary objects.
- Run OpenAI tests in the coverage job so the transport implementation is covered.
Validation
Implemented in PR #198.
- Unit tests, integration tests, Ruff, formatting, mypy, DCO, Gitar, and Codecov pass.
- OpenAI Agents 0.24.0 passes null, structured-output, and provider-format equivalence checks.
- A locally built wheel passed all 12 pinned
cadence-ai-samplesrecipe/profile locations. - The previously failing Recurring AI Watch OpenAI release test passed.
- The upgraded
cadence-samplesOpenAI environment passed compilation, Ruff, and boundary checks.
Downstream impact
OpenAI recipes should remain on their known-working client SHA until this fix is published in a client release. After that release, the SHA requirements can be replaced with the released version.
No paid-provider or Windows live matrix was run.
Activity
zawadzkidiana commentedon Oct 15, 2026
A local fix is complete on commit
1d3b16c330dddebf08ed70a654cd3353004aa9c7.It catches Pydantic schema-generation failure only for a JSON null whose hint explicitly accepts
None. Normal Pydantic validation still runs whenever an adapter can be built, and non-null unsupported values still fail.Validation:
invoke_modelregression passed.cadence-ai-sampleslocations, including the previously failing Recurring AI Watch OpenAI test.cadence-samplesOpenAI environment also passed compilation, Ruff, and the complete boundary check.The Docker integration suite was blocked before execution because local port 9090 was already allocated. No paid-provider or Windows live matrix was run.
zawadzkidiana commentedon Oct 15, 2026
Implementation update: the converter-level fallback described in my earlier comment has been replaced.
CadenceModelnow convertsAgentOutputSchemaBaseinto a concrete, serializableCadenceOutputSchemabefore scheduling the Activity.PydanticDataConverterremains unchanged, so there are no failedTypeAdapterbuilds to catch or cache.The revised tests cover:
output_schema=None;CadenceModelconversion before Activity scheduling;cadence-ai-sampleslocations; andcadence-samplesenvironment.Revision commit:
56f898d.[-]OpenAI invoke_model fails to decode null output_schema with PydanticDataConverter in v0.4.1[/-][+]OpenAI model Activity cannot transport output_schema through PydanticDataConverter[/+]fix(openai): serialize output schema activity input (cadence-workflow…