Skip to content

OpenAI model Activity cannot transport output_schema through PydanticDataConverter #197

Closed

Description

@zawadzkidiana

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_model arguments with output_schema=None.
  • Round-trip a non-null structured output schema.
  • Exercise the actual CadenceModel to 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-samples recipe/profile locations.
  • The previously failing Recurring AI Watch OpenAI release test passed.
  • The upgraded cadence-samples OpenAI 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

  1. added
    triage/needs-decisionUnderstood and ready for the TSC/domain owner to decide whether/when to prioritize.
    kind/bugExisting behavior is broken or not working as documented/intended.
    on Oct 15, 2026
  2. zawadzkidiana commented on Oct 15, 2026

    @zawadzkidiana
    ContributorAuthor

    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:

    • Full client unit suite, Ruff, formatting, and mypy passed.
    • Full 11-argument invoke_model regression passed.
    • OpenAI Agents 0.24.0 passed the same 11-argument boundary.
    • A locally built wheel passed all 12 pinned cadence-ai-samples locations, including the previously failing Recurring AI Watch OpenAI test.
    • The upgraded cadence-samples OpenAI 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.

  3. zawadzkidiana commented on Oct 15, 2026

    @zawadzkidiana
    ContributorAuthor

    Implementation update: the converter-level fallback described in my earlier comment has been replaced.

    CadenceModel now converts AgentOutputSchemaBase into a concrete, serializable CadenceOutputSchema before scheduling the Activity. PydanticDataConverter remains unchanged, so there are no failed TypeAdapter builds to catch or cache.

    The revised tests cover:

    • all 11 arguments with output_schema=None;
    • all 11 arguments with a non-null structured output schema;
    • the actual CadenceModel conversion before Activity scheduling;
    • OpenAI Agents 0.24.0;
    • all 12 pinned cadence-ai-samples locations; and
    • the upgraded cadence-samples environment.

    Revision commit: 56f898d.

  4. changed the title [-]OpenAI invoke_model fails to decode null output_schema with PydanticDataConverter in v0.4.1[/-] [+]OpenAI model Activity cannot transport output_schema through PydanticDataConverter[/+] on Oct 15, 2026
  5. added a commit that references this issue on Oct 16, 2026
    c28b21f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugExisting behavior is broken or not working as documented/intended.triage/needs-decisionUnderstood and ready for the TSC/domain owner to decide whether/when to prioritize.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions