Skip to content

Commit 2b6b31a

Browse files
PeiPei233Soulter
andauthored
fix: refresh queued conversation history under the session lock (#10238)
* fix: refresh queued conversation history under the session lock * style: format queued conversation history refresh * Delete tests/unit/test_queued_conversation_history.py --------- Co-authored-by: Soulter <[email protected]>
1 parent 0c99963 commit 2b6b31a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎astrbot/core/astr_main_agent.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,22 @@ async def collect_initial_request(
14401440
list(req.contexts) if isinstance(req.contexts, list) else req.contexts
14411441
)
14421442
if req.conversation:
1443-
req.contexts = json.loads(req.conversation.history)
1443+
# Handler requests can be prepared before the pipeline acquires
1444+
# the session lock. Reload the bound conversation here so queued
1445+
# turns include replies saved while they were waiting.
1446+
conversation = (
1447+
await plugin_context.conversation_manager.get_conversation(
1448+
event.unified_msg_origin, req.conversation.cid
1449+
)
1450+
)
1451+
if conversation is None:
1452+
_set_llm_error_message(
1453+
event,
1454+
"The requested conversation no longer exists. Please send a new message.",
1455+
)
1456+
return None, None
1457+
req.conversation = conversation
1458+
req.contexts = json.loads(conversation.history)
14441459
else:
14451460
req = ProviderRequest()
14461461
req.prompt = ""

0 commit comments

Comments
 (0)