@@ -98,7 +98,7 @@ async def insert_new_message(body: InsertNewMessage, message: Message):
9898 _l = await check_session_message_lock_or_set (str (body .session_id ))
9999 if not _l :
100100 LOG .info (
101- f"Current Session is processing . "
101+ f"Current Session is locked . "
102102 f"wait { DEFAULT_CORE_CONFIG .session_message_session_lock_wait_seconds } seconds for next resend. "
103103 f"Message { body .message_id } "
104104 )
@@ -113,6 +113,20 @@ async def insert_new_message(body: InsertNewMessage, message: Message):
113113 LOG .info (
114114 f"Session message buffer is full (size: { pending_message_length } ), start process"
115115 )
116+ if (
117+ pending_message_length
118+ > project_config .project_session_message_buffer_max_overflow_turns
119+ ):
120+ LOG .info (
121+ f"Session message buffer is overflow "
122+ f"(size: { pending_message_length } > { project_config .project_session_message_buffer_max_overflow_turns } ), "
123+ f"Truncate the buffer, the rest will be processed later in { DEFAULT_CORE_CONFIG .session_message_session_lock_wait_seconds } seconds"
124+ )
125+ await MQ_CLIENT .publish (
126+ exchange_name = EX .session_message ,
127+ routing_key = RK .session_message_insert_retry ,
128+ body = body .model_dump_json (),
129+ )
116130 await MC .process_session_pending_message (project_config , body .session_id )
117131 finally :
118132 await release_session_message_lock (str (body .session_id ))
@@ -162,7 +176,7 @@ async def buffer_new_message(body: InsertNewMessage, message: Message):
162176 _l = await check_session_message_lock_or_set (str (body .session_id ))
163177 if not _l :
164178 LOG .info (
165- f"Current Session is processing , resend Message { body .message_id } to insert queue."
179+ f"Current Session is locked , resend Message { body .message_id } to insert queue."
166180 )
167181 await MQ_CLIENT .publish (
168182 exchange_name = EX .session_message ,
0 commit comments