Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ async def push_notification_callback() -> None:

if isinstance(result, Task):
self._validate_task_id_match(task_id, result.id)
if params.configuration:
if (
params.configuration
and params.configuration.history_length is not None
):
result = apply_history_length(
result, params.configuration.history_length
)
Expand Down
39 changes: 39 additions & 0 deletions tests/server/request_handlers/test_default_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,45 @@ async def test_on_message_send_limit_history():
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():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

This is a great test case to ensure that a None value for history_length doesn't truncate the history. For better readability, consider renaming the test to be more descriptive of its purpose. For example: test_on_message_send_with_none_history_length_is_not_limited.

Suggested change
async def test_on_message_send_limit_history_non_as_no_limit():
async def test_on_message_send_with_none_history_length_is_not_limited():

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():
task_store = InMemoryTaskStore()
Expand Down
Loading