Title: feat(types): nested model_dump() resolution in response models · Issue #615 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: feat(types): nested model_dump() resolution in response models · Issue #615 · adcontextprotocol/adcp-client-python
X Title: feat(types): nested model_dump() resolution in response models · Issue #615 · adcontextprotocol/adcp-client-python
Description: Problem Pydantic doesn't auto-call custom model_dump() on nested models — if a parent's children have model_dump() overrides, the parent's super().model_dump() produces the children via the default Pydantic serialization, not via the chi...
Open Graph Description: Problem Pydantic doesn't auto-call custom model_dump() on nested models — if a parent's children have model_dump() overrides, the parent's super().model_dump() produces the children via the default...
X Description: Problem Pydantic doesn't auto-call custom model_dump() on nested models — if a parent's children have model_dump() overrides, the parent's super().model_dump() produces the children via...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/615
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(types): nested model_dump() resolution in response models","articleBody":"## Problem\n\nPydantic doesn't auto-call custom `model_dump()` on nested models — if a parent's children have `model_dump()` overrides, the parent's `super().model_dump()` produces the children via the default Pydantic serialization, not via the children's overrides. Adopters that need custom serialization on a child class (most commonly: tenant-internal fields excluded with `exclude=True`, or AdCP-spec-shaped overrides on extended types) end up writing this in every response model:\n\n```python\nclass GetCreativesResponse(AdCPBaseModel):\n creatives: list[Creative]\n\n def model_dump(self, **kwargs):\n result = super().model_dump(**kwargs)\n if \\\"creatives\\\" in result and self.creatives:\n result[\\\"creatives\\\"] = [c.model_dump(**kwargs) for c in self.creatives]\n return result\n```\n\nWe have **~59 such overrides** across [src/core/schemas/](https://github.com/prebid/salesagent/tree/main/src/core/schemas). Every override is mechanical: walk the children, call their `model_dump`. Adding a new response type means writing one again. Forgetting one is silent — the test fails on a serialization-difference, but only if the test exercises the nested path.\n\n## Proposed SDK shape\n\nEither of:\n\n**A) `AdCPBaseModel` recursively dispatches custom `model_dump()` on children.** Walk `__pydantic_fields__`, detect when a field's annotated type has a custom `model_dump`, and call it directly instead of relying on Pydantic's default child serialization. Same for lists/dicts of models.\n\n**B) Codegen flag** that emits nested-aware `model_dump()` on the generated response types — adopters extending those types via inheritance get the nested-walking for free.\n\n(A) is broader; (B) is narrower but ships with no risk to non-adopters.\n\n## Why this is the highest-LOC win on our open list\n\nThe other open framework gaps (spec defaults, agent-card URL, transport contextvar, test app builder) each kill 50-275 LOC of middleware. This one kills hundreds of LOC of mechanical override boilerplate spread across the schema package.\n\n## Files\n\n- Our overrides live across [src/core/schemas/_base.py](https://github.com/prebid/salesagent/blob/main/src/core/schemas/_base.py), product.py, creative.py, delivery.py, account.py.\n- Pattern documented in our CLAUDE.md as \"Critical Pattern #4: Pydantic Explicit Nested Serialization\" — we'd love to delete the section.","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-10T12:17:55Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/615"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5f6abc77-4824-a2c1-bc04-88334877ac54 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E14A:1C94F:FED93:1473D1:6B00F85C |
| html-safe-nonce | 2dbb441771281dcf1edba3997ba8bcbc568802da8a1b59812942bd2faaea0052 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTRBOjFDOTRGOkZFRDkzOjE0NzNEMTo2QjAwRjg1QyIsInZpc2l0b3JfaWQiOiI2ODE2NTg1MzM2NDk2Mzg4MTg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f0b9333fe446829603a2a6076e50470be59c712f3c2ec5245df3604ebf1bc321 |
| hovercard-subject-tag | issue:4415583069 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/adcontextprotocol/adcp-client-python/615/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d5c53c2cdbb31d9a741f9e7e65b7c7d8880e032481d5bd01c15e69b585d14ae6/adcontextprotocol/adcp-client-python/issues/615 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d5c53c2cdbb31d9a741f9e7e65b7c7d8880e032481d5bd01c15e69b585d14ae6/adcontextprotocol/adcp-client-python/issues/615 |
| og:image:alt | Problem Pydantic doesn't auto-call custom model_dump() on nested models — if a parent's children have model_dump() overrides, the parent's super().model_dump() produces the children via the default... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bokelley |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| turbo-cache-control | no-preview |
| go-import | github.com/adcontextprotocol/adcp-client-python git https://github.com/adcontextprotocol/adcp-client-python.git |
| octolytics-dimension-user_id | 221690821 |
| octolytics-dimension-user_login | adcontextprotocol |
| octolytics-dimension-repository_id | 1090305973 |
| octolytics-dimension-repository_nwo | adcontextprotocol/adcp-client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1090305973 |
| octolytics-dimension-repository_network_root_nwo | adcontextprotocol/adcp-client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width