-
Notifications
You must be signed in to change notification settings - Fork 1.2k
SEP-1904 : Add filtering support for tasks/list #1904
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: main
Are you sure you want to change the base?
Conversation
|
@LucaButBoring Would you like to help with this? Thanks, feel free to add you to the authors, too. |
|
I might be willing to sponsor this, depending on the specifics, but I likely won't be able to directly contribute that much right now due to having several other large SEPs to directly author (including subtasks). I do have a few questions on this, first (in part because these are questions I'd be asked as a sponsor):
Regarding a separate comment from @dsp-ant that #1300 already proposes tool filtering and hasn't been accepted (suggesting this might face similar pushback), I think we should discuss that as well. I'll refer to @cliffhall's comment here describing the feedback from the Core Maintainers on each aspect of that proposal. In particular, this part:
Based on this and @dsp-ant's comment right after that, I think the arguments against filtering are actually more specifically arguments against this kind of filtering being done by models. @He-Pin With that context established, I'd also like to ask you what the intended usage of task filtering is on the consuming side. If this is primarily intended to be invoked with filtering by models, we'll need to address the same questions as #1300. If this is primarily intended to be filtered by some control plane service or the host application itself (which makes more sense to me), then this is completely different from #1300, and those concerns likely don't apply. |
|
Discussing in parallel with @cliffhall and @scottslewis - the Primitives WG is planning to introduce a unified proposal for filtering across the protocol after the new Groups proposal (addressing feedback) lands, so this may fall under the Primitives WG's purview. It'd be great to have a consistent means of filtering across the entire protocol. |
@LucaButBoring thanks for your input. |
Thank you for letting me know, I agree 100%. |
|
Thank you for the proposal. My main feedback on any time of filter proposal is that you have to demonstrate that this is necessary to put into the protocol. My current stance is that filtering can be done in nearly all instances on the client. Even for large tool lists, they can transfer easily to the client in <100kb with gzip enabled. I just generate 1000 tool descriptions and received the following results: This means the client can do everything by themselves, giving it full control how it wants to filter, e.g. by using a search tool, by using RAG or any other method. For this proposal to get traction, I think you need to show a set of clear use-cases that this enables that otherwise can't be done and are becoming widespread patterns. |
|
You're absolutely right, but the main problem is that bandwidth costs money for large companies. By reducing the number of queries, we can also reduce the database's TPS (transactions per second). Meanwhile, considering edge-side agents, a user can say to their phone: "Please check the tasks I submitted yesterday but haven't completed yet," or "Please check the tasks with status updates in the last 3 hours." By implementing server-side filtering, we can quickly return results to the user. A demo implementation shows how to perform result filtering on the server side, thereby avoiding bandwidth costs and improving real-time response. |
I've been a participant in the specification for the OSGi framework. Early on, there was a need to do filtering for osgi service lookup aka runtime service discovery. The required filtering was over a dictionary of name/value properties associated with the service. Dynamic OSGi service lookup and filtering is in heavy use today. The approach taken then (and in use today) was to use a rfc-standardized filtering syntax RFC-1960. I bring this up as an example of a filtering use case similar to MCP primitive lookup/discovery/filtering being discussed here. |
|
@He-Pin you can get involved in the Groups working group channel in the discord. We can discuss filtering but current active priority is delivering the group abstraction that is much more agreed upon as a necessity before we start trying to deliver any dedicated solutions related to filtering. Whatever is agreed upon from the working group we'll want to make a universal SEP for all primitives, not just tasks like we're doing for the group abstraction |
|
Thanks, Discord is blocked at Alibaba, and I have to reach it with my phone.I am currently working on the Java-side implementation. |
|
@He-Pin Discord is here, linked in the governance documentation here. Check the Also linking Agents WG notes on this from two days ago for discoverability for others: #1927
|
@LucaButBoring FYI,here we may want to filter
|
|
Can you elaborate on this? I'm not sure what this is, exactly (and this appears to be a mockup). |

