Repository navigation
fix(training-agent): echo the media buy context on inventory get_media_buys - #9148
Conversation
…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]>
There was a problem hiding this comment.
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.
…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).
Summary
The inventory tenants (
/inventory-adserver,/inventory-content) dropped the media-buy-levelcontextafter creation:create_media_buyechoed it on its response; the SDK does that.get_media_buysreturned each buy without it.core/media-buy.jsonsays sellers MUST include persisted context on read surfaces such asget_media_buyswhen the buy was created through AdCP with context.Where it showed up. The Apostra simulator's staging certification run 171 failed
context_echoon all four live/inventory-adserverbuys. The run comparesmedia_buys[].contextwith the{ storefront_media_buy_id }its create sent.#9143 fixed the same gap for package context; this fixes it for the buy.
Change
create_media_buystores the request's top-levelcontexton the buy record, as an opaque structured clone that is never parsed.get_media_buysreturns it unchanged on each buy, and omits it for a buy created without one.update_media_buykeeps echoing the update request's own operation-levelcontext, asupdate-media-buy-response.jsonspecifies. It never replaces the buy's context, and a test pins that.Storyboard coverage
protocols/media-buy/index.yamlalready asserts this:check_buy_statuschecksmedia_buys[0].context.correlation_id. On the inventory tenants, though, everymedia_buy_sellerstep skips asfixture_seed_unsupported(0P / 16S). Their controller serves noseed_*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
training-agent-inventory-tenants.test.ts: context echoed on create, onget_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_buysreturned nocontext) and passes after.🤖 Generated with Claude Code