Skip to content

feat: response builders that eliminate media buy traps#526

Merged
bokelley merged 7 commits into
mainfrom
bokelley/response-builders
Apr 15, 2026
Merged

feat: response builders that eliminate media buy traps#526
bokelley merged 7 commits into
mainfrom
bokelley/response-builders

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

  • validActionsForStatus(status) — maps MediaBuyStatus to the correct set of buyer actions. Terminal statuses return [], active returns the full set. Exported from @adcp/client/server.
  • mediaBuyResponse() auto-defaultsrevision: 1, confirmed_at: now(), and valid_actions from status when not explicitly provided. Existing callers unaffected (explicit values always win).
  • updateMediaBuyResponse() auto-defaultsvalid_actions from status when not explicitly provided.
  • cancelMediaBuyResponse(input) — requires canceled_by and revision, auto-sets canceled_at, status: 'canceled', valid_actions: []. Makes it impossible to forget cancellation metadata.
  • Schema sync — regenerated types from latest AdCP schemas (reporting_capabilities now required on products, media_buy.reporting removed from capabilities, object-presence pattern active).

These address implementation traps documented in #502 where agent builders were getting response shapes wrong for revision, valid_actions, cancellation metadata, and account setup nesting.

Test plan

  • 50 response builder tests pass (8 new for mediaBuyResponse defaults, 4 new for updateMediaBuyResponse defaults, 8 new for validActionsForStatus, 10 new for cancelMediaBuyResponse)
  • Full suite passes (2841 pass, 0 fail)
  • TypeScript build clean
  • Code review feedback addressed (ValidAction derived from schema, revision required on cancel, no type widening)

🤖 Generated with Claude Code

bokelley and others added 3 commits April 15, 2026 05:02
Add validActionsForStatus() utility that maps MediaBuyStatus to the
correct set of buyer actions, eliminating the common trap of forgetting
valid_actions in responses.

Enhance mediaBuyResponse() with auto-defaults: revision defaults to 1,
confirmed_at defaults to now, valid_actions populated from status.

Enhance updateMediaBuyResponse() with valid_actions auto-population
from status when not explicitly provided.

Add cancelMediaBuyResponse() convenience builder that requires
canceled_by and revision, auto-sets canceled_at and status/valid_actions.

Sync schemas from latest AdCP (reporting_capabilities now required on
products, media_buy.reporting removed, object-presence pattern for
content_standards/audience_targeting/conversion_tracking).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bokelley and others added 4 commits April 15, 2026 05:10
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…umbers)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update SDK Quick Reference tables and code examples in build-seller-agent,
build-generative-seller-agent, and build-retail-media-agent skills to
document validActionsForStatus, cancelMediaBuyResponse, and the
auto-defaults on mediaBuyResponse/updateMediaBuyResponse.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit 316565c into main Apr 15, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant