Skip to content

feat(decisioning): let a seller declare property_list_filtering when its own get_products already filters #1300

Closed

Description

@bokelley

Summary

On 8.0.0, declaring Features(property_list_filtering=True) opts a seller into SDK-side filtering. There is no way to say "my handler applies property_list itself".

  • At boot, create_adcp_server_from_platform fails unless a PropertyListFetcher is passed (adcp/decisioning/serve.py:416-425 calling validate_property_list_config, adcp/decisioning/property_list.py:301-336).
  • At request time, the get_products shim re-fetches the list and re-filters the platform's response (adcp/decisioning/handler.py:2497-2506 calling maybe_apply_property_list_filter, property_list.py:253-298).
  • That post-filter calls response.model_copy(...) (property_list.py:298), so a platform that returns a dict from get_products, a return shape the dispatcher otherwise accepts, raises AttributeError.

So a seller whose handler already filters must either leave the capability undeclared, which means buyers can't discover it, or wire a fetcher that fetches the list a second time.

Reproduction (adcp 8.0.0)

import asyncio
import logging
import warnings

warnings.simplefilter("ignore")
logging.disable(logging.CRITICAL)

from adcp.decisioning import DecisioningCapabilities, DecisioningPlatform, SingletonAccounts
from adcp.decisioning.capabilities import Features, MediaBuy
from adcp.decisioning.serve import create_adcp_server_from_platform
from adcp.server.mcp_tools import create_tool_caller
from adcp.types import GetProductsResponse

CAPS = DecisioningCapabilities(
    specialisms=["sales-non-guaranteed"],
    supported_billing=["operator"],
    media_buy=MediaBuy(features=Features(property_list_filtering=True, canonical_creatives=True)),
)


class Seller(DecisioningPlatform):
    capabilities = CAPS
    accounts = SingletonAccounts(account_id="acct")
    return_dict = True

    async def get_products(self, req, ctx):
        # The seller already resolved req.property_list, filtered, then paginated.
        payload = {"products": [], "property_list_applied": True}
        return payload if self.return_dict else GetProductsResponse.model_validate(payload)

    def create_media_buy(self, req, ctx): raise NotImplementedError
    def update_media_buy(self, media_buy_id, patch, ctx): raise NotImplementedError
    def sync_creatives(self, req, ctx): raise NotImplementedError
    def get_media_buy_delivery(self, req, ctx): raise NotImplementedError


try:
    create_adcp_server_from_platform(Seller())
except Exception as exc:
    print("1. boot without a fetcher:", str(exc)[:120], "...")


class CountingFetcher:
    calls = 0

    async def fetch(self, agent_url, list_id, *, auth_token=None):
        CountingFetcher.calls += 1
        return ["example.com"]


REQUEST = {
    "adcp_version": "3.1", "buying_mode": "brief", "brief": "video",
    "property_list": {"agent_url": "https://example.com", "list_id": "approved"},
}

handlers = []
for return_dict in (True, False):
    seller = Seller()
    seller.return_dict = return_dict
    handlers.append(create_adcp_server_from_platform(seller, property_list_fetcher=CountingFetcher())[0])


async def main():
    for handler in handlers:
        CountingFetcher.calls = 0
        try:
            await create_tool_caller(handler, "get_products")(dict(REQUEST))
            print(f"3. model return: ok; SDK fetcher calls on top of the seller's own: {CountingFetcher.calls}")
        except Exception as exc:
            print(f"2. dict return: {type(exc).__name__}: {exc} (fetcher calls: {CountingFetcher.calls})")

asyncio.run(main())

Output:

1. boot without a fetcher: AdcpError[INVALID_REQUEST / terminal]: Features.property_list_filtering=True is declared in capabilities but no Property ...
2. dict return: AttributeError: 'dict' object has no attribute 'model_copy' (fetcher calls: 1)
3. model return: ok; SDK fetcher calls on top of the seller's own: 1

Why an adopter hits this

