Skip to content

fix(x402): discovery filters out all v2 resources (12,915 of 14,668) - #1400

Open
aoleg8525-ai wants to merge 1 commit into
coinbase:mainfrom
aoleg8525-ai:fix/x402-discovery-v2-description
Open

fix(x402): discovery filters out all v2 resources (12,915 of 14,668)#1400
aoleg8525-ai wants to merge 1 commit into
coinbase:mainfrom
aoleg8525-ai:fix/x402-discovery-v2-description

Conversation

@aoleg8525-ai

Copy link
Copy Markdown

Description

discover_x402_services currently returns no v2 resources at all.

getResourceDescription (action-providers/x402/utils.ts) reads v2 descriptions
only from metadata.description, but the CDP discovery API returns the description
at the top level of the resource. filterByDescription therefore sees an empty
string for every v2 resource and filters all of them out, so agents only ever see
v1 results.

Measured against the default facilitator (cdp) on 2026-08-05:

resources
total in /discovery/resources 14 668
x402 v2 13 074
v2 carrying metadata.description (what the filter reads) 0
v2 carrying a top-level description (what the API returns) 12 915
surviving filterByDescription today 1 594 (10.9 %) — all v1

Reproduce in a minute (no key needed):

node -e '
const B="https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources";
(async()=>{const all=[];let o=0,t=null;
 while(true){const j=await (await fetch(`${B}?limit=1000&offset=${o}`)).json();
  all.push(...j.items);t=j.pagination.total;o+=j.items.length;if(o>=t)break;}
 const v2=all.filter(r=>r.x402Version===2);
 console.log("total",all.length,"| v2",v2.length,
  "| v2 with metadata.description",v2.filter(r=>r.metadata?.description).length,
  "| v2 with top-level description",v2.filter(r=>r.description).length);})()'

The fix reads the top-level field first and keeps metadata.description as a
fallback, so both shapes work and v1 handling is untouched.

Tests

Added action-providers/x402/utils.test.ts (8 cases) covering both shapes and the
regressions around them:

  • v2 with a top-level description → kept (fails before this change)
  • v2 with metadata.description → kept (backward compatibility)
  • v2 with both → top-level wins, and filterByKeyword matches it
  • v2 with neither → dropped
  • the "Access to protected content" placeholder → dropped
  • v1 with accepts[].description → kept, unchanged
Before: Tests: 3 failed, 5 passed, 8 total
After:  Tests: 8 passed, 8 total

Run:

cd typescript/agentkit && npx jest --testMatch='**/x402/utils.test.ts'

eslint, prettier --check and tsc --noEmit are clean on the touched files.
A patch changeset is included.

Note on the manual chatbot walkthrough the template asks for: the change is inside
a pure filter with no wallet or network interaction, and the discovery counts above
come from the live default facilitator rather than a local run.

@cb-heimdall

cb-heimdall commented Aug 5, 2026

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions github-actions Bot added documentation Improvements or additions to documentation action provider New action provider typescript labels Aug 5, 2026
@aoleg8525-ai
aoleg8525-ai force-pushed the fix/x402-discovery-v2-description branch from 87be039 to 0e86317 Compare August 5, 2026 08:21
The discovery filter read v2 descriptions only from metadata.description.
The CDP discovery API returns them at the top level, so filterByDescription
dropped every v2 resource and discover_x402_services returned v1 results only.

Reading the top-level field first (metadata.description kept as a fallback)
restores discovery for v2 resources. v1 handling is unchanged.

Signed-off-by: Oleg <oleg@personal.local>
@aoleg8525-ai
aoleg8525-ai force-pushed the fix/x402-discovery-v2-description branch from 0e86317 to dc15758 Compare August 5, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action provider New action provider documentation Improvements or additions to documentation typescript

Development

Successfully merging this pull request may close these issues.

2 participants