Driver with DUT's output

I got an interview question where we should implement a driver and only drive it when this item’s index is same as DUT’s requested index.
I never dealt with problem like driver only provide transaction item based on DUT’s request before. I thought driver should only talk with sequencer and sequence. So how could driver know the DUT’s request? Like can we directly use the request on the virtual interface in driver?
My current implementation is below:

class my_driver extends uvm_driver;
  item item_aa[int]
  ...
  task run_phase(uvm_phase phase);
    item my_item;
    int request_id;
    forever begin
      if (vif.request_enable) begin
      	request_id = vif.request_id;
      end
      seq_item_port.get_next_item(my_item);
      if (item_aa.exist(request_id)
          drive(my_item);
      else item_aa[my_item.id] = my_item;
      item_done();
    end //forever
  endtask
endclass

This kind of agent is called sometimes a reactive-slave or responder.

I would recommend reading the next papers:
1.
https://www.sunburst-design.com/papers/CummingsDVCon2020_UVM_ReactiveStimulus.pdf

And the next chapter from UVM cookbook:

If the index value is not part of the interface pins, then another possible solution is to have a variable in the agent’s config class that defines the index. Then if your testbench instantiates 2 of the agents, you can set them to have different index values. The transaction class would have a field that defines the index so the sequence would set the index value before starting the sequence on all the agent sequencers. The sequencers would pass the transaction to the driver which could then check if the index value in the transaction class matches that index in it’s config class. If it does, then it could commence driving the data. If the index values do not match, then the transaction could be discarded.