Embedded Sales Agent's _get_products_impl (src/core/tools/products.py) resolves the buyer's list with its own cached, SSRF-checked resolver. It filters with the same rules the SDK later adopted from it (#494), then paginates the filtered set. Its decisioning delegates return wire dicts.

Declaring the capability would fail at boot. Wiring a fetcher would crash on the dict return, or, with a model return, fetch the list a second time and re-filter an already-paginated page. So build_router in core/main.py leaves property_list_filtering undeclared, with a comment explaining why. Buyers that select sellers by this capability skip ESA, even though it honors property_list.

Ask

  1. Add an explicit platform-owned mode, for example create_adcp_server_from_platform(..., property_list_filtering="platform"), or a PLATFORM_FILTERS sentinel for property_list_fetcher. It would skip the boot check and the post-adapter filter while still advertising the capability.
  2. Independently, make maybe_apply_property_list_filter handle dict responses (or coerce to GetProductsResponse first).

Activity

  1. added
    enhancementNew feature or request
    claude-triagingTriage routine is actively working on this issue (1-3 min)
    on Oct 2, 2026
  2. bokelley commented on Oct 2, 2026

    @bokelley
    ContributorAuthor

    Triage

    Classification: Bug + Feature request (two items, one cohesive brief below)
    Bucket(s): handlers
    Status: ready-to-implement
    Milestone: omitted

    What the experts said:

    • code-reviewer: Confirmed two blockers — getattr(response, "products", None) silently returns [] for dicts (attributes vs. keys), then model_copy crashes; both are on the same dict-response path and must be fixed together. Prefers new property_list_filter_mode kwarg over sentinel; recommends documenting that platform-owned mode makes the platform responsible for property_list_applied.
    • dx-expert: Same two blockers confirmed. Option A (new kwarg) preferred over Option B (sentinel would require PropertyListFetcher | None type change and is unguessable by code generators). Naming nit: use property_list_filter_mode: Literal["sdk", "platform"] = "sdk" to avoid visual collision with Features(property_list_filtering=True).

    My take: Both issues are non-breaking fixes to the same code path. The dict-return crash is independently shippable; the platform-owned mode unblocks sellers like ESA who do their own filtering. Both experts converge — this is a clean Ready to implement.

    Implementation brief:

    • Fix 1 — dict-response crash (src/adcp/decisioning/property_list.py:253–298): In maybe_apply_property_list_filter, branch on isinstance(response, dict): extract products via response.get("products") or [] and return {**response, "products": filtered, "property_list_applied": True}. For Pydantic models keep model_copy. Also update the products extraction on line 295 to use .get() for dicts.
    • Fix 2 — platform-owned mode (src/adcp/decisioning/serve.py + property_list.py:301–335): Add property_list_filter_mode: Literal["sdk", "platform"] = "sdk" kwarg to create_adcp_server_from_platform. Thread it into validate_property_list_config (skip the missing-fetcher error when mode is "platform") and into maybe_apply_property_list_filter (early-return without SDK filtering when mode is "platform"). Update the boot-error message to mention property_list_filter_mode="platform" as an alternative.
    • Fix 3 — property_list_applied in platform mode: When property_list is present in the request and mode is "platform", the framework should not override the platform's property_list_applied value but should document that the platform is responsible for setting it.
    • Tests: Parameterize existing filter tests over both GetProductsResponse model and plain-dict returns. Add a boot test for property_list_filter_mode="platform" skipping the validate_property_list_config error. Add an integration test that a dict-returning platform + mode "platform" boots and processes a request without crash.
    • Required checks: pytest tests/test_decisioning_property_list.py (and any test_serve.py), mypy src/adcp/decisioning/ (new Literal["sdk", "platform"] type must be importable), ruff check . / black --check ..
    • Non-breaking rationale: New kwarg defaults to "sdk" (existing behavior unchanged). Dict-response fix changes only the error from AttributeError to correct behavior. No public symbols removed or renamed.

    Triaged by Claude Code. Session: https://claude.ai/code/session_014f8dd8nS9tCTFaktNAepg5


    Generated by Claude Code

  3. added
    bugSomething isn't working
    and removed
    claude-triagingTriage routine is actively working on this issue (1-3 min)
    on Oct 2, 2026
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