SEP-1904: Task filter
Status: Draft
Type: Standards Track
Created: 2025-11-20
Author(s): He-Pin hepin.p@alibaba-inc.com (@He-Pin)
Sponsor: TBD
PR: #1904
Abstract
This SEP proposes a task filtering mechanism to enhance the query of tasks in large-scale distributed systems.
By implementing a filtering layer, the system can quickly identify and prioritize tasks based on predefined criteria,
reducing latency and improving overall performance.
Motivation
The current
tasks/listAPI retrieves all tasks without any filtering capabilities, which can lead to inefficiencies inlarge-scale distributed systems.
As in Streamable HTTP transport, a User or Agent system MAY reuse the same session for multiple task submissions.
When querying tasks, the system may return a large number of tasks that not interested(eg. already completed), leading
to increased latency and resource consumption.
To address this issue, we propose introducing a task filtering mechanism that allows users to specify criteria for
filtering tasks during the query process.
This will enable the system to return only relevant tasks, improving efficiency and user experience.
Specification
Capabilities
Servers and Clients that support task filtering MUST advertise this capability during the initial handshake or
capabilities negotiation phase. This can be done by including a
filterflag in the capabilities exchange message.Server capabilities
tasks.list.filtertasks/listoperation{ "capabilities": { "tasks": { "list": { "filter": { "methods": ["tools/call"], "taskIds": true, "status": true, "createdAt": { "before": true, "after": true }, "lastUpdatedAt": { "before": true, "after": true }, "order": { "by": ["createdAt", "lastUpdatedAt"], "direction": ["asc", "desc"] } } } } } }Client capabilities
tasks.list.filtertasks/listoperation{ "capabilities": { "tasks": { "list": { "filter": { "methods": ["sampling/createMessage", "elicitation/create"], "taskIds": true, "status": true, "createdAt": { "after": true, "before": true }, "lastUpdatedAt": { "after": true, "before": true }, "order": { "by": ["createdAt", "lastUpdatedAt"], "direction": ["asc", "desc"] } } } } } }Capability Negotiation
During the initialization phase, both parties exchange their
taskscapabilities to establish which operations supporttask-based execution.
Requestors SHOULD only query tasks with filtering if the receivers have advertised support for the
tasks.list.filtercapability.
If a specified filter criterion is not supported by the receiver, the receiver MAY just ignore that criterion and
process the request using the supported criteria.
The requester MUST be prepared to handle responses that do not fully adhere to the requested filtering criteria, eg
returning a broader set of tasks than expected.
eg, if a client requests filtering by
statusbut the server does not support it, the server may return all taskswithout filtering by status,
and the client should be able to handle this scenario gracefully, eg. by performing client-side filtering if necessary.
Filter Parameters
When making a
tasks/listrequest, clients MAY include filter parameters to specify the criteria for filteringtasks.
The following filter parameters are supported:
methods(array of strings, optional): Filter tasks by the types of the underlying request (e.g.tools/call,sampling/createMessage).taskIds(array of strings, optional): Filter tasks by a list of specific task IDs.status(array of strings, optional): Filter tasks by a list of specified current status (e.g.,working,completed,failed,cancelled,input_required).createdAfter(string, optional): An ISO 8601 timestamp to filter tasks created after the specified time.createdBefore(string, optional): An ISO 8601 timestamp to filter tasks created before the specified time.lastUpdatedAfter(string, optional): An ISO 8601 timestamp to filter tasks updated after the specified time.lastUpdatedBefore(string, optional): An ISO 8601 timestamp to filter tasks updated before the specified time.orderBy(string, optional): Specifies the field by which to order the returned tasks. Possible values arecreatedAtandlastUpdatedAt. Default islastUpdatedAt.order(string, optional): Specifies the order of the returned tasks. Possible values areascfor ascending anddescfor descending. Default isdesc.When the filter is omitted, all tasks belongs to that session are returned.
Backward Compatibility
New Client + Old Server: New clients that support task filtering can still interact with old servers that do not
support
the feature. In this case, the filtering parameters will be ignored by the old server, and the client will receive
the full list of tasks as per the existing behavior.
Old Client + New Server: Old clients that do not support task filtering can still interact with new servers that
support the feature. In this case, the server will return the full list of tasks without applying any filters,
maintaining
compatibility with the old client.