Skip to content

Commit 4255e39

Browse files
committed
Update to specification from 0a9f629e801d4ae89f94991fc28afe9429c91cbc
1 parent d585635 commit 4255e39

File tree

4 files changed

+223
-27
lines changed

4 files changed

+223
-27
lines changed

src/a2a/grpc/a2a_pb2.py

Lines changed: 33 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/a2a/grpc/a2a_pb2.pyi

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,34 @@ class GetTaskRequest(_message.Message):
497497
history_length: int
498498
def __init__(self, name: _Optional[str] = ..., history_length: _Optional[int] = ...) -> None: ...
499499

500+
class ListTasksRequest(_message.Message):
501+
__slots__ = ("context_id", "status", "page_size", "page_token", "history_length", "last_updated_time", "include_artifacts")
502+
CONTEXT_ID_FIELD_NUMBER: _ClassVar[int]
503+
STATUS_FIELD_NUMBER: _ClassVar[int]
504+
PAGE_SIZE_FIELD_NUMBER: _ClassVar[int]
505+
PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int]
506+
HISTORY_LENGTH_FIELD_NUMBER: _ClassVar[int]
507+
LAST_UPDATED_TIME_FIELD_NUMBER: _ClassVar[int]
508+
INCLUDE_ARTIFACTS_FIELD_NUMBER: _ClassVar[int]
509+
context_id: str
510+
status: TaskState
511+
page_size: int
512+
page_token: str
513+
history_length: int
514+
last_updated_time: _timestamp_pb2.Timestamp
515+
include_artifacts: bool
516+
def __init__(self, context_id: _Optional[str] = ..., status: _Optional[_Union[TaskState, str]] = ..., page_size: _Optional[int] = ..., page_token: _Optional[str] = ..., history_length: _Optional[int] = ..., last_updated_time: _Optional[_Union[datetime.datetime, _timestamp_pb2.Timestamp, _Mapping]] = ..., include_artifacts: _Optional[bool] = ...) -> None: ...
517+
518+
class ListTasksResponse(_message.Message):
519+
__slots__ = ("tasks", "next_page_token", "total_size")
520+
TASKS_FIELD_NUMBER: _ClassVar[int]
521+
NEXT_PAGE_TOKEN_FIELD_NUMBER: _ClassVar[int]
522+
TOTAL_SIZE_FIELD_NUMBER: _ClassVar[int]
523+
tasks: _containers.RepeatedCompositeFieldContainer[Task]
524+
next_page_token: str
525+
total_size: int
526+
def __init__(self, tasks: _Optional[_Iterable[_Union[Task, _Mapping]]] = ..., next_page_token: _Optional[str] = ..., total_size: _Optional[int] = ...) -> None: ...
527+
500528
class CancelTaskRequest(_message.Message):
501529
__slots__ = ("name",)
502530
NAME_FIELD_NUMBER: _ClassVar[int]

