How to query information from imp

I’m not sure how to use the agent/device paradigm to query information from the imp unit directly. Seems like the API is setup to do it asynchronously, and I’m not sure how to persist the request information from the query to send a reply when the device responds via another thread?

Here’s an example from @beardedinventor: