-
Notifications
You must be signed in to change notification settings - Fork 428
fix: null-pointer when message send configuration is provided with no history limit #536
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
Closed
yarolegovich
wants to merge
2
commits into
a2aproject:main
from
yarolegovich:yarolegovich/add-none-check
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,3 @@ | ||||||
| import asyncio | ||||||
| import contextlib | ||||||
| import logging | ||||||
|
|
@@ -874,6 +874,44 @@ | |||||
| assert task is not None | ||||||
| assert task.history is not None and len(task.history) > 0 | ||||||
|
|
||||||
| @pytest.mark.asyncio | ||||||
| async def test_on_message_send_limit_history_non_as_no_limit(): | ||||||
|
Contributor
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. This is a great test case to ensure that a
Suggested change
|
||||||
| task_store = InMemoryTaskStore() | ||||||
| push_store = InMemoryPushNotificationConfigStore() | ||||||
|
|
||||||
| request_handler = DefaultRequestHandler( | ||||||
| agent_executor=HelloAgentExecutor(), | ||||||
| task_store=task_store, | ||||||
| push_config_store=push_store, | ||||||
| ) | ||||||
| params = MessageSendParams( | ||||||
| message=Message( | ||||||
| role=Role.user, | ||||||
| message_id='msg_push', | ||||||
| parts=[Part(root=TextPart(text='Hi'))], | ||||||
| ), | ||||||
| configuration=MessageSendConfiguration( | ||||||
| blocking=True, | ||||||
| accepted_output_modes=['text/plain'], | ||||||
| history_length=None | ||||||
| ), | ||||||
| ) | ||||||
|
|
||||||
| result = await request_handler.on_message_send( | ||||||
| params, create_server_call_context() | ||||||
| ) | ||||||
|
|
||||||
| # verify that history_length is honored | ||||||
| assert result is not None | ||||||
| assert isinstance(result, Task) | ||||||
| assert result.history is not None and len(result.history) > 0 | ||||||
| assert result.status.state == TaskState.completed | ||||||
|
|
||||||
| # verify that history is still persisted to the store | ||||||
| task = await task_store.get(result.id) | ||||||
| assert task is not None | ||||||
| assert task.history is not None and len(task.history) > 0 | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.asyncio | ||||||
| async def test_on_task_get_limit_history(): | ||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While this change is intended to fix a null-pointer issue, the check for
params.configuration.history_length is not Noneappears to be redundant. Theapply_history_lengthfunction already includes a check forhistory_length is not Noneand safely handles the case where it isNoneby returning the task unmodified.To avoid duplicating this logic and to keep the code cleaner, it would be better to rely on
apply_history_lengthto handle this. This centralizes the logic for handlinghistory_lengthvalues.