Skip to content

Commit e37c095

Browse files
authored
Merge pull request #43 from adcontextprotocol/fix/context-field-for-custom-injected-types
fix: context field for custom injected types
2 parents 6c67f02 + b8296e5 commit e37c095

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

scripts/generate_models_simple.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class PreviewCreativeRequest(BaseModel):
535535
536536
# Output format (applies to both modes)
537537
output_format: Literal["url", "html"] | None = Field(default="url", description="Output format: 'url' for iframe URLs, 'html' for direct embedding")
538-
538+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
539539
540540
class PreviewCreativeResponse(BaseModel):
541541
"""Response containing preview links for one or more creatives. Format matches the request: single preview response for single requests, batch results for batch requests."""
@@ -547,6 +547,7 @@ class PreviewCreativeResponse(BaseModel):
547547
548548
# Batch mode field
549549
results: list[dict[str, Any]] | None = Field(default=None, description="Array of preview results for batch processing")
550+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
550551
551552
552553
# ============================================================================
@@ -564,13 +565,13 @@ class ActivateSignalSuccess(BaseModel):
564565
)
565566
estimated_activation_duration_minutes: float | None = None
566567
deployed_at: str | None = None
567-
568+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
568569
569570
class ActivateSignalError(BaseModel):
570571
"""Failed signal activation response"""
571572
572573
errors: list[Error] = Field(description="Task-specific errors and warnings")
573-
574+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
574575
575576
# Override the generated ActivateSignalResponse type alias
576577
ActivateSignalResponse = ActivateSignalSuccess | ActivateSignalError
@@ -588,12 +589,14 @@ class CreateMediaBuySuccess(BaseModel):
588589
None,
589590
description="ISO 8601 date when creatives must be provided for launch",
590591
)
592+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
591593
592594
593595
class CreateMediaBuyError(BaseModel):
594596
"""Failed media buy creation response"""
595597
596598
errors: list[Error] = Field(description="Task-specific errors and warnings")
599+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
597600
598601
599602
# Override the generated CreateMediaBuyResponse type alias
@@ -608,13 +611,14 @@ class UpdateMediaBuySuccess(BaseModel):
608611
packages: list[Package] = Field(
609612
description="Array of updated packages reflecting the changes"
610613
)
614+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
611615
612616
613617
class UpdateMediaBuyError(BaseModel):
614618
"""Failed media buy update response"""
615619
616620
errors: list[Error] = Field(description="Task-specific errors and warnings")
617-
621+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
618622
619623
# Override the generated UpdateMediaBuyResponse type alias
620624
UpdateMediaBuyResponse = UpdateMediaBuySuccess | UpdateMediaBuyError
@@ -626,13 +630,14 @@ class SyncCreativesSuccess(BaseModel):
626630
assignments: list[CreativeAssignment] = Field(
627631
description="Array of creative assignments with updated status"
628632
)
633+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
629634
630635
631636
class SyncCreativesError(BaseModel):
632637
"""Failed creative sync response"""
633638
634639
errors: list[Error] = Field(description="Task-specific errors and warnings")
635-
640+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
636641
637642
# Override the generated SyncCreativesResponse type alias
638643
SyncCreativesResponse = SyncCreativesSuccess | SyncCreativesError

src/adcp/types/generated.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ class PreviewCreativeRequest(BaseModel):
981981

982982
# Output format (applies to both modes)
983983
output_format: Literal["url", "html"] | None = Field(default="url", description="Output format: 'url' for iframe URLs, 'html' for direct embedding")
984-
984+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
985985

986986
class PreviewCreativeResponse(BaseModel):
987987
"""Response containing preview links for one or more creatives. Format matches the request: single preview response for single requests, batch results for batch requests."""
@@ -993,6 +993,7 @@ class PreviewCreativeResponse(BaseModel):
993993

994994
# Batch mode field
995995
results: list[dict[str, Any]] | None = Field(default=None, description="Array of preview results for batch processing")
996+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
996997

997998

998999
# ============================================================================
@@ -1010,13 +1011,13 @@ class ActivateSignalSuccess(BaseModel):
10101011
)
10111012
estimated_activation_duration_minutes: float | None = None
10121013
deployed_at: str | None = None
1013-
1014+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10141015

10151016
class ActivateSignalError(BaseModel):
10161017
"""Failed signal activation response"""
10171018

10181019
errors: list[Error] = Field(description="Task-specific errors and warnings")
1019-
1020+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10201021

10211022
# Override the generated ActivateSignalResponse type alias
10221023
ActivateSignalResponse = ActivateSignalSuccess | ActivateSignalError
@@ -1034,12 +1035,14 @@ class CreateMediaBuySuccess(BaseModel):
10341035
None,
10351036
description="ISO 8601 date when creatives must be provided for launch",
10361037
)
1038+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10371039

10381040

10391041
class CreateMediaBuyError(BaseModel):
10401042
"""Failed media buy creation response"""
10411043

10421044
errors: list[Error] = Field(description="Task-specific errors and warnings")
1045+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10431046

10441047

10451048
# Override the generated CreateMediaBuyResponse type alias
@@ -1054,13 +1057,14 @@ class UpdateMediaBuySuccess(BaseModel):
10541057
packages: list[Package] = Field(
10551058
description="Array of updated packages reflecting the changes"
10561059
)
1060+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10571061

10581062

10591063
class UpdateMediaBuyError(BaseModel):
10601064
"""Failed media buy update response"""
10611065

10621066
errors: list[Error] = Field(description="Task-specific errors and warnings")
1063-
1067+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10641068

10651069
# Override the generated UpdateMediaBuyResponse type alias
10661070
UpdateMediaBuyResponse = UpdateMediaBuySuccess | UpdateMediaBuyError
@@ -1072,13 +1076,14 @@ class SyncCreativesSuccess(BaseModel):
10721076
assignments: list[CreativeAssignment] = Field(
10731077
description="Array of creative assignments with updated status"
10741078
)
1079+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10751080

10761081

10771082
class SyncCreativesError(BaseModel):
10781083
"""Failed creative sync response"""
10791084

10801085
errors: list[Error] = Field(description="Task-specific errors and warnings")
1081-
1086+
context: dict[str, Any] | None = Field(None, description="Initiator-provided context echoed inside the task payload. Opaque metadata such as UI/session hints, correlation tokens, or tracking identifiers.")
10821087

10831088
# Override the generated SyncCreativesResponse type alias
10841089
SyncCreativesResponse = SyncCreativesSuccess | SyncCreativesError

src/adcp/utils/preview_cache.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ async def get_preview_data_for_manifest(
7474

7575
try:
7676
request = PreviewCreativeRequest(
77-
format_id=format_id, creative_manifest=manifest, inputs=None, template_id=None
77+
format_id=format_id,
78+
creative_manifest=manifest,
79+
inputs=None,
80+
template_id=None,
81+
context=None
7882
)
7983
result = await self.creative_agent_client.preview_creative(request)
8084

@@ -164,6 +168,7 @@ async def get_preview_data_batch(
164168
batch_request = PreviewCreativeRequest(
165169
requests=chunk_requests,
166170
output_format=output_format, # type: ignore[arg-type]
171+
context=None,
167172
)
168173
result = await self.creative_agent_client.preview_creative(batch_request)
169174

0 commit comments

Comments
 (0)