Skip to content

Commit 51ee2c7

Browse files
committed
Change last token to '' and add more list_tasks tests
1 parent 1d712e8 commit 51ee2c7

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ async def on_list_tasks(
144144
)
145145
processed_tasks.append(processed_task)
146146
return ListTasksResult(
147-
next_page_token=page.next_page_token,
147+
next_page_token=page.next_page_token or '',
148148
page_size=params.page_size or DEFAULT_LIST_TASKS_PAGE_SIZE,
149149
tasks=processed_tasks,
150150
total_size=page.total_size,

tests/server/tasks/test_database_task_store.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,19 @@ async def test_get_task(db_store_parameterized: DatabaseTaskStore) -> None:
190190
5,
191191
'1',
192192
),
193-
# Pagination (second page)
193+
# Pagination (final page)
194194
(
195-
ListTasksParams(page_size=2, page_token='1'),
196-
['task-2', 'task-1'],
195+
ListTasksParams(page_size=2, page_token='2'),
196+
['task-0'],
197197
5,
198-
'2',
198+
None,
199+
),
200+
# Pagination (out of bounds)
201+
(
202+
ListTasksParams(page_size=2, page_token='3'),
203+
[],
204+
5,
205+
None,
199206
),
200207
# Filtering by context_id
201208
(

tests/server/tasks/test_inmemory_task_store.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ async def test_in_memory_task_store_get_nonexistent() -> None:
5050
5,
5151
'1',
5252
),
53-
# Pagination (second page)
53+
# Pagination (final page)
5454
(
55-
ListTasksParams(page_size=2, page_token='1'),
56-
['task-2', 'task-3'],
55+
ListTasksParams(page_size=2, page_token='2'),
56+
['task-4'],
5757
5,
58-
'2',
58+
None,
59+
),
60+
# Pagination (out of bounds)
61+
(
62+
ListTasksParams(page_size=2, page_token='3'),
63+
[],
64+
5,
65+
None,
5966
),
6067
# Filtering by context_id
6168
(

0 commit comments

Comments
 (0)