-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add partial results as part of progress notifications #669
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,12 @@ class Meta(BaseModel): | |
parameter is an opaque token that will be attached to any subsequent | ||
notifications. The receiver is not obligated to provide these notifications. | ||
""" | ||
|
||
partialResults: bool | None = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be a comment for the spec PR. |
||
""" | ||
If true, the caller is requesting that results be streamed via progress notifications. | ||
When this is set to true, the final response may be empty as the complete result | ||
will have been delivered through progress notifications. | ||
""" | ||
model_config = ConfigDict(extra="allow") | ||
|
||
meta: Meta | None = Field(alias="_meta", default=None) | ||
|
@@ -322,6 +327,19 @@ class PingRequest(Request[RequestParams | None, Literal["ping"]]): | |
method: Literal["ping"] | ||
params: RequestParams | None = None | ||
|
||
class PartialResult(BaseModel): | ||
chunk: dict[str, Any] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. disregard below -- these points need to go on the spec PR. i will add them there. question:
|
||
"""The partial result data chunk.""" | ||
append: bool = False | ||
""" | ||
If true, this chunk should be appended to previously received chunks. | ||
If false, this chunk replaces any previously received chunks. | ||
""" | ||
lastChunk: bool = False | ||
""" | ||
If true, this is the final chunk of the result. | ||
No further chunks will be sent for this operation. | ||
""" | ||
|
||
class ProgressNotificationParams(NotificationParams): | ||
"""Parameters for progress notifications.""" | ||
|
@@ -338,6 +356,11 @@ class ProgressNotificationParams(NotificationParams): | |
""" | ||
total: float | None = None | ||
"""Total number of items to process (or total progress required), if known.""" | ||
partialResult: PartialResult | None = None | ||
""" | ||
If present, contains a partial result chunk for the operation. | ||
This is used to stream results incrementally while an operation is still in progress. | ||
""" | ||
model_config = ConfigDict(extra="allow") | ||
|
||
|
||
|
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.
Can we model this as an argument with Meta type rather than treating it as **kwargs? If the idea is not to put all extra keyword arguments, that don't match other call_tool arguments, in meta then we should use an argument with type Meta instead.