Skip to content

fix(training-agent): echo the media buy context on inventory get_media_buys - #9148

Merged
bokelley merged 1 commit into
mainfrom
fix/inventory-buy-context
Nov 21, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/inventory-buy-context

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

The inventory tenants (/inventory-adserver, /inventory-content) dropped the media-buy-level context after creation:

  • create_media_buy echoed it on its response; the SDK does that.
  • get_media_buys returned each buy without it.

core/media-buy.json says sellers MUST include persisted context on read surfaces such as get_media_buys when the buy was created through AdCP with context.

Where it showed up. The Apostra simulator's staging certification run 171 failed context_echo on all four live /inventory-adserver buys. The run compares media_buys[].context with the { storefront_media_buy_id } its create sent.

#9143 fixed the same gap for package context; this fixes it for the buy.

Change

  • Persist. create_media_buy stores the request's top-level context on the buy record, as an opaque structured clone that is never parsed.
  • Read back. get_media_buys returns it unchanged on each buy, and omits it for a buy created without one.
  • Updates are separate. update_media_buy keeps echoing the update request's own operation-level context, as update-media-buy-response.json specifies. It never replaces the buy's context, and a test pins that.

Storyboard coverage

protocols/media-buy/index.yaml already asserts this: check_buy_status checks media_buys[0].context.correlation_id. On the inventory tenants, though, every media_buy_seller step skips as fixture_seed_unsupported (0P / 16S). Their controller serves no seed_* scenarios, so the existing assertion never ran there. Seed scenarios on these tenants would be the follow-up. This PR adds no new storyboard.

Test plan

  • New test in training-agent-inventory-tenants.test.ts: context echoed on create, on get_media_buys, and after an update that carries its own operation context. A buy created without context reads back without one. It failed before the fix (get_media_buys returned no context) and passes after.
  • Inventory suite: 24/24
  • After deploy: live read-back on both tenants

🤖 Generated with Claude Code

…a_buys

The inventory tenants echoed create_media_buy's top-level context on the
create response (the SDK does that) but dropped it afterwards, so
get_media_buys returned each buy without the context it was created with.
core/media-buy.json says sellers MUST include persisted context on read
surfaces. Persist it on the buy and return it unchanged on every read.

An update's context stays its own: update_media_buy echoes the update
request's operation-level context and never replaces the buy's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — clean fix with complete test coverage.

Checked: Persists buy-level context on create_media_buy via structuredClone (platform.ts:528), echoes it unchanged on get_media_buys and omits when absent (platform.ts:648), and leaves update_media_buy's operation-level context handling untouched. Confined to the training-agent inventory simulator — no static/schemas/source/** surface touched, so no changeset required and no schema↔docs coherence concern. Mirrors the already-merged package-context pattern (#9143) and the wirePackage read-back convention. Test coverage spans all four cases.

Decision trace: no critical/high findings (row 1 n/a); gated_paths false (row 2 n/a); high_risk false, no deletions/modifications triggers (rows 3–5 n/a); no prior escalation (row 6 n/a); no no-auto-approve team match (row 7 n/a); zero medium findings (row 8 n/a). Falls through to row 9 — approve. Note: review_decision is REVIEW_REQUIRED but gated_paths is false, so row 2 does not apply.

@bokelley
bokelley merged commit 4e93a33 into main Nov 21, 2026
55 checks passed
@bokelley
bokelley deleted the fix/inventory-buy-context branch November 21, 2026 03:41
KonstantinMirin added a commit to KonstantinMirin/adcp that referenced this pull request Nov 21, 2026
…9147, adcontextprotocol#9148)

No conflicts. Two files changed on both sides, and git's merge keeps both:
- server/src/training-agent/state.ts: this branch's narrow
  `@adcp/sdk/server` import, plus main's session merge for concurrent
  requests.
- server/tests/unit/training-agent-inventory-tenants.test.ts: this branch's
  top-level router import, loopback listener and per-test clock reset, plus
  main's media buy context test, in a different describe block.

Resolution ledger:
- mechanical: none
- semantic: none; the two auto-merged files above were read, and they keep
  both sides' changes

Check: typecheck passes, and the full server unit suite passes
(867 files, 14,704 tests, 31 skipped; 69 s at load 60-100).
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