Skip to content

fix(client): unblock v2.5 sellers — brand alias type guard + response validation version pin - #1137

Merged
bokelley merged 1 commit into
mainfrom
bokelley/v2.5-seller-fixes
May 1, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/v2.5-seller-fixes

Conversation

@bokelley

@bokelley bokelley commented May 1, 2026

Copy link
Copy Markdown
Contributor

Two bugs surfaced by smoke-testing the live Wonderstruck v2.5 sales agent. Both silently broke every v3 buyer calling a v2.5 seller. Highest-impact production fixes from the v2.5 stack — without these, no v3-buyer SDK call against a v2.5 seller works end-to-end.

Findings

After the foundation work (#1121, #1123, #1133, #1134) landed/queued, ran a read-only smoke against Wonderstruck (scripts/smoke-wonderstruck-v2-5.ts). Hit two issues immediately.

Bug 1 — brand_manifest → brand aliasing dropped string into object slot

SingleAgentClient's field-stripping path (added in 43e6c972) renames brand_manifest (URL string from v2 adapter) back to brand whenever the agent's tool schema declares brand. Without checking the destination's declared type. v2.5 sellers declare brand as a BrandReference object (anyOf [{type:'object',required:['domain']}, {type:'null'}]). The string landed in the object slot and Wonderstruck rejected:

mcp_error: 1 validation error for call[get_products]
brand
  Input should be a valid dictionary or instance of BrandReference
  [type=model_type, input_value='https://wonderstruck.fm', input_type=str]

Fix: valueMatchesSchemaType helper recurses anyOf/oneOf and applies the alias only when the value's runtime type matches the declared shape. Legacy v2 sellers (brand: type:'string') still route correctly; v2.5 sellers (brand: type:'object') skip the alias.

Bug 2 — Response validation pinned to v3 even for v2 sellers

TaskExecutor.validateResponseSchema always passed this.config.adcpVersion (the SDK-pinned v3) to validateIncomingResponse. v2.5 sellers correctly returned v2.5-shaped responses; SDK falsely rejected:

Schema validation failed for get_products: [
  '/products/0/reporting_capabilities: must have required property reporting_capabilities',
  '/products/0/pricing_options: must NOT have fewer than 1 items'
]

Fix: derive validationVersion from lastKnownServerVersion. v2 → 'v2.5'; otherwise default. Symmetric to the post-adapter request pass added in #1121.

Net effect

Together these unblock real-world v3-buyer ↔ v2.5-seller traffic:

Tool Before After
get_products against Wonderstruck seller rejects (bug 1) OR response rejected (bug 2) works, products returned
list_creative_formats response rejected as malformed v3 works, formats returned

Real seller drift (Wonderstruck's pricing_options minItems / supported_macros oneOf divergences) still surfaces via result.debug_logs per #1133, so adopters see real spec deviations without the SDK conflating them with version-mismatch artifacts.

Test plan

  • test/lib/v2-5-seller-fixes.test.js (3 tests):
    • Alias skipped when v2.5 seller declares brand: anyOf[object,null] and adapter produces a URL string.
    • Alias still fires when legacy v2 seller declares brand: type:'string' (no regression for the original 43e6c972 use case).
    • validateResponse with version='v2.5' validates clean on a v2.5-shaped payload.
  • npm run test:lib — 5507 pass / 7 pre-existing skipped / 0 fail (2 cancelled are pre-existing CLI test flakes; pass clean in isolation).
  • Live smoke against Wonderstruck with NODE_ENV=production: 3/6 read-only tools work end-to-end with drift visible in result.debug_logs. The other 3 fail for unrelated reasons (auth header, feature gate, undefined-return) — filed as separate issues.

Out of scope (filed for follow-up)

  • get_adcp_capabilities against v2.5 sellers always fails v3 validation; SDK silently falls back to "v2 synthetic capabilities." Worse, under prod NODE_ENV the warn-mode hides the failure entirely and SDK declares v2.5 sellers as v3.
  • list_creative_formats supported_macros[*] fails v2.5 oneOf with ~99 issues per call. v2.5 schema vs Wonderstruck shape mismatch.
  • list_authorized_properties returns undefined and crashes the caller. Method shape needs investigation.

🤖 Generated with Claude Code

…inned response validation

Two bugs surfaced by smoking the live Wonderstruck v2.5 sales agent.
Both silently broke every v3 buyer calling a v2.5 seller.

1. SingleAgentClient field-stripping aliased brand_manifest → brand
   without checking the destination's declared type. v2.5 sellers
   declare brand as anyOf[object, null] (BrandReference). The v2 adapter
   produces brand_manifest: 'https://...' (string). Aliasing dropped the
   string into the object slot and Wonderstruck rejected with `Input
   should be a valid dictionary or instance of BrandReference`.

   Fix: valueMatchesSchemaType helper introspects the destination's
   declared shape (recursing into anyOf/oneOf) and only applies the
   alias when the value's runtime type is compatible. Legacy v2 sellers
   (brand: type:'string') still route correctly; v2.5 sellers
   (brand: type:'object') skip the alias and let field-stripping drop
   the v2-shaped value cleanly.

2. TaskExecutor.validateResponseSchema always validated against
   this.config.adcpVersion (v3). v2.5 sellers return correctly-shaped
   v2.5 responses; SDK falsely rejected them as malformed v3 with
   errors like `pricing_options must NOT have fewer than 1 items` and
   `reporting_capabilities required`.

   Fix: derive validationVersion from lastKnownServerVersion. v2 →
   validate against 'v2.5'; otherwise default. Symmetric to the
   post-adapter request pass from #1121.

Together: every v3 buyer using getProducts against a v2.5 agent now
goes through end-to-end. Drift between v2.5 spec and seller behavior
still surfaces via result.debug_logs (per #1133) so adopters see real
seller deviations without the SDK conflating them with version
artifacts.

Surfaced by scripts/smoke-wonderstruck-v2-5.ts (not committed; lives in
.context for ongoing testing). Five follow-up issues filed in tracker
for capability-detection drift, supported_macros oneOf cascade, and
list_authorized_properties undefined-return.

Tests: 3 new tests pin both fixes. v2.5 seller schema (anyOf object|null)
gets the alias guard; legacy string-typed brand still aliases. Direct
seam test on validateResponse with version='v2.5' confirms v2.5 shape
validates clean. 5507 lib tests pass / 7 pre-existing skipped / 0 fail
(2 cancelled are pre-existing CLI test flakes, pass clean in isolation).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley force-pushed the bokelley/v2.5-seller-fixes branch from df04566 to 51ce790 Compare May 1, 2026 09:11
@bokelley
bokelley merged commit 995de01 into main May 1, 2026
9 checks passed
bokelley added a commit that referenced this pull request May 1, 2026
scripts/smoke-wonderstruck-v2-5.ts — read-only harness that calls the
Wonderstruck v2.5 MCP agent through the SDK and reports any drift the
post-adapter validation pass observes via result.debug_logs. Surfaced
the three issues filed today: #1148 (list_authorized_properties throws),
#1149 (null envelope fields rejected), #1150 (response validation
should be warn-only).

scripts/probe-wonderstruck-brand-schema.ts — inspects tools/list to
pull the actual brand declaration from the agent's tool schema cache.
Used while writing the v2.5 brand-alias type guard in #1137.

Both scripts read SALES_AGENTS_CONFIG from .env. No tests or new
dependencies. Live under scripts/ alongside generate-types and other
dev utilities.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley added a commit that referenced this pull request May 1, 2026
…1150 (#1172)

Client-side response validation previously defaulted to strict in
dev/test and warn in prod. With #1137's version-pinned validator, that
asymmetry made v2.5 sellers' perfectly valid v2.5-shaped responses
strictly fail in dev/test even though they'd succeed in prod —
buyers got `0 products` with the actual data discarded.

Flip the dev/test default to match prod: warn everywhere. Drift still
surfaces via `result.debug_logs` (the channel #1133 plumbed). Buyers
who want hard-stop validation opt in via
`validation: { responses: 'strict' }` — explicit config still wins.

Server-side `createAdcpServer` is unchanged — handler-side validation
stays strict in dev/test/CI to catch our own handler-output bugs.

Side fix: update `adapter-v2-5-conformance.test.js` to match the
post-#1118 sync_creatives drift surface; pinned the failing pointer
to `/creatives/0/assets/asset_type` and noted that #1118's flatten
may have inverted the v2.5 schema expectation (creative-asset.json
declares `assets` as a role-keyed manifest object, same as v3 — the
flat shape #1118 now emits fails patternProperties validation). Worth
a follow-up to confirm the seller-runtime expectation vs the spec.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
bokelley added a commit that referenced this pull request May 1, 2026
scripts/smoke-wonderstruck-v2-5.ts — read-only harness that calls the
Wonderstruck v2.5 MCP agent through the SDK and reports any drift the
post-adapter validation pass observes via result.debug_logs. Surfaced
the three issues filed today: #1148 (list_authorized_properties throws),
#1149 (null envelope fields rejected), #1150 (response validation
should be warn-only).

scripts/probe-wonderstruck-brand-schema.ts — inspects tools/list to
pull the actual brand declaration from the agent's tool schema cache.
Used while writing the v2.5 brand-alias type guard in #1137.

Both scripts read SALES_AGENTS_CONFIG from .env. No tests or new
dependencies. Live under scripts/ alongside generate-types and other
dev utilities.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley added a commit that referenced this pull request May 1, 2026
* chore(scripts): commit v2.5 drift smoke + brand-schema probe

scripts/smoke-wonderstruck-v2-5.ts — read-only harness that calls the
Wonderstruck v2.5 MCP agent through the SDK and reports any drift the
post-adapter validation pass observes via result.debug_logs. Surfaced
the three issues filed today: #1148 (list_authorized_properties throws),
#1149 (null envelope fields rejected), #1150 (response validation
should be warn-only).

scripts/probe-wonderstruck-brand-schema.ts — inspects tools/list to
pull the actual brand declaration from the agent's tool schema cache.
Used while writing the v2.5 brand-alias type guard in #1137.

Both scripts read SALES_AGENTS_CONFIG from .env. No tests or new
dependencies. Live under scripts/ alongside generate-types and other
dev utilities.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* chore: empty changeset — smoke harness scripts are not published

* fix(scripts): drop dead listAuthorizedProperties probe — v3 uses getCapabilities

The smoke probe was calling agent.listAuthorizedProperties via optional
chaining, which returned undefined (the method doesn't exist on
AgentClient — list_authorized_properties was replaced by getCapabilities()
in v3, see property-crawler.ts:141). Replaced with a direct
executeTask('list_authorized_properties') probe so v2.5 sellers that
still expose the underlying tool can be tested.

Closes #1148.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions github-actions Bot mentioned this pull request May 1, 2026
bokelley added a commit that referenced this pull request May 1, 2026
…jv (#1149) (#1158)

* fix(validation): strip null on optional v2.x envelope fields before Ajv

v2.5 sellers (Pydantic-origin) emit errors/context/ext as null instead
of omitting them. The v2.5 schemas declare these as type:array/object
without a null union, so Ajv spuriously rejects them post-#1137's
version-pinned validator.

Adds stripEnvelopeNulls() that removes top-level optional fields with
null values and non-nullable declared types before the Ajv pass. Gated
to v2.x bundles via parseAdcpMajorVersion() — v3 errors is required on
failure branches and must not be silently stripped.

Closes #1149

https://claude.ai/code/session_01H9wytvzmHPVPdCPUYZVCte

* fix(test): add v2.5-required fields to null-stripping fixture

minimalGetProductsResponse needs delivery_measurement (top-level required)
and is_fixed: true on the cpm pricing option (const discriminator) for the
v2.5 schema to pass without stripping. Verified against upstream schemas
in adcontextprotocol/[email protected] dist/schemas/2.5.3/.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
@github-actions github-actions Bot mentioned this pull request May 1, 2026
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