Record Class MemoryQuery

java.lang.Object
java.lang.Record
dev.agenor.core.memory.MemoryQuery
Record Components:
text - optional full-text or substring filter; null means no text constraint
scope - memory scope to search (MemoryScope.SHORT_TERM or MemoryScope.LONG_TERM); must not be null
ownerId - optional filter by owning agent ID; null means any owner
filters - immutable map of metadata key/value filters; empty if null
limit - maximum number of results to return; must be between 1 and 1000

public record MemoryQuery(String text, MemoryScope scope, String ownerId, Map<String,Object> filters, int limit) extends Record
Query parameters for searching memory entries.

Example:


 MemoryQuery query = MemoryQuery.builder()
     .text("customer order")
     .scope(MemoryScope.LONG_TERM)
     .ownerId("order-agent")
     .filter("status", "completed")
     .limit(10)
     .build();
 List<MemoryEntry> results = memoryStore.search(query).join();
 
Since:
0.6.0
  • Constructor Details

  • Method Details

    • hasTextFilter

      public boolean hasTextFilter()
      Checks if this query has a text filter.
      Returns:
      true if text search is specified
    • hasOwnerFilter

      public boolean hasOwnerFilter()
      Checks if this query has an owner filter.
      Returns:
      true if owner ID is specified
    • hasMetadataFilters

      public boolean hasMetadataFilters()
      Checks if this query has metadata filters.
      Returns:
      true if any filters are specified
    • getFilter

      public <T> T getFilter(String key, Class<T> type)
      Gets a specific filter value cast to the specified type.
      Type Parameters:
      T - the type parameter
      Parameters:
      key - the filter key
      type - the expected type
      Returns:
      the filter value, or null if not found
      Throws:
      ClassCastException - if the value cannot be cast to the specified type
    • builder

      public static MemoryQuery.Builder builder()
      Creates a new builder for constructing queries.
      Returns:
      a new builder instance
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • scope

      public MemoryScope scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component
    • ownerId

      public String ownerId()
      Returns the value of the ownerId record component.
      Returns:
      the value of the ownerId record component
    • filters

      public Map<String,Object> filters()
      Returns the value of the filters record component.
      Returns:
      the value of the filters record component
    • limit

      public int limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component