Define how to (un)serialize the query Result so that agents can store in
in their state.
Fix incorrect query index for a compound query with sorting defined.