Skip to content

feat(training-agent): metric-mode forcing function for clicks/reach/completed_views scenarios#4766

Merged
bokelley merged 2 commits into
mainfrom
bokelley/training-agent-metric-mode-forcing
May 19, 2026
Merged

feat(training-agent): metric-mode forcing function for clicks/reach/completed_views scenarios#4766
bokelley merged 2 commits into
mainfrom
bokelley/training-agent-metric-mode-forcing

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

Summary

  • Declares seller-level media_buy.supported_optimization_metrics on both surfaces (v5 legacy /mcp handler and v6 TrainingSalesPlatform.capabilities) as the honest union across catalog products: [clicks, views, completed_views, engagements, reach].
  • Validates reach_unit against the product's metric_optimization.supported_reach_units and view_duration_seconds against supported_view_durations on create_media_buy, returning INVALID_REQUEST with literal JSONPath-lite error.field. Mirrors the event_source_id / audience_id checks already in place.
  • Emits cost_per_click (always when clicks + spend > 0), plus goal-gated reach + frequency and completed_views + completion_rate on get_media_buy_delivery. Placeholder ratios documented inline (reach = floor(impressions / 3); completed_views = floor(impressions × 0.7)).
  • Persists optimization_goals on PackageState so delivery handlers can gate metric emission on what the buyer actually requested.

Flips three capability-gated storyboards from not_applicable to applicable on the training agent: clicks_buy_flow, reach_buy_flow, completed_views_buy_flow.

Same forcing-function shape as #4654 (event_source validation + CPA) and #4664 (audience_buy_flow / event_dedup_flow). Manual declaration is required until adcp-client#1818 (SDK auto-rollup from product-level supported_metrics) ships — that PR is blocked on the SDK exposing the seller-level field.

Refs: #4637, #4642, #4654, #4664, #4722.

Test plan

  • npm run build:schemas
  • npm run build:compliance
  • npm run typecheck
  • npx vitest run server/tests/unit/training-agent.test.ts — 382 tests pass (6 new)
  • Confirm the three storyboard scenarios grade applicable (no longer not_applicable) against the training agent on the next compliance run

🤖 Generated with Claude Code

bokelley and others added 2 commits May 19, 2026 03:55
…elivery for clicks/reach/completed_views

Declares seller-level `media_buy.supported_optimization_metrics` (honest
union across catalog products), validates `reach_unit` / `view_duration_seconds`
against product capabilities on create_media_buy, and emits `cost_per_click`
plus goal-gated `reach + frequency` / `completed_views + completion_rate`
on get_media_buy_delivery. Flips three capability-gated storyboards from
`not_applicable` to applicable: clicks_buy_flow, reach_buy_flow,
completed_views_buy_flow. Same forcing-function shape as #4654 and #4664.

Manual rollup pending adcp-client#1818 (SDK seller-level field exposure).

Refs: #4637, #4642, #4654, #4664, #4722.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…r_click negative tests (PR 4766 review)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit b716da5 into main May 19, 2026
24 of 25 checks passed
@bokelley bokelley deleted the bokelley/training-agent-metric-mode-forcing branch May 19, 2026 11:17
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