Repository navigation
Description
Steps to reproduce
Goal
Make protocol-facing ListTasks requests use the pagination contract already
defined by the A2A schema:
- omitted
page_size: return at most 50 tasks; - minimum explicit
page_size: 1; - maximum explicit
page_size: 100.
Prevent an omitted page size from reaching the task store as 0 and silently
requesting every stored task.
Background
The protobuf schema states that an unspecified page size returns at most 50
tasks and that valid explicit values are 1 through 100.
The current internal ListTasksRequest uses page_size == 0 as an unbounded
sentinel. REST, JSON-RPC, and gRPC requests that omit the field can therefore
reach the stores with 0, causing all matching tasks to be materialised.
PR #174 demonstrates the cost with 1,000 tasks containing 100 history entries:
| Returned tasks | Benchmark | Median |
|---|---|---|
| 10 | BM_TaskStore_List_PageAndHistory/10/100 |
325,399 ns |
| 100 | BM_TaskStore_List_PageAndHistory/100/100 |
3,172,969 ns |
| 1,000 | BM_TaskStore_List_PageAndHistory/0/100 |
44,999,729 ns |
Required changes
-
Centralise pagination constants and validation:
inline constexpr std::size_t kDefaultListTasksPageSize = 50; inline constexpr std::size_t kMaxListTasksPageSize = 100;
-
Add one shared request-normalisation helper used by every protocol binding.
-
Apply identical behaviour to HTTP+JSON, JSON-RPC, and gRPC:
- omitted page size resolves to 50;
- explicit values from 1 through 100 are accepted;
- explicit
0, negative values, and values above 100 are rejected with the
appropriate protocol validation error.
-
Ensure protocol requests never reach
TaskStore::Listwith an unbounded
page size. -
Keep direct store-only
page_size == 0behaviour only if it is required for
internal benchmarks or non-protocol tests. If retained:- document it as an internal unbounded sentinel;
- make clear that it is not reachable from valid A2A protocol requests;
- avoid exposing it as recommended SDK usage.
-
Preserve existing page-token ordering and filtering semantics for both
InMemoryTaskStoreandPostgresTaskStore. -
Add client documentation showing how to continue while
next_page_tokenis non-empty. -
Document the consequences of unbounded or oversized task lists:
- CPU cost grows with returned task count and retained history;
- protobuf allocations and copies increase;
- response memory and serialized payload size increase;
- in-memory stores hold the shared read lock longer;
- write operations may wait longer;
- transport latency and timeout risk increase;
- requesting full history can dominate the list operation.
-
Recommend using both:
- a bounded page size, normally no more than 100;
- a small
history_length, often 0 or 1, unless deeper history is required.
Tests
Add deterministic coverage for every transport and both supported stores:
- omitted page size returns no more than 50 tasks;
- a result with more matching tasks contains
next_page_token; - following all page tokens returns every task exactly once and in order;
- explicit page sizes 1, 50, and 100 work;
- explicit 0 and 101 are rejected;
- negative values are rejected where the input representation supports them;
- filtering and pagination work together;
- history and artifact projection remain correct across pages.
Update performance tests so normal protocol scenarios exercise the default
bounded page size. Preserve explicit store-only full-list benchmarks for
diagnostic coverage.
Acceptance criteria
- Omitted protocol page size resolves to 50 on HTTP+JSON, JSON-RPC, and
gRPC. - Public protocol requests cannot request an unbounded page.
- Explicit values outside 1 through 100 are rejected consistently.
- Pagination produces no duplicate or missing tasks.
- In-memory and PostgreSQL stores pass the same conformance tests.
- Documentation includes a complete page-token loop example.
- Documentation explains the measured consequences of omitting pagination
and requesting deep history. - Existing benchmark and performance reports remain machine-readable.
- Formatting, build, tests, clang-tidy, sanitizers, performance smoke,
interoperability tests, and mandatory TCK pass.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity