Skip to content

Commit 84b5652

Browse files
bokelleyclaude
andcommitted
fix: define FormatId as proper object type per ADCP spec
Problem: FormatId was incorrectly defined as a string type alias, but the ADCP spec requires it to be a structured object with agent_url and id fields. Root Cause: The format-id.json schema was missing from the downloaded schemas, causing the type generator to create a placeholder string type. Solution: - Downloaded format-id.json schema from adcontextprotocol.org - Defined FormatId as proper Pydantic model with agent_url and id fields - Updated tests to use correct FormatId structure: {agent_url, id} This ensures all format references use the structured format ID objects as required by the ADCP specification, enabling proper format resolution across different creative agents. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c9da356 commit 84b5652

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

schemas/cache/1.0.0/format-id.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "/schemas/v1/core/format-id.json",
4+
"title": "Format ID",
5+
"description": "Structured format identifier with agent URL and format name",
6+
"type": "object",
7+
"properties": {
8+
"agent_url": {
9+
"type": "string",
10+
"format": "uri",
11+
"description": "URL of the agent that defines this format (e.g., 'https://creatives.adcontextprotocol.org' for standard formats, or 'https://publisher.com/.well-known/adcp/sales' for custom formats)"
12+
},
13+
"id": {
14+
"type": "string",
15+
"pattern": "^[a-zA-Z0-9_-]+$",
16+
"description": "Format identifier within the agent's namespace (e.g., 'display_300x250', 'video_standard_30s')"
17+
}
18+
},
19+
"required": ["agent_url", "id"],
20+
"additionalProperties": false
21+
}

src/adcp/types/generated.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,31 @@
2222

2323
# These types are referenced in schemas but don't have schema files
2424
# Defining them as type aliases to maintain type safety
25-
FormatId = str
2625
PackageRequest = dict[str, Any]
2726
PushNotificationConfig = dict[str, Any]
2827
ReportingCapabilities = dict[str, Any]
2928

3029

30+
# ============================================================================
31+
# FORMAT ID TYPE (manually defined from spec)
32+
# ============================================================================
33+
34+
class FormatId(BaseModel):
35+
"""
36+
Structured format identifier with agent URL and format name.
37+
38+
Based on https://adcontextprotocol.org/schemas/v1/core/format-id.json
39+
"""
40+
41+
agent_url: str = Field(
42+
description="URL of the agent that defines this format (e.g., 'https://creatives.adcontextprotocol.org' for standard formats, or 'https://publisher.com/.well-known/adcp/sales' for custom formats)"
43+
)
44+
id: str = Field(
45+
pattern="^[a-zA-Z0-9_-]+$",
46+
description="Format identifier within the agent's namespace (e.g., 'display_300x250', 'video_standard_30s')"
47+
)
48+
49+
3150
# ============================================================================
3251
# CORE DOMAIN TYPES
3352
# ============================================================================

tests/test_client.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,18 @@ async def test_list_creative_formats_parses_mcp_response():
257257
formats_data = {
258258
"formats": [
259259
{
260-
"format_id": "https://creative.example.com#banner_300x250",
260+
"format_id": {
261+
"agent_url": "https://creative.example.com",
262+
"id": "banner_300x250"
263+
},
261264
"name": "Medium Rectangle",
262265
"type": "display",
263266
},
264267
{
265-
"format_id": "https://creative.example.com#video_16x9",
268+
"format_id": {
269+
"agent_url": "https://creative.example.com",
270+
"id": "video_16x9"
271+
},
266272
"name": "Video 16:9",
267273
"type": "video",
268274
},
@@ -306,7 +312,10 @@ async def test_list_creative_formats_parses_a2a_response():
306312
formats_data = {
307313
"formats": [
308314
{
309-
"format_id": "https://creative.example.com#native_feed",
315+
"format_id": {
316+
"agent_url": "https://creative.example.com",
317+
"id": "native_feed"
318+
},
310319
"name": "Native Feed Ad",
311320
"type": "native",
312321
}

0 commit comments

Comments
 (0)