Pydantic Models Seperation and Schemas file cleanup #1047
Description
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.
- 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.
- Fix
exclude=Trueandmodel_dumpinconsistencies in both handling exclusions
- Constantine noted some of the issues with serialization and model_dump so he might clean this up in that pr
-
Clean Deprecated and Legacy code and comments in this file
-
Make sure there is consitentency like with some responses having a
_str_()while others don't -
Validation doesn't always use the pydantic
model_validateand in some cases recreates it as classmethod but don't believe that is a thing.
Activity
KonstantinMirin commentedon Feb 17, 2026
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
dictinstead 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.KonstantinMirin commentedon Feb 17, 2026
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