Skip to content

Commit f89c339

Browse files
committed
fix null pointer
1 parent 265fd33 commit f89c339

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/a2a/server/request_handlers/default_request_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ async def push_notification_callback() -> None:
346346

347347
if isinstance(result, Task):
348348
self._validate_task_id_match(task_id, result.id)
349-
if params.configuration:
349+
if params.configuration and params.configuration.history_length is not None:
350350
result = apply_history_length(
351351
result, params.configuration.history_length
352352
)

tests/server/request_handlers/test_default_request_handler.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,44 @@ async def test_on_message_send_limit_history():
874874
assert task is not None
875875
assert task.history is not None and len(task.history) > 0
876876

877+
@pytest.mark.asyncio
878+
async def test_on_message_send_limit_history_non_as_no_limit():
879+
task_store = InMemoryTaskStore()
880+
push_store = InMemoryPushNotificationConfigStore()
881+
882+
request_handler = DefaultRequestHandler(
883+
agent_executor=HelloAgentExecutor(),
884+
task_store=task_store,
885+
push_config_store=push_store,
886+
)
887+
params = MessageSendParams(
888+
message=Message(
889+
role=Role.user,
890+
message_id='msg_push',
891+
parts=[Part(root=TextPart(text='Hi'))],
892+
),
893+
configuration=MessageSendConfiguration(
894+
blocking=True,
895+
accepted_output_modes=['text/plain'],
896+
history_length=None
897+
),
898+
)
899+
900+
result = await request_handler.on_message_send(
901+
params, create_server_call_context()
902+
)
903+
904+
# verify that history_length is honored
905+
assert result is not None
906+
assert isinstance(result, Task)
907+
assert result.history is not None and len(result.history) > 0
908+
assert result.status.state == TaskState.completed
909+
910+
# verify that history is still persisted to the store
911+
task = await task_store.get(result.id)
912+
assert task is not None
913+
assert task.history is not None and len(task.history) > 0
914+
877915

878916
@pytest.mark.asyncio
879917
async def test_on_task_get_limit_history():

0 commit comments

Comments
 (0)