Title: feat(decisioning): refine[] flow scaffold for get_products (position-matched echo) · Issue #496 · adcontextprotocol/adcp-client-python · GitHub
Open Graph Title: feat(decisioning): refine[] flow scaffold for get_products (position-matched echo) · Issue #496 · adcontextprotocol/adcp-client-python
X Title: feat(decisioning): refine[] flow scaffold for get_products (position-matched echo) · Issue #496 · adcontextprotocol/adcp-client-python
Description: Motivation GetProductsRequest.refine[] is a discriminated-union list (scope: request | product | proposal) used when buying_mode='refine' to iterate on a previous response. The seller MUST return refinement_applied[] in the response, sam...
Open Graph Description: Motivation GetProductsRequest.refine[] is a discriminated-union list (scope: request | product | proposal) used when buying_mode='refine' to iterate on a previous response. The seller MUST return r...
X Description: Motivation GetProductsRequest.refine[] is a discriminated-union list (scope: request | product | proposal) used when buying_mode='refine' to iterate on a previous response. The seller MUST ...
Opengraph URL: https://github.com/adcontextprotocol/adcp-client-python/issues/496
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(decisioning): refine[] flow scaffold for get_products (position-matched echo)","articleBody":"## Motivation\n\n`GetProductsRequest.refine[]` is a discriminated-union list (scope: `request` | `product` | `proposal`) used when `buying_mode='refine'` to iterate on a previous response. The seller MUST return `refinement_applied[]` in the response, **same length, same order, echoing scope and the matching id field** (per the wire description). That echo contract is mechanical — adopters that get it wrong silently break orchestrators that cross-validate alignment.\n\nThe framework can scaffold the position-matched echo, validate the request, and call the adopter once per refine entry with a typed handler. The narrowing logic itself is adopter business logic, but every other piece is protocol plumbing.\n\nParent tracker: #491.\n\n## Current state\n\n**Salesagent**: does not implement `refine`. Grep of `src/core/tools/products.py` shows zero references to `refine` or `buying_mode`. A buyer sending `buying_mode='refine'` to salesagent today gets undefined behavior.\n\n**SDK**: `MediaBuyHandler.get_products` (`src/adcp/decisioning/handler.py:1015-1033`) is a pass-through; nothing validates the refine shape or builds `refinement_applied[]`. Wire shapes:\n- Request: `src/adcp/types/generated_poc/bundled/media_buy/get_products_request.py:21-107` (`Refine` / `Refine6` / `Refine7` / discriminated `Refine4`)\n- Request mode: `src/adcp/types/generated_poc/bundled/media_buy/get_products_request.py:15-18` (`BuyingMode.refine`)\n- Response: lines 4550-4554 of `get_products_response.py` (`refinement_applied`)\n\n## Proposed API\n\nAdopter-facing protocol the framework calls per refine entry; framework handles everything else (validation, position alignment, `refinement_applied[]` construction, `buying_mode` cross-validation):\n\n```python\n# src/adcp/decisioning/specialisms/sales.py — extend SalesPlatform\n\nclass SalesPlatform(Protocol):\n ...\n async def refine_get_products(\n self,\n previous_response_state: GetProductsResponseState, # opaque, framework-managed\n refines: list[Refine4],\n ctx: RequestContext,\n ) -> RefineResult:\n \\\"\\\"\\\"Optional. When buying_mode='refine', framework calls this\n instead of get_products. Adopter applies the narrowing logic per\n refine entry; framework projects to the wire response with\n position-matched refinement_applied[].\\\"\\\"\\\"\n\n\n# Adopter returns a typed shape that mirrors per-entry decisions:\n@dataclass\nclass RefineResult:\n products: list[Product]\n proposals: list[Proposal] | None\n per_refine_outcome: list[RefinementOutcome] # exactly len(refines)\n\n@dataclass\nclass RefinementOutcome:\n status: Literal['applied', 'partial', 'unable']\n note: str | None\n # framework infers scope + product_id/proposal_id from the request entry\n```\n\nThe framework:\n1. Rejects `buying_mode='refine'` when adopter doesn't implement `refine_get_products` (with a clear `AdcpError`).\n2. Validates `len(refinement_outcome) == len(refines)` and raises a developer-facing error if not.\n3. Echoes `scope`, `product_id`, `proposal_id` from request entries by position (adopter doesn't have to remember).\n4. Rejects `buying_mode='refine' + brief` and `buying_mode='wholesale' + brief` per wire spec.\n\n## Acceptance criteria\n\n- [ ] `refine_get_products` is optional on `SalesPlatform`; when absent, `buying_mode='refine'` returns `AdcpError(REFINE_NOT_SUPPORTED)`\n- [ ] Framework constructs `refinement_applied[i]` from `refines[i]` + `per_refine_outcome[i]` — adopter doesn't echo scope/id manually\n- [ ] Framework rejects mismatched lengths with a developer-facing error (not a wire error — this is an adopter bug)\n- [ ] Framework rejects `buying_mode='refine'` + non-empty `brief` per wire spec\n- [ ] Framework rejects `buying_mode='wholesale'` + non-empty `brief` per wire spec\n- [ ] `validate_platform` warns when adopter implements `refine_get_products` but doesn't list `sales-proposal-mode` (or whichever specialism gates refine — confirm via spec)\n- [ ] Test: 3-entry refine, all `applied` → response has 3-entry `refinement_applied`, scope+ids echoed correctly\n- [ ] Test: mixed `applied`/`unable` outcomes\n- [ ] Test: `proposal` scope echoes `proposal_id`\n- [ ] Test: `request` scope (no id) echoes scope only\n\n## Out of scope\n\n- The narrowing logic itself (adopter business logic)\n- Storing previous-response state — framework passes `previous_response_state` opaquely; adopter chooses whether to load anything from it (probably yes via `product_id` lookup, but not framework's job)\n- The `request_proposal` task (separate verb per `SalesPlatform.get_products` docstring at sales.py:115)\n- `action='finalize'` proposal-scoped refines that trigger HITL — that's a `SalesResult` hybrid concern, may need its own follow-up\n\n## Cross-references\n\n- Wire shapes: `src/adcp/types/generated_poc/bundled/media_buy/get_products_request.py:21-107`, `1413-1431`\n- Wire response: `src/adcp/types/generated_poc/bundled/media_buy/get_products_response.py:4550-4554`\n- `SalesPlatform` protocol: `src/adcp/decisioning/specialisms/sales.py:105-119`\n- Parent tracker: #491\n- Migration guide: #489\n\n## Open question (for the implementer)\n\nSpec-side: is `refine_get_products` gated by a specialism, or is it implicit in `sales-*`? If it's implicit, drop the `validate_platform` warning. If gated, name the gate. Check `adcontextprotocol/adcp` schemas before implementing.","author":{"url":"https://github.com/bokelley","@type":"Person","name":"bokelley"},"datePublished":"2026-05-03T21:07:57Z","url":"https://github.com/adcontextprotocol/adcp-client-python/issues/496"}
| 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:6b4829de-dc32-129b-23d3-953ae9e08c81 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E852:117C62:B8AE2D:F7E532:6B00F6A7 |
| html-safe-nonce | e77effa2ffb22e97f096100ea9029cd8a24d00efef346e68647a998f8656f9ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODUyOjExN0M2MjpCOEFFMkQ6RjdFNTMyOjZCMDBGNkE3IiwidmlzaXRvcl9pZCI6IjYzNjAzNDQ0MDM4ODk5NDQyMzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 702b7875c117fbf1379c2b780ebccfda368d162361e34c2325b962e50ce552d7 |
| hovercard-subject-tag | issue:4372989339 |
| 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/496/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d6dbfa74077b1dc24edc10eb8ea178f94e0f72c94f454be09f3b21ed2be38e30/adcontextprotocol/adcp-client-python/issues/496 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d6dbfa74077b1dc24edc10eb8ea178f94e0f72c94f454be09f3b21ed2be38e30/adcontextprotocol/adcp-client-python/issues/496 |
| og:image:alt | Motivation GetProductsRequest.refine[] is a discriminated-union list (scope: request | product | proposal) used when buying_mode='refine' to iterate on a previous response. The seller MUST return r... |
| 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 | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width