3636 MemoryRecordResults ,
3737 MemoryTypeEnum ,
3838 ModelNameLiteral ,
39+ RecencyConfig ,
3940 SessionListResponse ,
4041 WorkingMemory ,
4142 WorkingMemoryResponse ,
@@ -572,6 +573,7 @@ async def search_long_term_memory(
572573 user_id : UserId | dict [str , Any ] | None = None ,
573574 distance_threshold : float | None = None ,
574575 memory_type : MemoryType | dict [str , Any ] | None = None ,
576+ recency : RecencyConfig | None = None ,
575577 limit : int = 10 ,
576578 offset : int = 0 ,
577579 optimize_query : bool = True ,
@@ -671,6 +673,29 @@ async def search_long_term_memory(
671673 if distance_threshold is not None :
672674 payload ["distance_threshold" ] = distance_threshold
673675
676+ # Add recency config if provided
677+ if recency is not None :
678+ if recency .recency_boost is not None :
679+ payload ["recency_boost" ] = recency .recency_boost
680+ if recency .semantic_weight is not None :
681+ payload ["recency_semantic_weight" ] = recency .semantic_weight
682+ if recency .recency_weight is not None :
683+ payload ["recency_recency_weight" ] = recency .recency_weight
684+ if recency .freshness_weight is not None :
685+ payload ["recency_freshness_weight" ] = recency .freshness_weight
686+ if recency .novelty_weight is not None :
687+ payload ["recency_novelty_weight" ] = recency .novelty_weight
688+ if recency .half_life_last_access_days is not None :
689+ payload ["recency_half_life_last_access_days" ] = (
690+ recency .half_life_last_access_days
691+ )
692+ if recency .half_life_created_days is not None :
693+ payload ["recency_half_life_created_days" ] = (
694+ recency .half_life_created_days
695+ )
696+ if recency .server_side_recency is not None :
697+ payload ["server_side_recency" ] = recency .server_side_recency
698+
674699 # Add optimize_query as query parameter
675700 params = {"optimize_query" : str (optimize_query ).lower ()}
676701
@@ -681,7 +706,16 @@ async def search_long_term_memory(
681706 params = params ,
682707 )
683708 response .raise_for_status ()
684- return MemoryRecordResults (** response .json ())
709+ data = response .json ()
710+ # Some tests may stub json() as an async function; handle awaitable
711+ try :
712+ import inspect
713+
714+ if inspect .isawaitable (data ):
715+ data = await data
716+ except Exception :
717+ pass
718+ return MemoryRecordResults (** data )
685719 except httpx .HTTPStatusError as e :
686720 self ._handle_http_error (e .response )
687721 raise
0 commit comments