66from astrbot .api .provider import LLMResponse , ProviderRequest
77from astrbot .core import logger
88
9- from .constants import LTM_ACTIVE_REPLY_KEY
9+ from .constants import LTM_ACTIVE_REPLY_IN_PROGRESS_KEY , LTM_ACTIVE_REPLY_KEY
1010from .long_term_memory import LongTermMemory
1111
1212
@@ -99,7 +99,7 @@ async def decorate_llm_req(
9999 # so on_llm_response can correctly identify the active reply response
100100 active_reply_req_id = event .get_extra (LTM_ACTIVE_REPLY_KEY , None )
101101 if active_reply_req_id is not None and id (req ) == active_reply_req_id :
102- event .set_extra ("_ltm_active_reply_in_progress" , True )
102+ event .set_extra (LTM_ACTIVE_REPLY_IN_PROGRESS_KEY , True )
103103 try :
104104 await self .ltm .on_req_llm (event , req )
105105 except BaseException as e :
@@ -112,7 +112,7 @@ async def record_llm_resp_to_ltm(
112112 """在 LLM 响应后记录对话"""
113113 if self .ltm and self .ltm_enabled (event ):
114114 # Skip recording if this response is from an active reply request
115- if event .get_extra ("_ltm_active_reply_in_progress" , False ):
115+ if event .get_extra (LTM_ACTIVE_REPLY_IN_PROGRESS_KEY , False ):
116116 return
117117 # Only record if group_icl_enable is on, to keep session_chats consistent
118118 # (handle_message is also guarded by group_icl_enable)
@@ -136,4 +136,4 @@ async def after_message_sent(self, event: AstrMessageEvent) -> None:
136136 logger .error (f"ltm: { e } " )
137137 # 清除主动回复标记,避免 event 被复用时意外影响后续流程
138138 event .set_extra (LTM_ACTIVE_REPLY_KEY , None )
139- event .set_extra ("_ltm_active_reply_in_progress" , False )
139+ event .set_extra (LTM_ACTIVE_REPLY_IN_PROGRESS_KEY , False )
0 commit comments