Skip to content

Commit 7649d0c

Browse files
committed
Update usage in library
1 parent 0028bda commit 7649d0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+499
-489
lines changed

src/a2a/client/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def create_text_message_object(
1515
content: The text content of the message. Defaults to an empty string.
1616
1717
Returns:
18-
A `Message` object with a new UUID messageId.
18+
A `Message` object with a new UUID message_id.
1919
"""
2020
return Message(
21-
role=role, parts=[Part(TextPart(text=content))], messageId=str(uuid4())
21+
role=role, parts=[Part(TextPart(text=content))], message_id=str(uuid4())
2222
)

src/a2a/server/agent_execution/context.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def __init__( # noqa: PLR0913
5353
# match the request. Otherwise, create them
5454
if self._params:
5555
if task_id:
56-
self._params.message.taskId = task_id
56+
self._params.message.task_id = task_id
5757
if task and task.id != task_id:
5858
raise ServerError(InvalidParamsError(message='bad task id'))
5959
else:
6060
self._check_or_generate_task_id()
6161
if context_id:
62-
self._params.message.contextId = context_id
63-
if task and task.contextId != context_id:
62+
self._params.message.context_id = context_id
63+
if task and task.context_id != context_id:
6464
raise ServerError(
6565
InvalidParamsError(message='bad context id')
6666
)
@@ -148,17 +148,17 @@ def _check_or_generate_task_id(self) -> None:
148148
if not self._params:
149149
return
150150

151-
if not self._task_id and not self._params.message.taskId:
152-
self._params.message.taskId = str(uuid.uuid4())
153-
if self._params.message.taskId:
154-
self._task_id = self._params.message.taskId
151+
if not self._task_id and not self._params.message.task_id:
152+
self._params.message.task_id = str(uuid.uuid4())
153+
if self._params.message.task_id:
154+
self._task_id = self._params.message.task_id
155155

156156
def _check_or_generate_context_id(self) -> None:
157157
"""Ensures a context ID is present, generating one if necessary."""
158158
if not self._params:
159159
return
160160

161-
if not self._context_id and not self._params.message.contextId:
162-
self._params.message.contextId = str(uuid.uuid4())
163-
if self._params.message.contextId:
164-
self._context_id = self._params.message.contextId
161+
if not self._context_id and not self._params.message.context_id:
162+
self._params.message.context_id = str(uuid.uuid4())
163+
if self._params.message.context_id:
164+
self._context_id = self._params.message.context_id

src/a2a/server/agent_execution/simple_request_context_builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(
1818
1919
Args:
2020
should_populate_referred_tasks: If True, the builder will fetch tasks
21-
referenced in `params.message.referenceTaskIds` and populate the
21+
referenced in `params.message.reference_task_ids` and populate the
2222
`related_tasks` field in the RequestContext. Defaults to False.
2323
task_store: The TaskStore instance to use for fetching referred tasks.
2424
Required if `should_populate_referred_tasks` is True.
@@ -38,7 +38,7 @@ async def build(
3838
3939
This method assembles the RequestContext object. If the builder was
4040
initialized with `should_populate_referred_tasks=True`, it fetches all tasks
41-
referenced in `params.message.referenceTaskIds` from the `task_store`.
41+
referenced in `params.message.reference_task_ids` from the `task_store`.
4242
4343
Args:
4444
params: The parameters of the incoming message send request.
@@ -57,12 +57,12 @@ async def build(
5757
self._task_store
5858
and self._should_populate_referred_tasks
5959
and params
60-
and params.message.referenceTaskIds
60+
and params.message.reference_task_ids
6161
):
6262
tasks = await asyncio.gather(
6363
*[
6464
self._task_store.get(task_id)
65-
for task_id in params.message.referenceTaskIds
65+
for task_id in params.message.reference_task_ids
6666
]
6767
)
6868
related_tasks = [x for x in tasks if x is not None]

src/a2a/server/apps/jsonrpc/fastapi_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def add_routes_to_app(
8989
)(self._handle_requests)
9090
app.get(agent_card_url)(self._handle_get_agent_card)
9191

92-
if self.agent_card.supportsAuthenticatedExtendedCard:
92+
if self.agent_card.supports_authenticated_extended_card:
9393
app.get(extended_agent_card_url)(
9494
self._handle_get_authenticated_extended_agent_card
9595
)

src/a2a/server/apps/jsonrpc/jsonrpc_app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ def __init__(
135135
agent_card=agent_card, request_handler=http_handler
136136
)
137137
if (
138-
self.agent_card.supportsAuthenticatedExtendedCard
138+
self.agent_card.supports_authenticated_extended_card
139139
and self.extended_agent_card is None
140140
):
141141
logger.error(
142-
'AgentCard.supportsAuthenticatedExtendedCard is True, but no extended_agent_card was provided. The /agent/authenticatedExtendedCard endpoint will return 404.'
142+
'AgentCard.supports_authenticated_extended_card is True, but no extended_agent_card was provided. The /agent/authenticatedExtendedCard endpoint will return 404.'
143143
)
144144
self._context_builder = context_builder or DefaultCallContextBuilder()
145145

@@ -421,7 +421,7 @@ async def _handle_get_authenticated_extended_agent_card(
421421
self, request: Request
422422
) -> JSONResponse:
423423
"""Handles GET requests for the authenticated extended agent card."""
424-
if not self.agent_card.supportsAuthenticatedExtendedCard:
424+
if not self.agent_card.supports_authenticated_extended_card:
425425
return JSONResponse(
426426
{'error': 'Extended agent card not supported or not enabled.'},
427427
status_code=404,
@@ -435,7 +435,7 @@ async def _handle_get_authenticated_extended_agent_card(
435435
by_alias=True,
436436
)
437437
)
438-
# If supportsAuthenticatedExtendedCard is true, but no specific
438+
# If supports_authenticated_extended_card is true, but no specific
439439
# extended_agent_card was provided during server initialization,
440440
# return a 404
441441
return JSONResponse(

src/a2a/server/apps/jsonrpc/starlette_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def routes(
8686
),
8787
]
8888

89-
if self.agent_card.supportsAuthenticatedExtendedCard:
89+
if self.agent_card.supports_authenticated_extended_card:
9090
app_routes.append(
9191
Route(
9292
extended_agent_card_url,

src/a2a/server/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class TaskMixin:
123123
"""Mixin providing standard task columns with proper type handling."""
124124

125125
id: Mapped[str] = mapped_column(String(36), primary_key=True, index=True)
126-
contextId: Mapped[str] = mapped_column(String(36), nullable=False) # noqa: N815
126+
context_id: Mapped[str] = mapped_column(String(36), nullable=False)
127127
kind: Mapped[str] = mapped_column(
128128
String(16), nullable=False, default='task'
129129
)
@@ -148,12 +148,12 @@ def task_metadata(cls) -> Mapped[dict[str, Any] | None]:
148148
def __repr__(self) -> str:
149149
"""Return a string representation of the task."""
150150
repr_template = (
151-
'<{CLS}(id="{ID}", contextId="{CTX_ID}", status="{STATUS}")>'
151+
'<{CLS}(id="{ID}", context_id="{CTX_ID}", status="{STATUS}")>'
152152
)
153153
return repr_template.format(
154154
CLS=self.__class__.__name__,
155155
ID=self.id,
156-
CTX_ID=self.contextId,
156+
CTX_ID=self.context_id,
157157
STATUS=self.status,
158158
)
159159

@@ -188,11 +188,11 @@ class TaskModel(TaskMixin, base):
188188
@override
189189
def __repr__(self) -> str:
190190
"""Return a string representation of the task."""
191-
repr_template = '<TaskModel[{TABLE}](id="{ID}", contextId="{CTX_ID}", status="{STATUS}")>'
191+
repr_template = '<TaskModel[{TABLE}](id="{ID}", context_id="{CTX_ID}", status="{STATUS}")>'
192192
return repr_template.format(
193193
TABLE=table_name,
194194
ID=self.id,
195-
CTX_ID=self.contextId,
195+
CTX_ID=self.context_id,
196196
STATUS=self.status,
197197
)
198198

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async def on_cancel_task(
126126

127127
task_manager = TaskManager(
128128
task_id=task.id,
129-
context_id=task.contextId,
129+
context_id=task.context_id,
130130
task_store=self.task_store,
131131
initial_message=None,
132132
)
@@ -140,7 +140,7 @@ async def on_cancel_task(
140140
RequestContext(
141141
None,
142142
task_id=task.id,
143-
context_id=task.contextId,
143+
context_id=task.context_id,
144144
task=task,
145145
),
146146
queue,
@@ -184,8 +184,8 @@ async def _setup_message_execution(
184184
"""
185185
# Create task manager and validate existing task
186186
task_manager = TaskManager(
187-
task_id=params.message.taskId,
188-
context_id=params.message.contextId,
187+
task_id=params.message.task_id,
188+
context_id=params.message.context_id,
189189
task_store=self.task_store,
190190
initial_message=params.message,
191191
)
@@ -205,7 +205,7 @@ async def _setup_message_execution(
205205
request_context = await self._request_context_builder.build(
206206
params=params,
207207
task_id=task.id if task else None,
208-
context_id=params.message.contextId,
208+
context_id=params.message.context_id,
209209
task=task,
210210
context=context,
211211
)
@@ -218,10 +218,10 @@ async def _setup_message_execution(
218218
if (
219219
self._push_config_store
220220
and params.configuration
221-
and params.configuration.pushNotificationConfig
221+
and params.configuration.push_notification_config
222222
):
223223
await self._push_config_store.set_info(
224-
task_id, params.configuration.pushNotificationConfig
224+
task_id, params.configuration.push_notification_config
225225
)
226226

227227
queue = await self._queue_manager.create_or_tap(task_id)
@@ -366,13 +366,13 @@ async def on_set_task_push_notification_config(
366366
if not self._push_config_store:
367367
raise ServerError(error=UnsupportedOperationError())
368368

369-
task: Task | None = await self.task_store.get(params.taskId)
369+
task: Task | None = await self.task_store.get(params.task_id)
370370
if not task:
371371
raise ServerError(error=TaskNotFoundError())
372372

373373
await self._push_config_store.set_info(
374-
params.taskId,
375-
params.pushNotificationConfig,
374+
params.task_id,
375+
params.push_notification_config,
376376
)
377377

378378
return params
@@ -404,7 +404,8 @@ async def on_get_task_push_notification_config(
404404
)
405405

406406
return TaskPushNotificationConfig(
407-
taskId=params.id, pushNotificationConfig=push_notification_config[0]
407+
task_id=params.id,
408+
pushNotificationConfig=push_notification_config[0],
408409
)
409410

410411
async def on_resubscribe_to_task(
@@ -430,7 +431,7 @@ async def on_resubscribe_to_task(
430431

431432
task_manager = TaskManager(
432433
task_id=task.id,
433-
context_id=task.contextId,
434+
context_id=task.context_id,
434435
task_store=self.task_store,
435436
initial_message=None,
436437
)
@@ -470,7 +471,7 @@ async def on_list_task_push_notification_config(
470471
for config in push_notification_config_list:
471472
task_push_notification_config.append(
472473
TaskPushNotificationConfig(
473-
taskId=params.id, pushNotificationConfig=config
474+
task_id=params.id, pushNotificationConfig=config
474475
)
475476
)
476477

@@ -493,5 +494,5 @@ async def on_delete_task_push_notification_config(
493494
raise ServerError(error=TaskNotFoundError())
494495

495496
await self._push_config_store.delete_info(
496-
params.id, params.pushNotificationConfigId
497+
params.id, params.push_notification_config_id
497498
)

src/a2a/server/request_handlers/grpc_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ async def GetTaskPushNotificationConfig(
224224
return a2a_pb2.TaskPushNotificationConfig()
225225

226226
@validate(
227-
lambda self: self.agent_card.capabilities.pushNotifications,
227+
lambda self: self.agent_card.capabilities.push_notifications,
228228
'Push notifications are not supported by the agent',
229229
)
230230
async def CreateTaskPushNotificationConfig(

src/a2a/server/request_handlers/jsonrpc_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ async def get_push_notification_config(
255255
)
256256

257257
@validate(
258-
lambda self: self.agent_card.capabilities.pushNotifications,
258+
lambda self: self.agent_card.capabilities.push_notifications,
259259
'Push notifications are not supported by the agent',
260260
)
261261
async def set_push_notification_config(

0 commit comments

Comments
 (0)