Skip to content

Add canonical creative format compatibility helpers #885

@bokelley

Description

@bokelley

Context

While validating bokelley/salesagent#631 end-to-end, we found that legacy creative format IDs are upgraded by the SDK/schema layer, but implementations still need a reliable way to compare upgraded legacy IDs with structured canonical format refs.

Example failure mode:

  • client sends legacy display_300x250
  • SDK/model validation upgrades this to canonical display_image with width/height
  • implementation code still compares exact (agent_url, id) tuples
  • display_image no longer matches a product/creative format that originated as display_300x250 unless every implementation reimplements canonical matching correctly

Proposed SDK work

Expose documented helpers for common format compatibility checks, for example:

  • upgrade_legacy_format_id(value) -> FormatId (already effectively present in some surfaces)
  • canonical_format_matches(a, b) -> bool for equivalence after legacy upgrade
  • canonical_format_satisfies(requested, supported) -> bool for product/capability gating

The important distinction is that product gating is stricter than equivalence: if the supported/product format declares width, height, or duration_ms, the requested creative format should also declare and match that value. A broad supported format can accept a more specific request, but an under-specified request should not silently match a fixed-size/fixed-duration product.

Acceptance criteria

  • SDK exposes a helper or documented pattern for legacy-to-canonical format comparison.
  • Tests cover at least display_300x250 vs structured display_image width=300 height=250.
  • Tests cover the stricter product-gating case: requested display_image with no dimensions does not satisfy supported display_image width=300 height=250.
  • Docs/comments make clear which helper is for equivalence and which is for capability satisfaction.

Discovered in

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions