Skip to content

Pydantic Models Seperation and Schemas file cleanup #1047

Closed

Description

@ChrisHuie

Hey everyone. Been digging into the schemas.py which serves as the file for all the Pydantic models. These file is a beast and there seem to be some weird issues. Here are some things I found that I am planning to address. This build on Constantin's work in these prs to fix model_dump() inconsistencies and starting out a salesagent model from the base model. Here are some further issues to address with this file. Not in any order.

  1. Breakout file into the related models and get away from 4k line single file

Possible sub groups for splitting models into
The 8 domain groups:

Foundation — AdCPBaseModel is the root class with env-aware validation (strict in dev, lenient in prod). NestedModelSerializerMixin and TaskStatus which defines the universal state machine.

Pricing — pricing models and V3 consolidated pricing into fixed_price OR floor_price — never both.

Product Discovery — The request/response cycle lets AI agents discover ad inventory with filters and natural language briefs.

Media Buy Lifecycle — The core transactional flow: CreateMediaBuyRequest → CreateMediaBuySuccess/Error. Packages within buys reference products and pricing options.

Delivery & Reporting — Metrics at every level: per-package, per-day, aggregated totals. Enables pacing analysis and budget tracking.

Creative Lifecycle — Upload, sync, assign, review, and approve creatives. SyncCreativesRequest is a bulk operation that does upload + assignment in one call.

Targeting & Signals — Comprehensive any_of/none_of targeting across geo, device, audience, and content dimensions, plus AXE signal integration for data provider segments.

Admin & Operations — Human tasks, simulation control, property authorization, and principal (advertiser) identity management.

  1. Fix exclude=True and model_dump inconsistencies in both handling exclusions
  • Constantine noted some of the issues with serialization and model_dump so he might clean this up in that pr
  1. Clean Deprecated and Legacy code and comments in this file

  2. Make sure there is consitentency like with some responses having a _str_() while others don't

  3. Validation doesn't always use the pydantic model_validate and in some cases recreates it as classmethod but don't believe that is a thing.

Activity

  1. KonstantinMirin commented on Feb 17, 2026

    @KonstantinMirin
    Collaborator

    On the #2 above, per note in my PR #1044 I think that we need to avoid model_dump and exclude=True at all in the sales agent and instead rely on serialization/deserialization at the system boundaries. So the goal is to weed out these things completely.
    The issue with that is -- a lot of test are implementation-specific (even e2e ones) and test cetain flags and state of the dict instead of the behavior. So sometimes it is impossible to refactor without changing the test (yeah, I know, I know). Doing my best to keep that at the bare minimum and review several times the diff between the original and updated test.

  2. KonstantinMirin commented on Feb 17, 2026

    @KonstantinMirin
    Collaborator

    And I totally support the chunking as @ChrisHuie suggests. It is not the final state, but it is definitely a huge step forward and lets us avoid the gigantic diffs. Also, as one does that, I am pretty sure that there are tons of candidates for the helper method extraction to avoid code duplication

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions