|
| 1 | +# Migrating an integration from AdCP 3.1 to 3.2 beta |
| 2 | + |
| 3 | +Python SDK 8 beta supports the AdCP `3.2.0-beta.0` schemas and the compact |
| 4 | +product/media-buy lifecycle that becomes the foundation of AdCP 4.0. The SDK |
| 5 | +continues to support AdCP 3.0 and 3.1, and the deprecated |
| 6 | +`get_products`/`create_media_buy`/`update_media_buy` lifecycle remains available |
| 7 | +throughout AdCP 3.x. |
| 8 | + |
| 9 | +Protocol version and lifecycle shape are separate compatibility axes. A 3.2 |
| 10 | +seller may expose only the old lifecycle, a direct-buy subset of the compact |
| 11 | +lifecycle, or the complete proposal lifecycle. Do not infer supported tools |
| 12 | +from the version alone; read `media_buy.lifecycle_tools` or MCP `tools/list`. |
| 13 | + |
| 14 | +## Pin the beta precisely |
| 15 | + |
| 16 | +Use the release-precision prerelease identifier while 3.2 is in beta: |
| 17 | + |
| 18 | +```python |
| 19 | +client = ADCPClient(agent, adcp_version="3.2-beta.0") |
| 20 | +server = adcp_server("seller", adcp_version="3.2-beta.0") |
| 21 | +``` |
| 22 | + |
| 23 | +`"3.2"` intentionally does not alias to a prerelease. Exact prerelease pins |
| 24 | +prevent a deployment from silently changing contracts when 3.2 stable ships. |
| 25 | + |
| 26 | +## Choose the lifecycle subset |
| 27 | + |
| 28 | +| Workflow | Compact tools | |
| 29 | +|---|---| |
| 30 | +| Product feed/read | `list_products` | |
| 31 | +| Direct buy | `list_products`, `buy_products`, `control_media_buy` | |
| 32 | +| Proposal buy | `request_proposals`, `refine_proposals`, `decline_proposals`, `accept_proposal` | |
| 33 | + |
| 34 | +Sellers can combine these subsets. Declare exactly what is implemented: |
| 35 | + |
| 36 | +```python |
| 37 | +from adcp.decisioning import DecisioningCapabilities, DecisioningPlatform |
| 38 | +from adcp.decisioning.capabilities import LifecycleTool, MediaBuy |
| 39 | + |
| 40 | +class Seller(DecisioningPlatform): |
| 41 | + capabilities = DecisioningCapabilities( |
| 42 | + specialisms=["sales-non-guaranteed"], |
| 43 | + media_buy=MediaBuy( |
| 44 | + lifecycle_tools=[ |
| 45 | + LifecycleTool.list_products, |
| 46 | + LifecycleTool.buy_products, |
| 47 | + LifecycleTool.control_media_buy, |
| 48 | + ] |
| 49 | + ), |
| 50 | + ) |
| 51 | + |
| 52 | + def list_products(self, req, ctx): ... |
| 53 | + def buy_products(self, req, ctx): ... |
| 54 | + def control_media_buy(self, req, ctx): ... |
| 55 | + |
| 56 | + # Keep the 3.x compatibility facades while older buyers migrate. |
| 57 | + def get_products(self, req, ctx): ... |
| 58 | + def create_media_buy(self, req, ctx): ... |
| 59 | + def update_media_buy(self, media_buy_id, patch, ctx): ... |
| 60 | +``` |
| 61 | + |
| 62 | +Decisioning server startup fails if `lifecycle_tools` claims a method the |
| 63 | +platform does not implement. Tools omitted from the declaration are not |
| 64 | +advertised. |
| 65 | + |
| 66 | +Class-based `ADCPHandler` servers and decorator servers use the same names: |
| 67 | + |
| 68 | +```python |
| 69 | +class Handler(ADCPHandler): |
| 70 | + async def list_products(self, params, context=None): ... |
| 71 | + async def request_proposals(self, params, context=None): ... |
| 72 | + async def refine_proposals(self, params, context=None): ... |
| 73 | + async def decline_proposals(self, params, context=None): ... |
| 74 | + async def buy_products(self, params, context=None): ... |
| 75 | + async def accept_proposal(self, params, context=None): ... |
| 76 | + async def control_media_buy(self, params, context=None): ... |
| 77 | +``` |
| 78 | + |
| 79 | +## Update buyer calls |
| 80 | + |
| 81 | +Request and response models are public from `adcp`, `adcp.types`, |
| 82 | +`adcp.types.buyer`, and `adcp.types.media_buy`: |
| 83 | + |
| 84 | +```python |
| 85 | +from adcp import ListProductsRequest, BuyProductsRequest |
| 86 | + |
| 87 | +products = await client.list_products(ListProductsRequest(...)) |
| 88 | +purchase = await client.buy_products(BuyProductsRequest(...)) |
| 89 | +``` |
| 90 | + |
| 91 | +The same methods are available on `ADCPMultiAgentClient`. Do not import from |
| 92 | +`adcp.types._generated` or `adcp.types.generated_poc`. |
| 93 | + |
| 94 | +Each stateful compact task has its own idempotency identity. Retry with the |
| 95 | +same tool name and idempotency key; never retry `buy_products` as |
| 96 | +`create_media_buy`, or `accept_proposal` as another operation. Compact buy and |
| 97 | +control requests do not accept inline creatives—use the dedicated creative |
| 98 | +lifecycle. |
| 99 | + |
| 100 | +## Select the request-signing profile |
| 101 | + |
| 102 | +AdCP 3.2 tightens RFC 9421 handling: `Signature` Structured Fields binary |
| 103 | +values use standard padded Base64, and every signed body-bearing request covers |
| 104 | +`content-digest`. The SDK signer defaults to the 3.2 wire format. Select a |
| 105 | +legacy profile only when negotiating with a 3.0/3.1 peer: |
| 106 | + |
| 107 | +```python |
| 108 | +from adcp.signing import SigningConfig, VerifyOptions |
| 109 | + |
| 110 | +legacy_buyer = SigningConfig( |
| 111 | + private_key=key, |
| 112 | + key_id="buyer-key", |
| 113 | + signing_profile_version="3.1", |
| 114 | +) |
| 115 | + |
| 116 | +strict_3_2_verifier = VerifyOptions( |
| 117 | + ..., |
| 118 | + signing_profile_version="3.2", |
| 119 | +) |
| 120 | +``` |
| 121 | + |
| 122 | +Choose the verifier profile from trusted endpoint configuration and negotiated |
| 123 | +capabilities, never from an unsigned request-body field. The default verifier |
| 124 | +profile remains 3.1-compatible so existing deployments do not begin rejecting |
| 125 | +legacy signatures until they explicitly complete negotiation. |
| 126 | + |
| 127 | +## Test the two-dimensional matrix |
| 128 | + |
| 129 | +At minimum, exercise these rows independently: |
| 130 | + |
| 131 | +| Wire version | Lifecycle variant | Expected surface | |
| 132 | +|---|---|---| |
| 133 | +| 3.0 | legacy | `get_products`, `create_media_buy`, `update_media_buy` | |
| 134 | +| 3.1 | legacy | same legacy facade with canonical creative negotiation | |
| 135 | +| 3.2 beta | legacy | compatibility facade still works | |
| 136 | +| 3.2 beta | direct | list → buy → control | |
| 137 | +| 3.2 beta | proposal | request → refine/decline → accept → control | |
| 138 | + |
| 139 | +Keep legacy and compact tests against the same business implementation where |
| 140 | +possible. This catches accidental divergence between compatibility facades and |
| 141 | +the new task-specific contracts. |
0 commit comments