src/a2a/grpc/a2a_pb2_grpc.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def __init__(self, channel):
4040
request_serializer=a2a__pb2.GetTaskRequest.SerializeToString,
4141
response_deserializer=a2a__pb2.Task.FromString,
4242
_registered_method=True)
43+
self.ListTasks = channel.unary_unary(
44+
'/a2a.v1.A2AService/ListTasks',
45+
request_serializer=a2a__pb2.ListTasksRequest.SerializeToString,
46+
response_deserializer=a2a__pb2.ListTasksResponse.FromString,
47+
_registered_method=True)
4348
self.CancelTask = channel.unary_unary(
4449
'/a2a.v1.A2AService/CancelTask',
4550
request_serializer=a2a__pb2.CancelTaskRequest.SerializeToString,
@@ -113,6 +118,13 @@ def GetTask(self, request, context):
113118
context.set_details('Method not implemented!')
114119
raise NotImplementedError('Method not implemented!')
115120

121+
def ListTasks(self, request, context):
122+
"""List tasks with optional filtering and pagination.
123+
"""
124+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
125+
context.set_details('Method not implemented!')
126+
raise NotImplementedError('Method not implemented!')
127+
116128
def CancelTask(self, request, context):
117129
"""Cancel a task from the agent. If supported one should expect no
118130
more task updates for the task.
@@ -184,6 +196,11 @@ def add_A2AServiceServicer_to_server(servicer, server):
184196
request_deserializer=a2a__pb2.GetTaskRequest.FromString,
185197
response_serializer=a2a__pb2.Task.SerializeToString,
186198
),
199+
'ListTasks': grpc.unary_unary_rpc_method_handler(
200+
servicer.ListTasks,
201+
request_deserializer=a2a__pb2.ListTasksRequest.FromString,
202+
response_serializer=a2a__pb2.ListTasksResponse.SerializeToString,
203+
),
187204
'CancelTask': grpc.unary_unary_rpc_method_handler(
188205
servicer.CancelTask,
189206
request_deserializer=a2a__pb2.CancelTaskRequest.FromString,
@@ -321,6 +338,33 @@ def GetTask(request,
321338
metadata,
322339
_registered_method=True)
323340

341+
@staticmethod
342+
def ListTasks(request,
343+
target,
344+
options=(),
345+
channel_credentials=None,
346+
call_credentials=None,
347+
insecure=False,
348+
compression=None,
349+
wait_for_ready=None,
350+
timeout=None,
351+
metadata=None):
352+
return grpc.experimental.unary_unary(
353+
request,
354+
target,
355+
'/a2a.v1.A2AService/ListTasks',
356+
a2a__pb2.ListTasksRequest.SerializeToString,
357+
a2a__pb2.ListTasksResponse.FromString,
358+
options,
359+
channel_credentials,
360+
insecure,
361+
call_credentials,
362+
compression,
363+
wait_for_ready,
364+
timeout,
365+
metadata,
366+
_registered_method=True)
367+
324368
@staticmethod
325369
def CancelTask(request,
326370
target,

src/a2a/types.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,69 @@ class ListTaskPushNotificationConfigSuccessResponse(A2ABaseModel):
12711271
"""
12721272

12731273

1274+
class ListTasksParams(A2ABaseModel):
1275+
"""
1276+
Parameters for listing tasks with optional filtering criteria.
1277+
"""
1278+
1279+
context_id: str | None = None
1280+
"""
1281+
Filter tasks by context ID to get tasks from a specific conversation or session.
1282+
"""
1283+
history_length: int | None = None
1284+
"""
1285+
Number of recent messages to include in each task's history. Must be non-negative. Defaults to 0 if not specified.
1286+
"""
1287+
include_artifacts: bool | None = None
1288+
"""
1289+
Whether to include artifacts in the returned tasks. Defaults to false to reduce payload size.
1290+
"""
1291+
last_updated_after: int | None = None
1292+
"""
1293+
Filter tasks updated after this timestamp (milliseconds since epoch). Only tasks with a last updated time greater than or equal to this value will be returned.
1294+
"""
1295+
metadata: dict[str, Any] | None = None
1296+
"""
1297+
Request-specific metadata.
1298+
"""
1299+
page_size: int | None = None
1300+
"""
1301+
Maximum number of tasks to return. Must be between 1 and 100. Defaults to 50 if not specified.
1302+
"""
1303+
page_token: str | None = None
1304+
"""
1305+
Token for pagination. Use the nextPageToken from a previous ListTasksResult response.
1306+
"""
1307+
status: TaskState | None = None
1308+
"""
1309+
Filter tasks by their current status state.
1310+
"""
1311+
1312+
1313+
class ListTasksRequest(A2ABaseModel):
1314+
"""
1315+
JSON-RPC request model for the 'tasks/list' method.
1316+
"""
1317+
1318+
id: str | int
1319+
"""
1320+
A unique identifier established by the client. It must be a String, a Number, or null.
1321+
The server must reply with the same value in the response. This property is omitted for notifications.
1322+
"""
1323+
jsonrpc: Literal['2.0'] = '2.0'
1324+
"""
1325+
The version of the JSON-RPC protocol. MUST be exactly "2.0".
1326+
"""
1327+
method: Literal['tasks/list'] = 'tasks/list'
1328+
"""
1329+
A String containing the name of the method to be invoked.
1330+
"""
1331+
params: ListTasksParams | None = None
1332+
"""
1333+
A Structured value that holds the parameter values to be used during the invocation of the method.
1334+
"""
1335+
1336+
12741337
class MessageSendConfiguration(A2ABaseModel):
12751338
"""
12761339
Defines configuration options for a `message/send` or `message/stream` request.
@@ -1694,6 +1757,7 @@ class A2ARequest(
16941757
SendMessageRequest
16951758
| SendStreamingMessageRequest
16961759
| GetTaskRequest
1760+
| ListTasksRequest
16971761
| CancelTaskRequest
16981762
| SetTaskPushNotificationConfigRequest
16991763
| GetTaskPushNotificationConfigRequest
@@ -1707,6 +1771,7 @@ class A2ARequest(
17071771
SendMessageRequest
17081772
| SendStreamingMessageRequest
17091773
| GetTaskRequest
1774+
| ListTasksRequest
17101775
| CancelTaskRequest
17111776
| SetTaskPushNotificationConfigRequest
17121777
| GetTaskPushNotificationConfigRequest
@@ -1936,6 +2001,48 @@ class GetTaskSuccessResponse(A2ABaseModel):
19362001
"""
19372002

19382003

2004+
class ListTasksResult(A2ABaseModel):
2005+
"""
2006+
Result object for tasks/list method containing an array of tasks and pagination information.
2007+
"""
2008+
2009+
next_page_token: str
2010+
"""
2011+
Token for retrieving the next page. Empty string if no more results.
2012+
"""
2013+
page_size: int
2014+
"""
2015+
Maximum number of tasks returned in this response.
2016+
"""
2017+
tasks: list[Task]
2018+
"""
2019+
Array of tasks matching the specified criteria.
2020+
"""
2021+
total_size: int
2022+
"""
2023+
Total number of tasks available (before pagination).
2024+
"""
2025+
2026+
2027+
class ListTasksSuccessResponse(A2ABaseModel):
2028+
"""
2029+
JSON-RPC success response model for the 'tasks/list' method.
2030+
"""
2031+
2032+
id: str | int | None = None
2033+
"""
2034+
The identifier established by the client.
2035+
"""
2036+
jsonrpc: Literal['2.0'] = '2.0'
2037+
"""
2038+
The version of the JSON-RPC protocol. MUST be exactly "2.0".
2039+
"""
2040+
result: ListTasksResult
2041+
"""
2042+
The result object on success.
2043+
"""
2044+
2045+
19392046
class SendMessageSuccessResponse(A2ABaseModel):
19402047
"""
19412048
Represents a successful JSON-RPC response for the `message/send` method.
@@ -1998,6 +2105,7 @@ class JSONRPCResponse(
19982105
| SendStreamingMessageSuccessResponse
19992106
| GetTaskSuccessResponse
20002107
| CancelTaskSuccessResponse
2108+
| ListTasksSuccessResponse
20012109
| SetTaskPushNotificationConfigSuccessResponse
20022110
| GetTaskPushNotificationConfigSuccessResponse
20032111
| ListTaskPushNotificationConfigSuccessResponse
@@ -2011,6 +2119,7 @@ class JSONRPCResponse(
20112119
| SendStreamingMessageSuccessResponse
20122120
| GetTaskSuccessResponse
20132121
| CancelTaskSuccessResponse
2122+
| ListTasksSuccessResponse
20142123
| SetTaskPushNotificationConfigSuccessResponse
20152124
| GetTaskPushNotificationConfigSuccessResponse
20162125
| ListTaskPushNotificationConfigSuccessResponse
@@ -2023,6 +2132,15 @@ class JSONRPCResponse(
20232132
"""
20242133

20252134

2135+
class ListTasksResponse(
2136+
RootModel[JSONRPCErrorResponse | ListTasksSuccessResponse]
2137+
):
2138+
root: JSONRPCErrorResponse | ListTasksSuccessResponse
2139+
"""
2140+
JSON-RPC response for the 'tasks/list' method.
2141+
"""
2142+
2143+
20262144
class SendMessageResponse(
20272145
RootModel[JSONRPCErrorResponse | SendMessageSuccessResponse]
20282146
):

0 commit comments

Comments
 (0)