-
Notifications
You must be signed in to change notification settings - Fork 51
fix: A2A top-level failures return failed Task with AdCP envelope, not JSON-RPC InternalError #1547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
5657f80
8d78cb7
8fca519
e6ef756
7d540d0
a5248fe
c51e76c
51d7b33
4a5ee33
1bc4185
acfe455
8ae774c
a5132c9
fe4c23d
5a23a65
176a5d4
0c10422
d037cc0
ee13a6d
ea44fe7
e9c2514
2428449
daacade
c806db2
87b5141
a764510
f300986
4400d1b
b466601
0f75f1f
34fe71f
cd7c087
75fdf24
6c07d8b
5b5d799
dc59b0f
8e3f84c
75fc3d0
1b75743
17d774c
6f287d3
2c37087
e3bf24e
e29a490
5e99d68
5bf1821
832aaba
41cdfae
bd0545f
b1b2076
c8ca35a
78ba8c4
5d266a8
6e08548
34d3c3a
c55c904
8284a90
c005712
269ea52
4395a92
32e7aa9
806e52f
cfdeb1e
99f4ff8
c0daf64
98ace2d
090bbe6
b13146e
48989f7
86edccc
d7abf17
19bb1a8
0a6c467
e0e40f4
916688e
8350ba3
33bb1f2
47d6c76
c945a39
b031a17
ee8743b
63cbf33
22c1c72
95d6065
33b8fea
e771533
8f11cdc
5b41082
61093b1
dc1dc97
a2bdd62
3e52582
27803bf
a01544f
5af3f4f
540dd0a
7d7e8ca
335fe38
f047bd6
685ed0c
d91fc38
a0a6562
ce45f9a
e7ec1cb
bf48d5c
c108982
c6c92b8
2985cf6
fe19e95
d209eb0
5e53f0c
841ced9
21001c5
c4e2506
1dd5280
9deda75
4889c1a
13483b2
399bb3c
97a6976
6756c3e
5abd6af
a436d04
ee70d23
edb898b
2dfe3d7
562364e
2b59b0d
cf05bb4
3ab463a
c3b6a10
e08193d
97ec54f
649ed61
8cceed3
7e3c9e1
c68dc41
c0d7d2a
9eaa7a1
17a0c29
c456e75
dea3df8
80cde69
5b9f3a2
e4293de
1bf9718
00ca307
475f87b
6b1a47e
0067454
a52f1ac
fec0a3b
d82b3a3
e36919d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "src": 36, | ||
| "tests": 89, | ||
| "tests": 88, | ||
| "scripts": 0 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,9 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
| from unittest.mock import MagicMock | ||
|
|
||
| from pytest_bdd import given, parsers, then, when | ||
|
|
||
| from tests.bdd.steps._harness_db import db_session as _db_session | ||
|
|
@@ -61,6 +64,12 @@ def given_valid_request(ctx: dict) -> None: | |
| ctx.setdefault("account_ref", None) | ||
|
|
||
|
|
||
| @given("an authenticated buyer") | ||
| def given_authenticated_buyer(ctx: dict) -> None: | ||
| """Record that this scenario uses the harness-created buyer identity.""" | ||
| ctx["has_auth"] = True | ||
|
|
||
|
|
||
| @given(parsers.parse('a valid create_media_buy request with account "{account_id}"')) | ||
| def given_request_with_account(ctx: dict, account_id: str) -> None: | ||
| """Set up a create_media_buy request with account (short form).""" | ||
|
|
@@ -187,6 +196,47 @@ def given_account_active(ctx: dict) -> None: | |
| AgentAccountAccessFactory(tenant_id=tenant.tenant_id, principal=principal, account=account) | ||
|
|
||
|
|
||
| @when(parsers.parse('the buyer sends a natural-language "{request_text}" request')) | ||
| def when_buyer_sends_nl_a2a_request(ctx: dict, request_text: str) -> None: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This when-step hand-builds
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [SHOULD-FIX] Two separable points here. The read half is honest — On the dispatch bypass: the stated cost — that NL dispatch is "a genuinely new dispatch primitive, not a signature change" — does not hold up. A throwaway prototype at this head is three files, +27/-51, a net 24 lines deleted: an Also worth knowing, since the hand-built |
||
| """Drive real A2A ``on_message_send`` with a natural-language text part.""" | ||
| from a2a.server.routes.common import ServerCallContext | ||
| from a2a.types import Task, TaskState | ||
|
|
||
| from src.a2a_server.adcp_a2a_server import AdCPRequestHandler | ||
| from src.core.config_loader import set_current_tenant | ||
| from src.core.exceptions import AdCPError | ||
| from tests.a2a_helpers import make_nl_send_message_request | ||
| from tests.harness._base import _envelope_to_adcp_error | ||
| from tests.harness.transport import Transport | ||
| from tests.utils.a2a_helpers import extract_data_from_artifact | ||
|
|
||
| env = ctx["env"] | ||
| identity = env.identity_for(Transport.A2A) | ||
| set_current_tenant(identity.tenant) | ||
|
|
||
| handler = AdCPRequestHandler() | ||
| handler._get_auth_token = MagicMock(return_value=identity.auth_token) | ||
| handler._resolve_a2a_identity = MagicMock(return_value=identity) | ||
|
|
||
| async def _call() -> Task: | ||
| return await handler.on_message_send(make_nl_send_message_request(request_text), ServerCallContext()) | ||
|
|
||
| try: | ||
| result = asyncio.run(_call()) | ||
| except Exception as exc: | ||
| ctx["error"] = exc | ||
| return | ||
|
|
||
| ctx["response"] = result | ||
| if result.status.state == TaskState.TASK_STATE_FAILED: | ||
| if not result.artifacts: | ||
| ctx["error"] = AdCPError(f"A2A task failed without artifacts: {result.status}") | ||
| return | ||
| envelope = extract_data_from_artifact(result.artifacts[0]) | ||
|
numarasSigmaSoftware marked this conversation as resolved.
Outdated
|
||
| ctx["wire_error_envelope"] = envelope | ||
| ctx["error"] = _envelope_to_adcp_error(envelope, fallback_message="A2A natural-language request failed") | ||
|
|
||
|
|
||
| @given(parsers.parse("a create_media_buy request with account configuration {partition}")) | ||
| def given_request_with_partition(ctx: dict, partition: str) -> None: | ||
| """Set up request based on partition name (for Scenario Outline tables).""" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.