-
Notifications
You must be signed in to change notification settings - Fork 279
feat(spec): Add tasks/list method with filtering and pagination to the specification
#511
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: 1.0-dev
Are you sure you want to change the base?
feat(spec): Add tasks/list method with filtering and pagination to the specification
#511
Conversation
Summary of ChangesHello @a2a-bot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the A2A API by introducing a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the A2A specification and the corresponding generated Python files to introduce the ListTasks functionality. The changes correctly add the necessary protobuf messages, gRPC service definitions, and Pydantic models for the JSON-RPC transport. It appears the implementation of these new endpoints in the server handlers and client transports is planned for future work.
My review focuses on the manually edited src/a2a/types.py file. I've suggested adding Pydantic validators to the ListTasksParams model to enforce constraints mentioned in the docstrings, which will improve data integrity. I also pointed out a small inconsistency in a docstring for better clarity. Overall, the changes are well-structured and align with the existing design.
39b57dc to
e5853a6
Compare
tasks/list method with filtering and pagination to the specification
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the tasks/list method, providing filtering and pagination capabilities for tasks. The changes are extensive, touching the client, server, transports, data stores, and tests. The implementation is solid, but I have a few suggestions to improve consistency, validation, and code clarity. Specifically, I recommend centralizing the payload reduction logic, adding a validator for request parameters, and removing some dead code. Overall, a great addition to the A2A specification.
Co-authored-by: Holt Skinner <13262395+holtskinner@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces the tasks/list method across the entire stack, from the specification and type definitions to client and server implementations for all transports (gRPC, JSON-RPC, REST), and includes comprehensive tests. The changes are well-structured and thorough. I've found a few minor issues, mostly related to robustness, documentation, and a small bug in a test case. Overall, this is a solid contribution.
|
|
||
| # Get paginated results | ||
| stmt = ( | ||
| base_stmt.order_by(self.task_model.id.desc()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of limit-offset it's better to return task id of the last selected task as a page token and use it in where(task.id < pageToken).
looking at TaskMixin:
id: Mapped[str] = mapped_column(String(36), primary_key=True, index=True)I think we should coordinate the migration to uuid v7 for id generation so that primary index inserts are mostly append only and not random
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, v7 uuids are out of scope for this PR.
Secondly, I don't agree that we should use ids or timestamps as offsets for the following reasons:
- Users can provide custom ID generators, making not to have any specific order.
- I image that we can add other sorting options in the future and this approach is more future-proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v7 uuids are out of scope for this PR.
Agree.
Users can provide custom ID generators, making not to have any specific order.
ID is already a primary key in your TaskModel which means tasks are stored sorted by it, regardless of whether it's random, increasing or monotonic.
I image that we can add other sorting options in the future and this approach is more future-proof.
Sorting option should have secondary indices, selector column value should be used as a cursor.
Btw, in the current spec version:
Ordering: Implementations MUST return tasks sorted by their last update time in descending order (most recently updated tasks first). This ensures consistent pagination and allows clients to efficiently monitor recent task activity.
So ID ordering is not really spec compliant, a last_update timestamp should be added to TaskModel (ideally with a creation timestamp).
There's also a section about offset-based pagination:
Pagination Strategy: This method uses cursor-based pagination (via pageToken/nextPageToken) rather than offset-based pagination for better performance and consistency, especially with large datasets. Cursor-based pagination avoids the "deep pagination problem" where skipping large numbers of records becomes inefficient for databases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I somehow missed the part about the cursor-based pagination. Will change the implementation.
| offset = page_number * page_size | ||
|
|
||
| # Base query for filtering | ||
| base_stmt = select(self.task_model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
task model needs to be updated to have user credentials in it with a db index for faster queries. otherwise anyone can query all the tasks on the server. can be done in a separate index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is not something we cannot do properly at this time. There is a number of different auth schemes and resource ownership models that the server maintainers can decide to follow. This is also a broader topic then just the task/list method.
For now, all resources are accessible to all-users/all-authenticated-users.
We do have a plan on adding support for common auth schemes in the SDK and this is when this could potentially be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is ServerCallContext with User in it, it's even passed to DatabaseTaskStore, just unused. User.username should be an indexed field in TaskModel to filter on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is making an assumption that tasks are user-scoped. Correct me if I'm wrong but I think that doesn't always has to be the case. For instance, they could be tenant scoped. I don't see other parts of the SDK user-scoping tasks and we should be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's another note in the specification 🙂
Security Note: Implementations MUST ensure appropriate scope limitation based on the authenticated user's permissions. Servers SHOULD NOT return tasks from other users or unauthorized contexts. Even when contextId is not specified in the request, the implementation MUST still scope results to the caller's authorization and tenancy boundaries. The implementation MAY choose to limit results to tasks created by the current authenticated user, tasks within a default user context, or return an authorization error if the scope cannot be safely determined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's bigger issue of persistent task store implementation, we can address this separately.
Commit: a2aproject/A2A@0a9f629
This PR introduces support for the new
tasks/listmethod, including:Fixes #515 🦕