Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/a2a/client/transports/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ async def get_task(
) -> Task:
"""Retrieves the current state and history of a specific task."""
task = await self.stub.GetTask(
a2a_pb2.GetTaskRequest(name=f'tasks/{request.id}')
a2a_pb2.GetTaskRequest(
name=f'tasks/{request.id}',
history_length=request.history_length,
)
)
return proto_utils.FromProto.task(task)

Expand Down
22 changes: 21 additions & 1 deletion tests/client/test_grpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,31 @@ async def test_get_task(
response = await grpc_transport.get_task(params)

mock_grpc_stub.GetTask.assert_awaited_once_with(
a2a_pb2.GetTaskRequest(name=f'tasks/{sample_task.id}')
a2a_pb2.GetTaskRequest(
name=f'tasks/{sample_task.id}', history_length=None
)
)
assert response.id == sample_task.id


@pytest.mark.asyncio
async def test_get_task_with_history(
grpc_transport: GrpcTransport, mock_grpc_stub: AsyncMock, sample_task: Task
):
"""Test retrieving a task with history."""
mock_grpc_stub.GetTask.return_value = proto_utils.ToProto.task(sample_task)
history_len = 10
params = TaskQueryParams(id=sample_task.id, history_length=history_len)

await grpc_transport.get_task(params)

mock_grpc_stub.GetTask.assert_awaited_once_with(
a2a_pb2.GetTaskRequest(
name=f'tasks/{sample_task.id}', history_length=history_len
)
)


@pytest.mark.asyncio
async def test_cancel_task(
grpc_transport: GrpcTransport, mock_grpc_stub: AsyncMock, sample_task: Task
Expand Down
Loading